如何使用ANT编译不仅改变了源文件 [英] how to compile only changed source files using ANT

查看:210
本文介绍了如何使用ANT编译不仅改变了源文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写Ant构建这里编译源文件夹是我的脚本的目标编译。

I am trying to write ant build for compiling source folder here is my script target for compiling.

 <target name="compile" depends="init">
        <javac srcdir="${src.dir}" destdir="${classes.dir}" debug="true">
            <classpath refid="master-classpath"/>
        </javac>

    </target>

在我的项目,我有近1000 的.java 文件。当以往单一的的.java 文件高于目标改为趋于编译所有的.java 文件。这使得发展非常缓慢。我只是想知道有没有什么办法或code键更改任务的行为,只编译修改或变更的.java 文件,而不是所有的的.java 文件。

In my project I have near about 1000 .java files. When ever a single .java file is changed above target tends to compile all .java files. Which make development very slow. I just want to know is there any way or code to change the behavior of task to compile only modified or changed .java file rather than all .java file.

请帮我。

推荐答案

据我了解,仅编译修改后的java文件是蚂蚁javac任务的默认行为。蚂蚁使用一个.java文件的时间戳和相应的.class文件,以确定是否一个Java文件需要重新编译。我已经在很多项目中使用它,不会有问题。

As I understand, compiling only the modified java files is the default behavior of ant javac task. Ant uses the timestamp of a .java file and its corresponding .class file to determine if the a Java file needs to be recompiled. I have used it in many projects and never have issues.

下面是您可以检查一些东西。

Here are a few things you can check


  1. 是您的源代码树的目录结构相匹配的Java包
    结构体?请参阅为什么蚂蚁总是重新编译我的所有Java
    文件?
    。这可能是1号的原因,因为它是常见问题。

  1. Is your source tree directory structure matching your Java package structure? Please see Why does ant always recompile all my Java files?. This is probably the number 1 reason since it is in the FAQ.

我看到你的编译目标依赖于的init 目标?什么是的init 目标呢?它是否依赖于任何清洁目标还是它清理.class文件?

I see your compile target depends on init target? What does the init target do? Does it depends on any clean target or does it cleanup the .class files?

你是什么蚂蚁版本?你可以尝试不同的蚂蚁版本,看看如果你仍然有同样的问题?

What is your ant version? Can you try a different ant version to see if you still have the same problem?

如果没有上述修复您的问题,编译后,您可以手动检查.class文件的时间戳,并将其与相应的.java文件的时间戳比较?

If none of the above fixes your issue, after the compilation, can you manually check the .class file timestamp and compare it with the timestamp of the corresponding .java file?

这篇关于如何使用ANT编译不仅改变了源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆