简体   繁体   中英

Include other project java files in build.xml

I have project called LTSWebEJB in eclipse. This Project reference another project called LTSCommonUtil. I have written build file for LTSWebEJB as,

<?xml version="1.0"?>
<project name="ejbproj" default="deploy">

    <property name="build.dir" value="build" />
    <property name="jarName" value="LTSWebEJB.jar" />
    <property name="JBOSS" value="C:\Lts8083\jboss-as-web-7.0.0.Final" />
    <property name="JBOSSLIB" value="${JBOSS}\modules\javax" />

    <path id="project.class.path">
        <fileset dir="../LTSWebEAR/ear/lib" includes="*.jar"/>
        <fileset dir="${JBOSSLIB}/persistence/api/main" includes="*.jar"/>
    <fileset dir="${JBOSSLIB}/ejb/api/main" includes="*.jar"/>
    <fileset dir="${JBOSSLIB}/servlet/api/main" includes="*.jar"/>
    <fileset dir="../LTSCommonUtil/src" includes="src/com/eiw/server/"/>
    </path>

   <target name="clean" description="Cleans this project">
    <delete dir="${build.dir}" failonerror="false" />
    <delete dir="../LTSWebEAR/ear/${jarName}" failonerror="false" />
  </target>

  <target name="compile" depends="clean" description="Compile java source to bytecode">
    <mkdir dir="${build.dir}"/>
    <javac srcdir="src" includes="**/*.java"  encoding="utf-8"
        destdir="build" excludes="*.java"
        source="1.5" target="1.5" nowarn="true"
        debug="true" debuglevel="lines,vars,source">
         <classpath refid="project.class.path"/>
    </javac>
  </target>

  <target name="deploy" depends="compile" description="Deploy this jar to Ear location">
      <copy todir="${build.dir}" > <fileset dir="src" excludes="*.java"/> </copy>
      <jar destfile="../LTSWebEAR/ear/${jarName}" >
            <fileset
                dir="${build.dir}"
                excludes="**/Test.class" />
        </jar>
  </target>

</project>

But LTSWebEJB fails compilation as it shows cannot find symbol. It is unable to take classes from LTSCommonUtil project. But i had included it in the line "". Please help.

I'm guessing but I reckon the issue is how you've declared your path to the other project's class files. Need to specify the root directory corresponding to the class's package.

Here's my blind attempt to fix the problem, but a second question must be asked.... Why the "src" directory? Have you compiled the other project into ".class" files?

<path id="project.class.path">

  <fileset dir="../LTSWebEAR/ear/lib" includes="*.jar"/>
  <fileset dir="${JBOSSLIB}/persistence/api/main" includes="*.jar"/>
  <fileset dir="${JBOSSLIB}/ejb/api/main" includes="*.jar"/>
  <fileset dir="${JBOSSLIB}/servlet/api/main" includes="*.jar"/>

  <pathelement location="../LTSCommonUtil/src"/>

</path>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM