简体   繁体   English

编译 java 类“.class”ANT

[英]Compile java classes ".class" ANT

I've a question about compiling and deployment process with ANT tool in JAVA.我有一个关于在 JAVA 中使用 ANT 工具编译和部署过程的问题。

According to my knowledge in java, when we have ".class" files this means that these classes are already compiled.根据我对 java 的了解,当我们有“.class”文件时,这意味着这些类已经编译。 Also a jar files contain compiled classes.还有一个 jar 文件包含已编译的类。

So, how can we compile jars that are already compiled (see the text bellow)?那么,我们如何编译已经编译好的jar(见下文)? Is it possible and why?有可能吗?为什么?

<target name="compile_common" description="compile the java classes ">
    <mkdir dir="${BUILD_PATH}" />
    <javac target="1.6" source="1.6" srcdir="${SRC_COMMON}" destdir="${BUILD_PATH}" failonerror="false" debug="true">
        <classpath>
            <fileset dir="${ECOLL_LIB}">
                <include name="**/*.jar" />
            </fileset>
            <fileset dir="${COMMON_LIB}">
                <include name="**/*.jar" />
            </fileset>
        </classpath>
    </javac>
</target>

I hope that my question is clear.我希望我的问题很清楚。

Those are classpath declarations, they're not telling ant to compile those JARs, they're telling it were JARs needed for the build are.这些是类路径声明,它们不是告诉 ant 编译这些 JAR,而是告诉它构建所需的 JAR 是。

In your case, you make jars part of you classpath.在您的情况下,您将罐子作为类路径的一部分。 You don't need to recompile.你不需要重新编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM