Note that there are some explanatory texts on larger screens.

plurals
  1. POAnt optional classpath element
    primarykey
    data
    text
    <p>I have some modules and a main runnable project. I have common build file, and </p> <p>build.common.xml</p> <pre><code>&lt;target name="build" &gt; &lt;path id="libraries.classpath"&gt; &lt;fileset dir="${lib.dir}" includes="*.jar" /&gt; &lt;/path&gt; &lt;javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false" source="1.6"&gt; &lt;classpath refid="libraries.classpath" /&gt; &lt;classpath refid="modules.classpath" /&gt; &lt;/javac&gt; &lt;/target&gt; </code></pre> <p>..and every module declares its own dependencies in their build.xml:</p> <pre><code>&lt;path id="modules.classpath"&gt; &lt;pathelement path="../ModuleA/${build.dir}" /&gt; ... &lt;/path&gt; </code></pre> <p>The problem is if there is no internal dependency I get the following exception: "Reference modules.classpath not found."</p> <p>What is the solution for that? <strong>How could I declare an optional classpath element?</strong></p> <p><strong>Note:</strong> <em>If anybody want to suggest to create jars out of my modules, please justify this. I'm going to have 5-10 rapidly changing modules, and I don't want to do unnecesary steps in the build process.</em></p> <p><strong>Update:</strong> I extracted the build into two different targets and created a condition for them, but did not help (it echoes the 'false' and builds with module-dependencies):</p> <pre><code>&lt;target name="build"&gt; &lt;condition property="modules.classpath.set" else="false"&gt; &lt;isset property="modules.classpath"/&gt; &lt;/condition&gt; &lt;echo message="modules.classpath is set: ${modules.classpath.set} " /&gt; &lt;antcall target="build-with-modules" /&gt; &lt;antcall target="build-without-modules" /&gt; &lt;/target&gt; &lt;target name="build-with-modules" if="modules.classpath.set"&gt; &lt;echo message="Building with module-dependencies" /&gt; &lt;javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false" source="1.6"&gt; &lt;classpath refid="libraries.classpath" /&gt; &lt;classpath refid="modules.classpath" /&gt; &lt;/javac&gt; &lt;/target&gt; &lt;target name="build-without-modules" unless="modules.classpath.set"&gt; &lt;echo message="Building with no dependent modules" /&gt; &lt;javac srcdir="${src.dir}" destdir="${build.dir}" includeantruntime="false" source="1.6"&gt; &lt;classpath refid="libraries.classpath" /&gt; &lt;/javac&gt; &lt;/target&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload