Bear Bibeault wrote:1. Yes
2. Just let Ant do its thing
2. Ant
Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
O. Ziggy wrote:Hi could you point me to an example?
Bear Bibeault wrote:
O. Ziggy wrote:Hi could you point me to an example?
Not really -- it's not necessary to show you a huge Ant build script.
Just rebuild the war file using Ant and stop worrying about it.
Raghavan Muthu wrote:Bascially, this is done by a Build tool (so that the manual errors are avoided to the maximum). The build tools need the inputs to do its thing (as Bear specified above) and that is all!
Ant is one famous tool. Look at http://ant.apache.org . One extra info is : Ant is purely Java based. Hence its 100% compatible with Java application
You can go through the website itself for an excellent tutorial and other useful information.
Bear Bibeault wrote:Ant should only be rebuilding the changed files. Otherwise, there's a problem with your script.
The source and destination directory will be recursively scanned for Java source files to compile. Only Java files that have no corresponding .class file or where the class file is older than the .java file will be compiled.
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
gaurav kant wrote: But you must go for complete clean and build your project when you want to create WAR for production or deployment on server.
Please correct me if m wrong at any point
O. Ziggy wrote:Thanks all for the responses.
In what situations might it cause a problem to not go for a clean rebuild? How is this likely to cause a problem. Any example?
Thanks
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
gaurav kant wrote:There is no need to recompile a file that has been compiled earlier. This is for the sake of surety that you have latest classes in you build. Suppose you have a vast number of files and you had made some changes in say 60 or 70 files and if you by chance forget to copy 1 or 2 files in your build, what would be the result ? For this we just compile all the files not to leave even a single file and i think there is no harm to do this just before production. what do you think?
one more thing. ANT compiles only those file that have been modified and never touch unmodified files. clean means delete all those files that you have specified in command (in ant script) from build and run ant command by which ant can recompile and place into your build all those deleted files just to ensure that you have latest code in build.
Sam Mercs wrote:
O. Ziggy wrote:Thanks all for the responses.
In what situations might it cause a problem to not go for a clean rebuild? How is this likely to cause a problem. Any example?
Thanks
Also there is one particular case that i can think of that might cause a problem.
Lets say you have a File called Constants.java with a line like,
public static final myName="Sam";
and you are using this constant in another file say xyz.java
print(Constants.myName);
Now you go and make a change to Constants.java and change 'Sam' to 'O.Ziggy'.
Now lets say you run the compile task. This means that your constants file would be recompiled since it has a newer timestamp than the class file. However if the xyz.java file would not be recompiled. (I'm not 100% - does ant work intelligently and re-compile all dependent files?)
If you run such application the see the output - you'll see 'Sam' getting printed instead of 'O.Ziggy'.
--
Another possible pain area. Say you change your system time for some reason while working on a java file. You save the file and run your build script - Since the timestamp of the saved file is older than the time stamp of the compiled file - it won't be re-compiled.
--
Some of the problems I mentioned are stretched too for - but that's why I prefer doing a clean & then build for any production going code - Added safety against some weird and hard to debug cases!
Sam Mercs wrote:
O. Ziggy wrote:Thanks all for the responses.
In what situations might it cause a problem to not go for a clean rebuild? How is this likely to cause a problem. Any example?
Thanks
Also there is one particular case that i can think of that might cause a problem.
Lets say you have a File called Constants.java with a line like,
public static final myName="Sam";
and you are using this constant in another file say xyz.java
print(Constants.myName);
Now you go and make a change to Constants.java and change 'Sam' to 'O.Ziggy'.
Now lets say you run the compile task. This means that your constants file would be recompiled since it has a newer timestamp than the class file. However if the xyz.java file would not be recompiled. (I'm not 100% - does ant work intelligently and re-compile all dependent files?)
If you run such application the see the output - you'll see 'Sam' getting printed instead of 'O.Ziggy'.
--
Another possible pain area. Say you change your system time for some reason while working on a java file. You save the file and run your build script - Since the timestamp of the saved file is older than the time stamp of the compiled file - it won't be re-compiled.
--
Some of the problems I mentioned are stretched too for - but that's why I prefer doing a clean & then build for any production going code - Added safety against some weird and hard to debug cases!
O. Ziggy wrote:Is there any situation where this wont work?
O. Ziggy wrote:2. Could you provide an example on the approach you use from the point a source file comes out from CVS to the point it get to the production environment. (An example with a single file change would be usefull)
Misha Ver wrote:
O. Ziggy wrote:Is there any situation where this wont work?
It would not work for static final, as Sam Mercs wrote above
Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Sam Mercs wrote:
Misha Ver wrote:
O. Ziggy wrote:Is there any situation where this wont work?
It would not work for static final, as Sam Mercs wrote above
And I am not kidding - something similar had really happened - Fortunately for us not in production.
(Build wasn't used that time - just the class file was replaced manually -- but final static's are in-lined at compile time -- You can get some more info on my blog -- http://twisters.quiz4j.com/2009/09/puzzle-53-statically-speaking.html!!)
Sam Mercs wrote:
Misha Ver wrote:
O. Ziggy wrote:Is there any situation where this wont work?
It would not work for static final, as Sam Mercs wrote above
And I am not kidding - something similar had really happened - Fortunately for us not in production.
(Build wasn't used that time - just the class file was replaced manually -- but final static's are in-lined at compile time -- You can get some more info on my blog -- http://twisters.quiz4j.com/2009/09/puzzle-53-statically-speaking.html!!)
Those who dance are thought mad by those who hear not the music. This tiny ad plays the bagpipes:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
|