2

I have a project called MyApp in eclipse. I have another project called TestRepository that contains in it, the testcases written for MyApp project.

I am trying to compile the testcases and generate a junit report using groovyc ant task whose classpath is :

<path id="classpath">
   <fileset dir="lib/MyApp">
      <include name="*.jar" />
   </fileset>   
</path>

The jar files of MyApp are added on classpath. If in case, a class of MyApp project referred in a testcase is not existing in the jars of lib folder, I want the groovyc to search for the class in MyApp/bin package.

How can I do this?

PS: MyApp project is very huge and I'd rather not want groovyc task to compile all the src files in MyApp but just pick up the additional .class file from bin and put it on its classpath.

Vamsi Emani
  • 10,072
  • 9
  • 44
  • 71

1 Answers1

3

The classpath in Java, Groovy or any other JVM language is a list of paths, each of which may be either a directory or a JAR file. You've added all the JAR files that your code depends on, but not the bin directory.

Add a pathelement as shown below to add the bin directory to your classpath. Remember that the path needs to be given relative to the location of the build script.

<path id="classpath">
   <fileset dir="lib/MyApp">
      <include name="*.jar" />
   </fileset>
   <pathelement path="bin" />
</path>

The above path definition assumes that 'bin' is in the same directory as your build script. If not, adjust the path accordingly.

Rajesh J Advani
  • 5,585
  • 2
  • 23
  • 35