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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

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
CEHJCommented:
>>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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
objectsCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.