ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 33585] New: - ClassNotFoundException For <junit>
Date Tue, 15 Feb 2005 14:21:50 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=33585>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=33585

           Summary: ClassNotFoundException For <junit>
           Product: Ant
           Version: 1.6.1
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Optional Tasks
        AssignedTo: dev@ant.apache.org
        ReportedBy: duffymo@yahoo.com


I'm running Ant 1.6.1 on Windows XP under Sun's 1.4.2 JDK.  

I've written a build.xml that automatically runs JUnit tests and generates XML 
reports using the JUnitReport task.  It's been successful for me in the past 
with Ant 1.5.

Now when I run it under Ant 1.6 I get a ClassNotFoundException for my TestCase.

I know that means CLASSPATH problems.  I've set build.sysclasspath=ignore in my 
properties file and set the CLASSPATH inside the build.xml.  When I click on 
Properties in the XML report I can see the class that can't be found in 
java.class.path, so I believe it's set correctly.

I can't for the life of me figure out why the class loader can't find the 
TestCases.  

Here are the properties I've used:

# Project specific items that change each time
project=oe-rtf
major=1
minor=0
version=${major}.${minor}
jar.name=${project}
versiondate=${TODAY}

# Tells Ant to ignore the system CLASSPATH and use only the
# internally-set CLASSPATH.  Depend on the build.xml author
# to get the CLASSPATH right.
build.sysclasspath=ignore



# Everything under source should come out of a repository
source=source
source.java=${source}/java
source.lib=${source}/lib
source.bin=${source}/bin
source.xml=${source}/rtf
source.xml=${source}/xml
source.xsl=${source}/xsl




# These are created and deleted by Ant each time
build=build
build.classes=${build}/classes
build.manifest=${build}/manifest
build.lib=${build}/lib
build.javadocs=${build}/javadocs
build.reports=${build}/reports

deploy=deploy
 
Here is the complete build.xml:

<project name="Standard Ant Build XML" default="javadocs" basedir=".">




    <target name="init-props" description="initialize properties">

        <tstamp>
            <format property="touch.time" pattern="MM/dd/yyyy hh:mm aa"/>
        </tstamp>
        
        <filterset id="ant.filters">
            <filter token="DATE" value="${TODAY}"/>
            <filter token="TIME" value="${TSTAMP}"/>
        </filterset>

        <!-- Load in all the settings in the properties file -->
        <property file="build.properties"/>

    </target>




    <target name="prepare" depends="init-props" description="create all the 
necessary directories">
        <mkdir dir="${build}"/>
        <mkdir dir="${build.javadocs}"/>
        <mkdir dir="${build.classes}"/>
        <mkdir dir="${build.manifest}"/>
        <mkdir dir="${build.reports}"/>
        <mkdir dir="${deploy}"/>
    </target>




    <target name="clean" depends="init-props" description="clean up the output 
directories">
        <delete dir="${build.javadocs}"/>
        <delete dir="${build.javadocs}"/>
        <delete dir="${build.classes}"/>
        <delete dir="${build.manifest}"/>
        <delete dir="${build.reports}"/>
        <delete dir="${deploy}"/>
    </target>




    <!-- Set the project class path for all targets -->
    <target name="set-classpath" depends="prepare" description="set the project 
classpath">

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

            <fileset dir="${build.classes}">
                <patternset>
                    <include name="**/*.class"/>
                </patternset>
            </fileset>
        </path>

    </target>




    <target name="echo-classpath" depends="set-classpath" description="echo the 
classpath">
        <pathconvert dirsep=";" pathsep="/" property="converted.class.path">
            <path refid="project.class.path"/>
        </pathconvert>
        <echo message="${converted.class.path}"/>
    </target>




    <target name="compile" depends="set-classpath" description="compile all 
java">
        <javac srcdir="${source.java}"
               destdir="${build.classes}"
               deprecation="on"
               debug="on">
            <classpath refid="project.class.path"/>
            <include name="**/*.java"/>
        </javac>
    </target>




    <target name="test" depends="compile" description="run all unit tests">
        <pathconvert dirsep="/" pathsep=";" property="converted.class.path">
            <path refid="project.class.path"/>
        </pathconvert>
        <echo message="${converted.class.path}"/>
        <junit>
            <classpath refid="project.class.path"/>
            <formatter type="xml"/>
            <batchtest fork="yes" todir="${build.reports}">
                <fileset dir="${build.classes}">
                    <include name="**/*TestCase.class"/>
                </fileset>
            </batchtest>
        </junit>
    </target>




    <target name="report" depends="test" description="create HTML report for 
JUnit test results">
        <junitreport todir="${build.reports}">
            <fileset dir="${build.reports}">
                <include name="TEST-*.xml"/>
            </fileset>
            <report format="frames" todir="${build.reports}"/>
        </junitreport>
    </target>



    <target name="deploy" depends="report" description="deploy the application">

        <buildnumber/>

        <manifest file="${build.manifest}/manifest.mf">
            <attribute name="Implementation-Title"      value="${project}"/>
            <attribute name="Built-By"                  value="${user.name}"/>
            <attribute name="Build-Date"                value="${TODAY}"/>
            <attribute name="Major-Version"             value="${major}"/>
            <attribute name="Minor-Version"             value="${minor}"/>
            <attribute name="Build-Number"              
value="${build.number}"/>
        </manifest>

        <jar jarfile="${deploy}/${project}.jar" 
             manifest="${build.manifest}/manifest.mf">
            <fileset dir="${build.classes}" excludes="**/*TestCase*.class, 
**/*TestSuite*.class"/>
        </jar>

        <jar jarfile="${deploy}/${project}-tests.jar"
             manifest="${build.manifest}/manifest.mf">
            <fileset dir="${build.classes}" includes="**/*TestCase*.class, 
**/*TestSuite*.class"/>
        </jar>

        <copy todir="${deploy}">
            <fileset dir="${source.lib}"/>
        </copy>

    </target>




    <target name="javadocs" depends="deploy" description="generate complete 
javadocs">
        <javadoc sourcepath="${source.java}"
                 destdir="${build.javadocs}"
                 overview="${source.java}/overview.html">
            <classpath refid="project.class.path"/>
            <packageset dir="${source.java}"/>
        </javadoc>
    </target>

</project>

I'll apologize in advance if it's a boneheaded thing on my part.  Thanks - %

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message