?
Solved

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

Posted on 2005-03-23
4
Medium Priority
?
239 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month7 days, 20 hours left to enroll

765 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