Solved

Jakarta Ant Help

Posted on 2006-10-31
15
289 Views
Last Modified: 2010-03-31
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
Comment
Question by:meaar
  • 7
  • 6
  • 2
15 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 17848096
Use a FileSet and wildcard the jars

<fileset dir="x">
    <include path="**/*.jar" />
</fileset>
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 17848104
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
 
LVL 92

Expert Comment

by:objects
ID: 17848109
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
 

Author Comment

by:meaar
ID: 17852067
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
 
LVL 92

Expert Comment

by:objects
ID: 17852894
you cannot do that
instead use the javadoc task and specify the version using the executable attribute.
0
 

Author Comment

by:meaar
ID: 17853429
Object, would you mind giving me an example?  
0
 
LVL 92

Expert Comment

by:objects
ID: 17853527
<javadoc sourcepathref="sources" destdir="javadoc" executable="${env.JAVA_15_HOME}/bin/javadoc" ...
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:meaar
ID: 17853753
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
 
LVL 92

Expert Comment

by:objects
ID: 17853787
How exactly is it not working?
0
 

Author Comment

by:meaar
ID: 17853818
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
 

Author Comment

by:meaar
ID: 17853834
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
 
LVL 92

Expert Comment

by:objects
ID: 17853848
sounds like you're using an old version of ant. Can you upgrade?
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
ID: 17853870
otherwise use pathconvert to create your path

http://ant.apache.org/manual/CoreTasks/pathconvert.html
0
 

Author Comment

by:meaar
ID: 17853881
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
 
LVL 92

Expert Comment

by:objects
ID: 17854389
it was added in 1.6.3, i'd suggest upgrading to latest
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now