ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Douglas Dunn <dkd...@cox.net>
Subject classpath problem using the java task
Date Tue, 04 Jul 2006 22:54:48 GMT
Like many programmers, I pride myself in no wasting other programmer's time by always making
a best effort to find my own answers. BUT, I have just spend almost the entire Forth of July
trying to find out why this VERY BASIC ant project fails. The problem is that ant cannot find
the j2ee.jar extension delivered in the Java EE 5 (i.e. not part of the core API). I've tried
absolutely everything after hours and hours of exhaustive Internet research. Many, many times
it appeared I found the answer, but it would not work. 

So, here I am. Your help would be greatly appreciated. 

HERE IS THE ANT CODE. NOTHING FOLLOWS; PLEASE EMAIL ME IF YOU WOULD LIKE TO HELP AND HAVE
SOME IDEA. I CANNOT LIST EVERYTHING I HAVE TRIED, BUT BELIEVE ME I HAVE TRIED EVERYTHING I
COULD FIND WHILE RESEARCHING THE PROBLEM ON THE INTERNET. I EVEN WOULD BE GREATFUL FOR SOME
IDEA HOW TO PRINT THE CLASSPATH THE java TASK IS USING. I FOUND MANY WAYS TO DO THIS, BUT
NONE, NONE OF THEM WORKED FOR ME. THIS HAS BEEN A REALLY UGLY DAY, AND ON TOP OF IT I READ
SOME REALLY DISTURBING REPLIES FROM THE DEVELOPER'S AT ANT, REPLIES TO OTHER PEOPLE HAVING
SIMILAR PROBLEMS. MANY THANKS IN ADVANCE.

<?xml version="1.0" encoding="UTF-8"?>
<project name="TestHttpServlet"  basedir="." default="run">

    <!-- property names for directories -->
    <property name="src.dir"     value="src"/>
    <property name="build.dir"   value="build"/>
    <property name="classes.dir" value="${build.dir}/classes"/>
    <property name="jar.dir"     value="${build.dir}/jar"/>
    
    <!-- property name for the Main-Class in a JAR manifest -->
    <property name="main-class"  value="TestHttpServlet"/>    
    
    <!-- AS Home -->
    <property name="appserver-home"  value="c:SunAppServer"/>
   


    <!-- CLEAN -->
    <target name="clean" description="Delete all generated files">
         <delete dir="${build.dir}" failonerror="false" />
    </target>
    

    <!-- COMPILE -->
    <target name="compile" depends="clean"
     description="Compiles all .java files in the src directory" 
    >
        <mkdir dir="${classes.dir}"/>
        <javac srcdir="${src.dir}" destdir="${classes.dir}" compiler="javac1.5"/>
    </target>    
    

    <!-- COPY RESOURCES -->
    <target name="copy" depends="compile"
     description="Copies resource files in the src directory to the classes directory in preparation
for archiving"
    >
        <copy todir="${classes.dir}">
        <fileset dir="${src.dir}" excludes="**/*.java"/>
        </copy>
    </target>
	

    <!-- ARCHIVE -->
    <target name="jar" depends="copy"
	    description="archive the .class files and other resources found in the src directory,
and create the manifest file"
    >
            <mkdir dir="${jar.dir}"/>
            <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="build/classes">
            <manifest>
                <attribute name="Main-Class" value="${main-class}"/>
            </manifest>
        </jar>
    </target>
    

    <!-- TEST -->
    <!-- NOTE: fork="true" MUST BE used when executing a .jar file -->
    <target name="run" depends="jar"     
       description="Executes main(String[] args) to test build"
    >
       <java jar="${jar.dir}/${ant.project.name}.jar" fork="true">
          <classpath>
             <pathelement location="${appserver.home}/lib/j2ee.jar"/>
          </classpath>
       </java>
   </target>
    
</project>

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


Mime
View raw message