0

I created a axis2 soap client project with unit tests using the following command:

wsdl2java -t -uri http://myDomain.tld/myService.svc?wsdl

I then ran ant and got build errors because it could not find junit methods such as fail(),assertNotNull(), etc. I realize I need the compiler to reference a junit jar. Looking in the build.xml I see the following:

<property name="classes" value="${build}/classes"/>
<property name="lib" value="${build}/lib"/>

So I place junit-4.8.2.jar in the build.lib subfolder. I still get the same errors. What else do I need to do to get ant to build my project?

Update:

I made the following changes to the build.xml:

Added the lib folder as a path with the id local.class.path

<path id="local.class.path">
    <fileset dir="${lib}">
        <include name="*.jar"/>
    </fileset>
</path>

Then I modified my init task to look for junit:

    <available classpathref="local.class.path" property="junit.available" classname="junit.framework.TestCase"/>
    <condition property="jars.ok">
        <and>
            <isset property="stax.available"/>
            <isset property="axis2.available"/>
            <isset property="junit.available"/>
        </and>
    </condition>
    <!--Print out the availabilities-->
    <echo message="Stax Availability= ${stax.available}"/>
    <echo message="Axis2 Availability= ${axis2.available}"/>
    <echo message="JUnit Availability= ${junit.available}"/>

And strangely the output is:

H:\Code\Java\test.axis2> ant pre.compile.test
Buildfile: H:\Code\Java\RiskTools.axis2\build.xml

init:
    [mkdir] Created dir: H:\Code\Java\test.axis2\build
    [mkdir] Created dir: H:\Code\Java\test.axis2\build\classes
    [mkdir] Created dir: H:\Code\Java\test.axis2\build\lib

pre.compile.test:
     [echo] Stax Availability= true
     [echo] Axis2 Availability= true
     [echo] JUnit Availability= ${junit.available}

BUILD SUCCESSFUL
Total time: 0 seconds

So it seems I am doing something wrong due to the line [echo] JUnit Availability= ${junit.available}

Justin Dearing
  • 14,270
  • 22
  • 88
  • 161
  • 1
    If you normally do `ant build`, may I suggest that you instead try ant -debug -verbose build >buildStdOut.txt This will definitively show you whether junit-4.8.2 is being included. – rajah9 May 23 '11 at 18:54
  • rajah, Thats good information to know – Justin Dearing May 23 '11 at 19:01

1 Answers1

0

Apparently build/lib is the transient folder that gets blown away by ant clean. I made a folder called lib at the project root and then did the following to the build.xml.

In the root I added <property name="dep_libs" value="${project.base.dir}/lib"/>

I then change my path statement above to:

<path id="local.class.path">
    <fileset dir="${dep_libs}">
        <include name="*.jar"/>
    </fileset>
</path>

Then everything worked.

Justin Dearing
  • 14,270
  • 22
  • 88
  • 161