Reputation: 4121
I'm working on a build system that has bad practices piled on other bad practices for a long time and I'm in the process of re-writing the build. The languages involved are C/C++, Fortran, Ada, and Java and for the time being I'm sticking with GNU style makefiles -- though we're considering other alternatives such as SCons.
With that said, I'm looking for some specific recommendations -- not recommendations of the form "use a different build system", etc.
Whoever wrote the particular makefile I'm looking at right now had planned on a sequential build of java code that looks something like this:
LIST_OF_JAVA_FILES = file1.java
LIST_OF_JAVA_FILES += file2.java
LIST_OF_JAVA_FILES += file3.java
...
LIST_OF_JAVA_FILES += fileN.java
all: ${LIST_OF_JAVA_FILES}
${LIST_OF_JAVA_FILES} : %.class : %.java
${JAVAC} ${CLASSPATH} ${<}
Provided you perform a build in serial, this works fine. However, as soon as dependencies come into the mix it becomes more problematic.
.java
files in one command-line -vs- one target for each .class
file?
Upvotes: 0
Views: 394
Reputation: 4121
It ended up being most expedient (and the norm for java development as a whole) to just specify all source files in a single build step and allow javac
to resolve all the dependencies that way.
Upvotes: 0
Reputation: 31182
We had similar issue in our project. We decided to build all java code via ant and invoke ant from a makefile.
Unless you have a lot of JNI (c++ <----> java) dependencies this might work for you too.
Good luck.
Upvotes: 1
Reputation: 46482
Doing something like
javac -cp MY_CLASSPATH Main.java
suffices most of the time, as it resolves dependences automatically. Sometimes you may need to use more files on the command line, since some of them may get used without an explicit reference.
There are also ant
and maven
and ivy
and whatever, but it's an overkill for something that simple.
Upvotes: 0