I want the javac task to use jars from the system class path, by which I mean the class path that is installed in the shell environment before ant runs. This class path
CLASSPATH=D:\local\lib\java\*;.;C:\lib\java\*;C:\lib\java\db\*
on my system. I have popular banks that are used by many projects. The main snippet that I use in the assembly file is
<target name="build"> <mkdir dir="${obj}" /> <javac srcdir="${src}" destdir="${obj}" includes="**/*.java" excludes="**/package-info.java **/deprecated/*.java" includeAntRuntime="no" debug="true" debuglevel="source,lines" > <compilerarg value="-Xlint"/> </javac> </target>
Thus, ant only passes the output directory as the classpath.
[javac] '-classpath' [javac] 'D:\dev\tbull-projects\jsonc\obj'
(jsonc is the project I'm working on, and D:\dev\tbull-projects\jsonc is the working directory.) For a while I looked at the documentation and came up with two attempts. First, the attribute classpath="${java.class.path}" to the javac tag. This would skip the extremely long path to the compiler, specifying each jar from ant of its own lib directory, and finally tools.jar from the JDK. Not the class path I wanted.
Second shot set
<property name="build.sysclasspath" value="first" />
before calling javac, and that led me in the right direction. Now these lines were among the weekend:
dropping D:\dev\tbull-projects\jsonc\D:\local\lib\java\* from path as it doesn't exist dropping D:\dev\tbull-projects\jsonc\C:\lib\java\* from path as it doesn't exist dropping D:\dev\tbull-projects\jsonc\C:\lib\java\db\* from path as it doesn't exist dropping D:\dev\tbull-projects\jsonc\C:\Program Files\Java\jdk1.6.0_18\jre\lib\sunrsasign.jar from path as it doesn't exist dropping D:\dev\tbull-projects\jsonc\C:\Program Files\Java\jdk1.6.0_18\jre\classes from path as it doesn't exist
Well, you can imagine that these paths really do not exist. I just don't understand why ant built them that way. He would know how to do path arithmetic in Windows, right?
Perhaps my approach has been corrupted more fundamentally, so I will let you know what I really am after. Therefore, I am developing this project (library) that uses another library. The project will be open source, so I want other developers to be able to create it after they download the dependency library and put it somewhere in their classpath.
From what I saw in other questions about ant + classpath, it seems like this is a normal way to distribute dependency libraries with source code (so the class path can be like. / Libs). But of course I don't want to have jars in my git repository. So how can this be done?