Results 1 to 1 of 1
- 06-05-2009, 09:53 PM #1
FYI: Ant-Netbean Dependency Issues & The Fix
There seems to be a problem w/ ant, that it can't recompile those classes that depend on an interface which has changed.
To illustrate:
Java Code:public class Test implements TestInterface{ public static void main(String[] args){ System.out.println(VALUE); System.out.println(NAME); System.out.println(obj); } }the build file:Java Code:public interface TestInterface { int VALUE = 5; String NAME = "FOO"; Object obj = null; }
First run:Java Code:<target name="compile" depends="init" description="Compiles src files."> <mkdir dir="${classes.dir}"/> <depend srcdir="${src.dir}" destdir="${build.dir}" cache=".depcache" closure="true"> <include name= "**/*.java"/> </depend> <javac srcdir="${src.dir}" destdir="${classes.dir}" deprecation="true" optimize="true" fork="true"/> </target>
Now edit the interface and recompileJava Code:A:\>ant clean run Buildfile: build.xml init: clean: init: compile: [mkdir] Created dir: A:\build\classes [javac] Compiling 2 source files to A:\build\classes run:[b] [java] 5 [java] FOO [java] null [/b] BUILD SUCCESSFUL Total time: 8 seconds A:\>
Java Code:public interface TestInterface { int VALUE = 99; String NAME = "BAR"; Object obj = "Hello World!"; }Java Code:A:\>ant run Buildfile: build.xml init: compile:[b] [depend] The class classes.Test in file A:\build\classes\Test.class is out of date due to TestInterface but has not been deleted because its source file could not be determined[/b] [javac] Compiling 1 source file to A:\build\classes run:[b] [java] 5 [java] FOO [java] Hello World! [/b] BUILD SUCCESSFUL Total time: 6 seconds A:\>
The Fix:
Use an external lib: JMake (was JavaMake).
src only: The jmake utility — Project Kenai
bin attached below...
On second run after "ant clean run" using jmakeJava Code:<target name="compile" depends="init" description="Compiles src files."> <mkdir dir="${classes.dir}"/> <taskdef name="jmake" classpath="jmake.jar" classname="com.sun.tools.jmake.ant.JavaMake"/> <jmake srcdir="${src.dir}" destdir="${classes.dir}" deprecation="true" optimize="true" fork="true" pdbFilename=".depcache/jmake.pdb" failondependentjar="true"/> </target>
Java Code:A:\>ant run Buildfile: build.xml init: compile: [jmake] Jmake version 1.3.5 [jmake] Opening project database... Done. [jmake] Compiling 1 source file to A:\build\classes [jmake] Checking TestInterface [jmake] Compiling 1 source file to A:\build\classes [jmake] Checking Test [jmake] Writing project database... Done. run:[b] [java] 99 [java] BAR [java] Hello World! [/b] BUILD SUCCESSFUL Total time: 10 seconds A:\>
Now what if this is used on netbeans, would it be faster not having to call "ant clean" on every build?
I'll leave that test to IDE users...USE CODE TAGS--> [CODE]...[/CODE]
Get NotePad++ (free)
Similar Threads
-
How to paint on a Netbean 6.5 generated applet?
By Pucho in forum NetBeansReplies: 1Last Post: 03-31-2009, 05:04 PM -
how to create a login system by using netbean 6?
By j007ha in forum NetBeansReplies: 5Last Post: 08-16-2008, 04:33 PM -
Maven Dependency Overview 1.1
By Java Tip in forum Java SoftwareReplies: 0Last Post: 07-02-2008, 07:13 PM -
Maven Dependency Overview 1.0
By Java Tip in forum Java SoftwareReplies: 0Last Post: 04-15-2008, 06:52 PM -
Dependency Analyzer 1.0.3-rc0
By levent in forum Java SoftwareReplies: 0Last Post: 07-30-2007, 04:34 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks