Hi all. I have searched google and searched the forums here but I just cannot seem to get this working. I do my development on Linux (in Eclipse) but everyone else at my work uses IntelliJ on Windows. There is interest in moving everyone to Eclipse -- even the guys running Windows. Unfortunately, our Java code isn't in the normal structure that Eclipse likes (src/com/companyname/package/Foo.java). To get around this on Linux I just wrote a shell script that figures out the package name in each Java file by recursively traversing the Java directory, and then creates symbolic links in the appropriate place. I tried running this script in Cygwin on Windows but it took like 10 minutes to run for some reason, which is unacceptable.
Thus, today I wrote up a little Java program that uses the FileUtils.copyFile() method of the Commons IO project, and it copies all of the files to the appropriate structure -- works beautifully in Windows. Now in Eclipse on Windows I can connect up the debugger to a remote Tomcat environment and Eclipse will let me properly step through the source code (since everything is copied under the src directory as desired).
With that out of the way, I would like to further automate the Windows build. Essentially I would like the ant task to invoke a Java target, essentially calling this Java class that I just wrote after a successful build. So the logic is something like this:
- ant compile task runs
- if compilation is successful, then invoke this external Java program I wrote
I don't think I need to fire up a separate JVM, so it should be relatively simple. I have been trying to use this tutorial but I just can't seem to get things working properly:
http://www.java-tips.org/other-api-tips/ant/how-to-use-java-task.html
Let's just suppose for the sake of argument that the bytecode is at C:\build-tools\CopyFiles.class and that commons-io-2.0.1.jar is in this same directory. To invoke the class manually I would just do this:
I am just using the default package in CopyFiles.java (e.g. I don't define any package statement in there). How exactly do I invoke my Java class upon a successful ant build? It seems like it should be something like this:
Is that right? If so, where does it go -- inside the <target name="compile" ...> tag, or outside of it? I'm confused...any help is appreciated. If we can get this working that would be great. Maybe in the future I can convince them to change the code in SVN to reflect the package structure that Eclipse likes...
Thus, today I wrote up a little Java program that uses the FileUtils.copyFile() method of the Commons IO project, and it copies all of the files to the appropriate structure -- works beautifully in Windows. Now in Eclipse on Windows I can connect up the debugger to a remote Tomcat environment and Eclipse will let me properly step through the source code (since everything is copied under the src directory as desired).
With that out of the way, I would like to further automate the Windows build. Essentially I would like the ant task to invoke a Java target, essentially calling this Java class that I just wrote after a successful build. So the logic is something like this:
- ant compile task runs
- if compilation is successful, then invoke this external Java program I wrote
I don't think I need to fire up a separate JVM, so it should be relatively simple. I have been trying to use this tutorial but I just can't seem to get things working properly:
http://www.java-tips.org/other-api-tips/ant/how-to-use-java-task.html
Let's just suppose for the sake of argument that the bytecode is at C:\build-tools\CopyFiles.class and that commons-io-2.0.1.jar is in this same directory. To invoke the class manually I would just do this:
I am just using the default package in CopyFiles.java (e.g. I don't define any package statement in there). How exactly do I invoke my Java class upon a successful ant build? It seems like it should be something like this:
Is that right? If so, where does it go -- inside the <target name="compile" ...> tag, or outside of it? I'm confused...any help is appreciated. If we can get this working that would be great. Maybe in the future I can convince them to change the code in SVN to reflect the package structure that Eclipse likes...