meaar
asked on
Jakarta Ant Help
Hello,
Because of mixmatch JDK versions I am using an ant exec task to run javadocs. I have a dir with many .jar files which I need to include in the classpath to create the javadocs. What task...or how should I go about adding the jars (without having to list all of them manually or as a new property) in the path.
Any help would be appreciated!
Because of mixmatch JDK versions I am using an ant exec task to run javadocs. I have a dir with many .jar files which I need to include in the classpath to create the javadocs. What task...or how should I go about adding the jars (without having to list all of them manually or as a new property) in the path.
Any help would be appreciated!
Have a look at this example from Lucene, in particular lines 8-12 and 30:
1 <project name="site" default="docs" basedir=".">
2
3 <!-- Initialization properties -->
4 <property name="project.name" value="lucene-site"/>
5 <property name="docs.src" value="../xdocs"/>
6 <property name="docs.dest" value="../docs"/>
7
8 <path id="classpath">
9 <fileset dir="./lib">
10 <include name="**/*.jar"/>
11 </fileset>
12 </path>
13
14 <target name="prepare">
15 <available classname="org.apache.velo city.anaki a.AnakiaTa sk"
16 property="AnakiaTask.prese nt">
17 <classpath refid="classpath"/>
18 </available>
19 </target>
20
21 <target depends="prepare" name="prepare-error" unless="AnakiaTask.present ">
22 <echo>
23 AnakiaTask is not present! Please check to make sure that
24 velocity.jar is in your classpath.
25 </echo>
26 </target>
27
28 <target name="docs" depends="prepare-error" if="AnakiaTask.present">
29 <taskdef name="anakia" classname="org.apache.velo city.anaki a.AnakiaTa sk">
30 <classpath refid="classpath"/>
31 </taskdef>
32 <anakia basedir="${docs.src}" destdir="${docs.dest}/"
33 extension=".html" style="./site.vsl"
34 projectFile="stylesheets/p roject.xml "
35 excludes="**/stylesheets/* * empty.xml **/test/flood/*"
36 includes="**/*.xml"
37 lastModifiedCheck="true"
38 templatePath="${docs.src}/ stylesheet s"
39 >
40 </anakia>
41
42 <copy todir="../docs/images" filtering="no">
43 <fileset dir="../xdocs/images">
44 <include name="**/*.gif"/>
45 <include name="**/*.jpeg"/>
46 <include name="**/*.jpg"/>
47 </fileset>
48 </copy>
49 </target>
50
51 </project>
1 <project name="site" default="docs" basedir=".">
2
3 <!-- Initialization properties -->
4 <property name="project.name" value="lucene-site"/>
5 <property name="docs.src" value="../xdocs"/>
6 <property name="docs.dest" value="../docs"/>
7
8 <path id="classpath">
9 <fileset dir="./lib">
10 <include name="**/*.jar"/>
11 </fileset>
12 </path>
13
14 <target name="prepare">
15 <available classname="org.apache.velo
16 property="AnakiaTask.prese
17 <classpath refid="classpath"/>
18 </available>
19 </target>
20
21 <target depends="prepare" name="prepare-error" unless="AnakiaTask.present
22 <echo>
23 AnakiaTask is not present! Please check to make sure that
24 velocity.jar is in your classpath.
25 </echo>
26 </target>
27
28 <target name="docs" depends="prepare-error" if="AnakiaTask.present">
29 <taskdef name="anakia" classname="org.apache.velo
30 <classpath refid="classpath"/>
31 </taskdef>
32 <anakia basedir="${docs.src}" destdir="${docs.dest}/"
33 extension=".html" style="./site.vsl"
34 projectFile="stylesheets/p
35 excludes="**/stylesheets/*
36 includes="**/*.xml"
37 lastModifiedCheck="true"
38 templatePath="${docs.src}/
39 >
40 </anakia>
41
42 <copy todir="../docs/images" filtering="no">
43 <fileset dir="../xdocs/images">
44 <include name="**/*.gif"/>
45 <include name="**/*.jpeg"/>
46 <include name="**/*.jpg"/>
47 </fileset>
48 </copy>
49 </target>
50
51 </project>
define your path usinf a reference, you can then reuse that reference in any task that require it,. such as your javadoc task.
http://ant.apache.org/manual/using.html#references
http://ant.apache.org/manual/using.html#references
ASKER
CEHJ,
Thanks. I'm running into a little trouble. Here's where I am at... Apparently the exec task does not except classpath refid to be nested so I tried adding it as I did (see line 18), but the classpath does not appear to be visible according to the errors I'm getting. Any ideas on how to make this work. As a note I am using exec for the javadocs because I use a different JDK version for the rest of the build.
1<path id="source_jars">
2 <fileset dir="${src_dir}/jars">
3 <include name="/**/*.jar"/>
4 </fileset>
5 <fileset dir="${env.JAVA_15_HOME}/j re/lib">
6 <include name="jsse.jar"/>
7 </fileset>
8 <pathelement location="${preproc_dir}"/ >
9</path>
10
11<exec executable="${env.JAVA_15_ HOME}/bin/ javadoc" failonerror="true">
12 <arg value="-J-Xmx512m"/>
13 <arg value="-sourcepath"/>
14 <arg value="${preproc_dir}"/>
15 <arg value="-d"/>
16 <arg value="${javadoc_dir}/RWeb "/>
17 <arg value="-classpath"/>
18 <arg value="classpath refid=source_jars"/>
19 <arg value="-protected"/>
20 <arg value="-use"/>
21 <arg value="-author"/>
22 <arg value="-windowtitle"/>
23 <arg value="Web ${major_version}.${minor_v ersion}"/>
24 <arg value="-doctitle"/>
25 <arg value="Library"/>
26 <arg value="-splitindex"/>
27 <arg value="-bottom"/>
28 <arg value="<font size=-2>Build time: ${build.time}<br>Cop yright &copy; ${YEAR} All 29rights reserved.</font>"/>
30 <arg value="@${tmp_dir}/package .list"/>
31</exec>
Thank you in advance!
Thanks. I'm running into a little trouble. Here's where I am at... Apparently the exec task does not except classpath refid to be nested so I tried adding it as I did (see line 18), but the classpath does not appear to be visible according to the errors I'm getting. Any ideas on how to make this work. As a note I am using exec for the javadocs because I use a different JDK version for the rest of the build.
1<path id="source_jars">
2 <fileset dir="${src_dir}/jars">
3 <include name="/**/*.jar"/>
4 </fileset>
5 <fileset dir="${env.JAVA_15_HOME}/j
6 <include name="jsse.jar"/>
7 </fileset>
8 <pathelement location="${preproc_dir}"/
9</path>
10
11<exec executable="${env.JAVA_15_
12 <arg value="-J-Xmx512m"/>
13 <arg value="-sourcepath"/>
14 <arg value="${preproc_dir}"/>
15 <arg value="-d"/>
16 <arg value="${javadoc_dir}/RWeb
17 <arg value="-classpath"/>
18 <arg value="classpath refid=source_jars"/>
19 <arg value="-protected"/>
20 <arg value="-use"/>
21 <arg value="-author"/>
22 <arg value="-windowtitle"/>
23 <arg value="Web ${major_version}.${minor_v
24 <arg value="-doctitle"/>
25 <arg value="Library"/>
26 <arg value="-splitindex"/>
27 <arg value="-bottom"/>
28 <arg value="<font size=-2>Build time: ${build.time}<br>Cop
30 <arg value="@${tmp_dir}/package
31</exec>
Thank you in advance!
you cannot do that
instead use the javadoc task and specify the version using the executable attribute.
instead use the javadoc task and specify the version using the executable attribute.
ASKER
Object, would you mind giving me an example?
<javadoc sourcepathref="sources" destdir="javadoc" executable="${env.JAVA_15_ HOME}/bin/ javadoc" ...
ASKER
Object, looks like the javadoc task does not accept executable nesting... This doesn't seem to work either:
<target name="Javadoc" depends="init,rweb_javadoc -dep,set_1 5_bootclas spath" if="do.rwebjavadoc">
<mkdir dir="${javadoc_dir}/RWeb" />
<path id="source_jars">
<fileset dir="${src_dir}/jars">
<include name="/**/*.jar"/>
</fileset>
<fileset dir="${env.JAVA_15_HOME}/j re/lib">
<include name="jsse.jar"/>
</fileset>
<pathelement location="${preproc_dir}"/ >
</path>
<javadoc
classpath refid="source_jars"
executable="${env.JAVA_15_ HOME}/bin/ javadoc"
sourcepath="${preproc_dir} "
destdir="${javadoc_dir}/RW eb"
additionalparam="-J-Xmx512 m"
access="protected"
use="yes"
verbose="off"
author="on"
windowtitle="Web ${major_version}.${minor_v ersion}"
doctitle="Library"
splitindex="on"
bottom="<font size=-2>Build time: ${build.time}<br>Cop yright &copy; ${YEAR} All rights reserved.</font>"
failonerror="yes"
>
<package name="com.*"/>
</javadoc>
</target>
<target name="Javadoc" depends="init,rweb_javadoc
<mkdir dir="${javadoc_dir}/RWeb" />
<path id="source_jars">
<fileset dir="${src_dir}/jars">
<include name="/**/*.jar"/>
</fileset>
<fileset dir="${env.JAVA_15_HOME}/j
<include name="jsse.jar"/>
</fileset>
<pathelement location="${preproc_dir}"/
</path>
<javadoc
classpath refid="source_jars"
executable="${env.JAVA_15_
sourcepath="${preproc_dir}
destdir="${javadoc_dir}/RW
additionalparam="-J-Xmx512
access="protected"
use="yes"
verbose="off"
author="on"
windowtitle="Web ${major_version}.${minor_v
doctitle="Library"
splitindex="on"
bottom="<font size=-2>Build time: ${build.time}<br>Cop
failonerror="yes"
>
<package name="com.*"/>
</javadoc>
</target>
How exactly is it not working?
ASKER
Here's the error I am getting when I run the target:
D:\rweb\trunk\rweb-targets .xml:5391: Attribute name "classpath" associated with
an element type "javadoc" must be followed by the ' = ' character.
Not sure what I changed, but initially I was getting a nesting error.
D:\rweb\trunk\rweb-targets
an element type "javadoc" must be followed by the ' = ' character.
Not sure what I changed, but initially I was getting a nesting error.
ASKER
Here's the nexting error. I get this when I remove the classpath refid:
BUILD FAILED
D:\rweb\trunk\rweb-targets .xml:5405: The <javadoc> type doesn't support the "exe
cutable" attribute.
BUILD FAILED
D:\rweb\trunk\rweb-targets
cutable" attribute.
sounds like you're using an old version of ant. Can you upgrade?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I figured that was the problem. Any idea which version I need? I have 1.6.2. I just looked at the current version 1.6.5 (stable) and I don't see anything about javadoc exec bug fixes.
it was added in 1.6.3, i'd suggest upgrading to latest
<fileset dir="x">
<include path="**/*.jar" />
</fileset>