[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 342
  • Last Modified:

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!
0
meaar
Asked:
meaar
  • 7
  • 6
  • 2
1 Solution
 
CEHJCommented:
Use a FileSet and wildcard the jars

<fileset dir="x">
    <include path="**/*.jar" />
</fileset>
0
 
CEHJCommented:
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.velocity.anakia.AnakiaTask"
     16             property="AnakiaTask.present">
     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.velocity.anakia.AnakiaTask">
     30             <classpath refid="classpath"/>
     31         </taskdef>
     32         <anakia basedir="${docs.src}" destdir="${docs.dest}/"
     33              extension=".html" style="./site.vsl"
     34              projectFile="stylesheets/project.xml"
     35              excludes="**/stylesheets/** empty.xml **/test/flood/*"
     36              includes="**/*.xml"
     37              lastModifiedCheck="true"
     38              templatePath="${docs.src}/stylesheets"
     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>
0
 
objectsCommented:
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
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
meaarAuthor Commented:
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}/jre/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_version}"/>
24      <arg value="-doctitle"/>
25      <arg value="Library"/>
26      <arg value="-splitindex"/>
27      <arg value="-bottom"/>
28      <arg value="&lt;font size=-2&gt;Build time: ${build.time}&lt;br&gt;Copyright &#38;copy; ${YEAR} All 29rights reserved.&lt;/font&gt;"/>
30      <arg value="@${tmp_dir}/package.list"/>
31</exec>

Thank you in advance!
0
 
objectsCommented:
you cannot do that
instead use the javadoc task and specify the version using the executable attribute.
0
 
meaarAuthor Commented:
Object, would you mind giving me an example?  
0
 
objectsCommented:
<javadoc sourcepathref="sources" destdir="javadoc" executable="${env.JAVA_15_HOME}/bin/javadoc" ...
0
 
meaarAuthor Commented:
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_15_bootclasspath" 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}/jre/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}/RWeb"
                  additionalparam="-J-Xmx512m"
                  access="protected"
                  use="yes"
                  verbose="off"
                  author="on"
                  windowtitle="Web ${major_version}.${minor_version}"
                  doctitle="Library"
                  splitindex="on"
                  bottom="&lt;font size=-2&gt;Build time: ${build.time}&lt;br&gt;Copyright &#38;copy; ${YEAR}  All rights reserved.&lt;/font&gt;"
                  failonerror="yes"
    >
      <package name="com.*"/>
      </javadoc>
  </target>
0
 
objectsCommented:
How exactly is it not working?
0
 
meaarAuthor Commented:
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.  
0
 
meaarAuthor Commented:
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.
0
 
objectsCommented:
sounds like you're using an old version of ant. Can you upgrade?
0
 
objectsCommented:
otherwise use pathconvert to create your path

http://ant.apache.org/manual/CoreTasks/pathconvert.html
0
 
meaarAuthor Commented:
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.  
0
 
objectsCommented:
it was added in 1.6.3, i'd suggest upgrading to latest
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now