?
Solved

creating an ant build.xml with files coming from multiple places

Posted on 2005-03-23
4
Medium Priority
?
244 Views
Last Modified: 2012-05-05
Hello,

This ant/build.xml is giving me a really difficult time.  I have java files coming from two places

#1 - M:\a19675_sol.view\pnm_config.pr\serv_meta.su\util\jsrc\pnm\servmeta\common
#2 - M:\a19675_sol.view\pnm_config.pr\serv_meta.su\util\jsrc\pnm\servmeta\tools\mibimport

My build.xml is located in #2 (mibimport) and that's where I'm running the build.xml from.
In my build.xml I have

<property name="projectImports" value="M:/a19675_sol.view/pnm_config.pr/serv_meta.su/util/jsrc">

<path id="projectImports.classpath">
     <fileset dir="${projectImports}">
          <include name="**/*.java"/>
     </fileset>
     <pathelement location="${projectImports}"/>
  </path>

<target name="compile" depends="init">
    <javac srcdir="."
           destdir="${obj-dir}">
      <classpath refid="projectImports.classpath"/>
      <classpath refid="thirdPartyJars.classpath"/>
    </javac>
  </target>

Keep in mind that my files in "common" belong to a package called pnm.servmeta.common. I think I'm getting confused with this package, but through trial and error I could not get it.  Any suggestions?  I left parts of code out of my xml file......just a FYI.

My error is:  pnm\servmeta\tools\mibimport\MIBEncoder.java [31] package pnm.servmeta.common does not exist
0
Comment
Question by:nothing8171
  • 2
  • 2
4 Comments
 
LVL 1

Author Comment

by:nothing8171
ID: 13615170
I think the problem is that it's looking for the package from the mibimport folder.........pnm/servmeta are there, but not common.  Even if this is the case I have no idea how to fix it.  :(
0
 
LVL 6

Accepted Solution

by:
mightyone earned 2000 total points
ID: 13615451
<target name="compile" >
   <!-- copy all .java files from ${src} to ${build}  -->
    <copy todir="${build}/">
      <fileset dir="${src}" includes="**/*.java"/>
   <!-- apply a substitution @version@ with the value of ${version} -->
      <filterset>
   <filter token="version" value="${version}"/>
      </filterset>
    </copy>
 <!-- run javac to compile the source files -->
    <javac srcdir="${build}" destdir="${build}">
  <classpath>
    <!-- use the value of the ${classpath} property in the classpath -->
       <pathelement path="${classpath}"/>
    <!-- include all jar files  -->
       <fileset dir="${include}">
           <include name="**/*.jar"/>
       </fileset>
  </classpath>
 </javac>
 
  </target>

it should work for you doubleing

<javac srcdir="${build1}" destdir="${build}">
<javac srcdir="${build2}" destdir="${build}">

more info can be found

http://www.cfdev.com/code_samples/code.cfm/CodeID/83/Java/Simple_Ant_build_xml_Build_Task

or

http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21352719.html
0
 
LVL 1

Author Comment

by:nothing8171
ID: 13615472
Okay......this is messed up.

I added / altered the following code and somehow it built:

<property name="projectImports" value="M:/a19675_sol.view/pnm_config.pr/serv_meta.su/util/jsrc/pnm/servmeta/common"/>
<property name="package" value="M:/a19675_sol.view/pnm_config.pr/serv_meta.su/util/jsrc"/>

<path id="pnm.servmeta.common">
     <fileset dir="${package}">
          <include name="**/*.java"/>
     </fileset>
     <pathelement location="${package}"/>
  </path>

<target name="compile" depends="init">
    <javac srcdir="."
           destdir="${obj-dir}">
      <classpath refid="pnm.servmeta.common"/>
      <classpath refid="projectImports.classpath"/>
      <classpath refid="thirdPartyJars.classpath"/>
    </javac>
  </target>

If someone could tell me why this worked, I will give you the points.
0
 
LVL 6

Expert Comment

by:mightyone
ID: 13615722
due to

<classpath refid="pnm.servmeta.common"/>
<classpath refid="projectImports.classpath"/>


but it can be easier by just

using:

<fileset dir="M:/a19675_sol.view/pnm_config.pr/serv_meta.su/util/jsrc" includes="**/*.java"/>

as it iterates down taking all files *.java
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question