Apache-Ant Build

Hey experts,

 I have this build xml configuration that is used by apache-ant build:

<target name="compile-map5" description="Compile all belgacomedi source">
    <echo>Compiling belgacomedi Mappers</echo>
    <subant target="compile" inheritall="false">
      <fileset dir="${ecmp.config.dir}/mappers/belgacomedi">
        <patternset refid="subant.build.patternset"/>
      </fileset>
    </subant>
  </target>

I want to know first of all if this is a standard (or is it specific to my project); and second, if it's a standard, then what would be the option to allow it to include external libraries??

P.S.: In this project, a batch file is used for the build & the target above would be used as parameter (i.e. build.bat compile-map5)
LVL 3
mte01Asked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
>>The classpath element should go in the 'compile' target

More precisely in the javac task in the 'compile' target

There should also be a target simply named 'compile'

>>This one above compiles properly when targetted

Please print the output
0
 
CEHJCommented:
Yes it's standard.

>>what would be the option to allow it to include external libraries??

You'dd add them to the <classpath> element in the compile target
0
 
mte01Author Commented:
>>Yes it's standard.

Oh my god!!...I've been suffering with this script for more than a month especially when I want to change some compile options....I thought it was some configuration specific to that project....I'll be trying your option now...
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.

 
CEHJCommented:
>>I thought it was some configuration specific to that project.

Well it *is* specific to some project, but as far as Ant principles go, it's standard
0
 
mte01Author Commented:
>>but as far as Ant principles go, it's standard

Yes, that's what I meant....

I made it this way:

<target name="compile-map5" description="Compile all belgacomedi source" >
    <echo>Compiling belgacomedi Mappers</echo>
    <subant target="compile" inheritall="false">
      <fileset dir="${ecmp.config.dir}/mappers/belgacomedi">
        <patternset refid="subant.build.patternset"/>
      </fileset>
    </subant>
      <classpath refid="mappers.classpath" />
  </target>

where mappers.classpath is as defined in another xml file:

<!-- Main classpath for compiling mappers -->
  <path id="mappers.classpath">
    <path refid="common.classpath"/>
    <pathelement location="${xercesImpl.jar}"/>
  </path>

and xercesImpl.jar is my jar file with its location & name defined properly in another file...

but I am getting the following error: Could not create task or type of type: classpath
0
 
CEHJCommented:
The classpath element should go in the 'compile' target
0
 
mte01Author Commented:
In this config. file, there are two types of targets, one with this compile option:

<target name="compile-ecmp" depends="compile-sbm,castor-gen-ecmp" description="Compile the source for ECMP">
    <echo>Compiling ECMP</echo>
    <mkdir dir="${ecmp.classes.dir}"/>
    <javac debug="${build.debug}"
           deprecation="${build.deprecation}"
           includeAntRuntime="${build.includeAntRuntime}"
           optimize="${build.optimize}"
           fork="true"
           memoryInitialSize="${build.msSize}"
           memoryMaximumSize="${build.mxSize}"
           srcdir="${src.dir}"
           destdir="${ecmp.classes.dir}"
           includesfile="ecmpappinclude.list"
           excludesfile="ecmpappexclude.list">
      <classpath refid="ecmp.classpath"/>
    </javac>
  </target>

and one without it....as this one:

<target name="compile-map5" description="Compile all belgacomedi source">
    <echo>Compiling belgacomedi Mappers</echo>
    <subant target="compile" inheritall="false">
      <fileset dir="${ecmp.config.dir}/mappers/belgacomedi">
        <patternset refid="subant.build.patternset"/>
      </fileset>
    </subant>
  </target>

This one above compiles properly when targetted; this compilation must be defined somewhere in another xml file, but it seems that I can't find where...
0
 
mte01Author Commented:
>>Please print the output

compile-map5:
     [echo] Compiling belgacomedi Mappers

wlInit:

init:

compile-global-jsp:
     [echo] Building belgacomedi
    [javac] Compiling 1 source file to C:\work\CMP\build\import-mods\belgacomedi\classes

compile:

BUILD SUCCESSFUL
Total time: 11 seconds
0
 
mte01Author Commented:
>>There should also be a target simply named 'compile', More precisely in the javac task in the 'compile' target

Yes, in fact there is one, in a build.xml file  (inside the specified directory in compile-map5), but it has no javax task...:( :

<target name="compile" depends="compile-global-jsp" if="localjsp.exists">
    <weblogicjspc-macro modName="${module.name}" srcdir="${module.jsp.src.dir}"/>
  </target>
0
 
CEHJCommented:
Search for string

target name="compile"

starting in the same directory
0
 
CEHJCommented:
Yes, this is a tangled web ;-)

Can you post the one with

<target name="compile-global-jsp"

?
0
 
mte01Author Commented:
Here you go:

<target name="compile-global-jsp" depends="init">
    <compile-module-macro modName="${module.name}" />
    <copy file="${module.config.dir}/${module.name}${versionMetadata.xml.name}" tofile="${module.build.dir}/${versionMetadata.xml.name}"/>
    <weblogicjspc-macro modName="${module.name}" srcdir="${billimport.jsp.src.dir}"/>
  </target>
0
 
mte01Author Commented:
and here's the contents of that xml file specified in ="${module.config.dir}/${module.name}${versionMetadata.xml.name}":

<?xml version="1.0"?>
<VersionMetadata>
  <Global>
    <DataLocatorClass>com.tangoe.cmp.enterprise.controller.actions.billing.newimport.modules.belgacomedi.BelgacomEDIDataLocator</DataLocatorClass>
    <VersionSelectorClass>com.tangoe.cmp.enterprise.business.services.billing.billimport.VersionOneSelector</VersionSelectorClass>
    <Properties>
       <Property>
          <name>defaultDirectory</name>
          <value></value>
       </Property>
       <Property>
          <name>PropertiesFileName</name>
          <value>belgacomedi.properties</value>
       </Property>
       <Property>
          <name>STXConfigDirectory</name>
          <value>belgacomedi</value>
       </Property>
    </Properties>
  </Global>
  <Versions>
    <Version versionId="1.0" startDate="" endDate="">
      <MetadataFile>belgacomediBillingMetadata001.xml</MetadataFile>
      <MetadataClass>com.tangoe.cmp.enterprise.business.data.billing.billimport.belgacomedi.BelgacomEDIMetaData</MetadataClass>
      <DataRetrieverClass>com.tangoe.cmp.enterprise.controller.actions.billing.newimport.modules.belgacomedi.BelgacomEDIDataRetriever</DataRetrieverClass>
      <MapperClass>com.tangoe.cmp.enterprise.business.services.billing.billimport.mapper.belgacomedi.BaseBelgacomEDIIterativeMapper</MapperClass>
      <classpath>
        <jar>jars/commons-logging.jar</jar>
        <jar>jars/joost.jar</jar>
        <jar>jars/sax2.jar</jar>
        <jar>jars/xercesImpl.jar</jar>
      </classpath>
    </Version>
  </Versions>
</VersionMetadata>

I added the jar file that I need to this section above: jars/xercesImpl.jar, but when I change my java file to include one of its classes, I get a compile error that the package doesn't exist....
0
 
CEHJCommented:
>>I added the jar file that I need to this section above: jars/xercesImpl.jar

Have you put xercesImpl.jar in the same directory as joost.jar?
0
 
objectsCommented:
> I added the jar file that I need to this section above: jars/xercesImpl.jar, but when I change my java file to include one of its classes, I get a compile error that the package doesn't exist....

which package?
0
 
mte01Author Commented:
>>CEHJ

Yes, xercesImpl.jar is inthe same directory as joost.jar

>>objects

org.apache.xerces.parsers.*
0
 
objectsConnect With a Mentor Commented:
and is that package is in that jar?

jar tvf xercesImpl.jar
0
 
mte01Author Commented:
>>objects
>>and is that package is in that jar?

Yes..I extracted the package's folder and put it with my classes' files, and now it compiles fine...of course this is only a temporary solution untill this problem gets solved
0
 
objectsCommented:
are you sure its actually looking at the correct jars directory.
if u delete one of thoses other jars from the directory do they stop getting resolved (it could be picking them up elsewhere)

perhaps also try an absoluter path to the jars directory instead of a relative one.
0
 
CEHJCommented:
You can run ant:

ant -d <target name>

and get some debug info
0
 
mte01Author Commented:
>>CEHJ

In the output of your command:
Setting project property: xercesImpl.jar -> C:\work\CMP\lib/xercesImpl.jar

very weird..isn't it?!
0
 
CEHJCommented:
Yes it is a bit, but not necessarily a sign that it's broken. You could put an echo of ${java.class.path} somewhere too

0
 
mte01Author Commented:
>>You could put an echo of ${java.class.path}

In which file, the xml file??
0
 
CEHJCommented:
In any target that's being run
0
 
mte01Author Commented:
>>CEHJ,objects

problem solved by using weblogic.apche.xerces.parsers.* (instead of org.)....apparently since WebLogic is used in this project, any reference to xerces should come from weblogic classes, rather then the original apache classes..thanks for your help guys!
0
 
objectsCommented:
yep, that'd cause a problem.
good to hear u got it solved :)
0
 
CEHJCommented:
:-)
0
All Courses

From novice to tech pro — start learning today.