How to make Compilation faster

J

juergen

Hi,
I was using C/C++ and make files for many years (2 decades). It was
possible to compile large project with many source-files very quickly,
because only the updated file needed to be compiled and the rest only
linked.

$(BINARY):$(OBJFILES)
$(CC) $(OBJFILES) $(LIBS) -o $(BINARY)
midev.o : $(CODIRmm)/midev.c
$(CC) $(CFLAGS) -c $< -o $@
....

In Java it is also possible to use make. First compile the class-files,
then generate the *.jar.
I tried to write a makefile that compiles every *.java file
individually, but that wouldn't work.
It seems that javac only compiles when all source-files are given like
this:

notdis.jar: $(SRC) $(TSRC)
javac -g -d build $(SRC) $(TSRC)
jar cfm $@ manifest.mf -C build .

How do you handle big projects with many source-files?
Useful ideas are very welcome!
Juergen
 
T

Thomas Kellerer

In Java it is also possible to use make. First compile the class-files,
then generate the *.jar. [...]

How do you handle big projects with many source-files?
Useful ideas are very welcome!
Juergen

Use ant instead of make. It will only recompile the needed files and is
the de-facto standard in the Java environment.

http://ant.apache.org/

Thomas
 
T

TechBookReport

juergen said:
Hi,
I was using C/C++ and make files for many years (2 decades). It was
possible to compile large project with many source-files very quickly,
because only the updated file needed to be compiled and the rest only
linked.

$(BINARY):$(OBJFILES)
$(CC) $(OBJFILES) $(LIBS) -o $(BINARY)
midev.o : $(CODIRmm)/midev.c
$(CC) $(CFLAGS) -c $< -o $@
...

In Java it is also possible to use make. First compile the class-files,
then generate the *.jar.
I tried to write a makefile that compiles every *.java file
individually, but that wouldn't work.
It seems that javac only compiles when all source-files are given like
this:

notdis.jar: $(SRC) $(TSRC)
javac -g -d build $(SRC) $(TSRC)
jar cfm $@ manifest.mf -C build .

How do you handle big projects with many source-files?
Useful ideas are very welcome!
Juergen
As Thomas has already said, in Java ant is pretty much standard. But
there are other tools, and plenty of ant extensions. Take a look at the
list here: http://www.java-source.net/open-source/build-systems
 
J

jAnO!

Thomas Kellerer said:
In Java it is also possible to use make. First compile the class-files,
then generate the *.jar. [...]

How do you handle big projects with many source-files?
Useful ideas are very welcome!
Juergen

Use ant instead of make. It will only recompile the needed files and is
the de-facto standard in the Java environment.

http://ant.apache.org/

Thomas

Last 2 years, maven is becomming even more popular and usefull btw.
 
C

cmmagid

TechBookReport said:
As Thomas has already said, in Java ant is pretty much standard. But
there are other tools, and plenty of ant extensions. Take a look at the
list here: http://www.java-source.net/open-source/build-systems


I have not done this since my company went over to using make with
java and I moved to using Eclipse. I believe that, unless classes are
loaded in a non standard way, i.e. by their string name and your class
path is correct, 'javac' does a reasonable job of locating the
dependant files to be compiled. Javac does this with out any use of
'make', 'ant', 'maven or IDE..


Ex: javac MyMain.java
javac MyClassesLoadedDynamically*.java
..
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

jAnO! said:
Last 2 years, maven is becomming even more popular and usefull btw.

Maven is more popular now than it was 2 years ago.

Maven is not more popular than ant.

Some like Maven - some don't.

Arne
 
W

Wibble

I have not done this since my company went over to using make with
java and I moved to using Eclipse. I believe that, unless classes are
loaded in a non standard way, i.e. by their string name and your class
path is correct, 'javac' does a reasonable job of locating the
dependant files to be compiled. Javac does this with out any use of
'make', 'ant', 'maven or IDE..


Ex: javac MyMain.java
javac MyClassesLoadedDynamically*.java
.
Javac is great if your not in a hurry. Ant is much faster, but can
sometimes get compile time dependencies wrong.
 
B

bugbear

Wibble said:
Javac is great if your not in a hurry. Ant is much faster, but can
sometimes get compile time dependencies wrong.

Agreed. I use Ant, but if I have the SLIGHTEST
suspicion (experience is a good guide) that my build
my have "faulty" dependancies, I have (and use)
an Ant target that does a full unconditional build.

The result is that my normal compile-JUnit cycle is around
2-3 seconds.

BugBear
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top