Qing Zhang
Qing Zhang

Reputation: 117

Ant built does not generate class files

I'm using build.xml to build my src. However it failed to generate class files without any error message. The full script is

<?xml version="1.0"?>

<project name="auxiliary" basedir="." default="dist">

<property name="src.dir" value="../auxiliary-src/com/nextbio/drugbank"/>
<property name="dist.dir" value="dist"/>
<property name="lib.dir" value="../jboss_config/common_app_jars"/>
<property name="temp.dir" value="temp"/>
<property name="foo_dist.dir" value="../foo/dist"/>

<path id="libs-classpath">
    <fileset dir="${foo_dist.dir}">
            <include name="foo.jar"/>
    </fileset>  

</path> 
<target name="dist" depends="auxiliary-dist" />


<target name="auxiliary-cleanup">
        <delete dir="${temp.dir}"/>
        <delete dir="${dist.dir}"/>
        <echo message="cleaned up. ${temp.dir}, and ${dist.dir} have been deleted."/>
</target>

<target name ="auxiliary-dist">

    <delete dir="${temp.dir}"/>
    <echo message="delete ${temp.dir}" />
        <mkdir dir="${temp.dir}"/>

    <javac destdir="${temp.dir}" source="1.6" target="1.6" debug="on" fork="true" memorymaximumsize="1024m">
        <src path="${src.dir}"/>
        <classpath>
            <path refid="libs-classpath"/>          
        </classpath>
        <include name="com/car/**"/> <!-- troubled line -->

    </javac>
    <!--<copy overwrite="true" todir="${temp.dir}">
        <fileset dir="${src.dir}">
            <exclude name="**/*.java"/>
            <exclude name="**/*.sql"/>
            <exclude name="**/*.txt"/>
        </fileset>
    </copy> 
     <delete dir="${dist.dir}"/>
     <mkdir dir="${dist.dir}"/>
     <jar destfile="${dist.dir}/auxiliary.jar" basedir="${temp.dir}"/> -->

</target>

There is no class file in ${temp.dir} after this step, and no error message. I double checked it, and found it is because of the "troubled line". I tried to add some files to the classpath. I don't know why it is wrong.

Upvotes: 1

Views: 8001

Answers (3)

Cristian Florescu
Cristian Florescu

Reputation: 1816

I encountered this "ant, javac, compile" problem related with the classpath to.

No debug or verbose message shown.

This behavior appear because in classpath exists not compatible (superior) version jar packages and that cause no output classes.

Upvotes: 0

Cesargv
Cesargv

Reputation: 29

I had the same problem.

My project complilated well but the classes there weren't in nowhere and It didn't have any error message.

My problem was the classpath. The eclipse wizard added EclipseLink 2.5.1 jars. I removed it and the problem is gone.

I suggest make a simple HelloWord and remove all jars reference from the classpath and try again.

Upvotes: 0

JB Nizet
JB Nizet

Reputation: 691655

The source path should point to the root of the package tree. You make it point to a specific package inside the sources : ../auxiliary-src/com/nextbio/drugbank.

And in the javac task, you ask it to compile all the files matching the pattern com/car/**. That means that it will compile the Java source files in ../auxiliary-src/com/nextbio/drugbank/com/car or in a subdirectory. If that's the case, you have very unconventional package names.

Upvotes: 1

Related Questions