• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

[Ant] Classpath issues building from multiple source trees

 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm an Ant neophyte trying to loosen the chains of the IDE builds that have been thrust upon me. Unfortunately, I'm having some issues and I was wondering if someone might be able to point out the error of my ways. I'm trying to compile some unit tests which are kept in the same package but a different location from the classes under test. When I try to compile the test classes, Ant complains that it can't find the class under test. So it would seem to be a classpath problem somewhere. In fact, I'm sure it's probably glaringly obvious but I've been staring at it for awhile and I just must be missing it. Maybe I need some more caffeine. Here's what part of my directory structure looks like:



Let's say I'm building off of the share source tree... The related .java files would be in src/share and they would be compiled to build/share. My unit test source for classes in the share source tree would be in test/share. Here's the relevant parts of my build script and the properties that are imported into it.

First, here are the relevant properties imported from a property file:

root=.
src.root=${root}/src
share.src=${src.root}/share
test.root=${root}/test
share.test=${test.root}/share
build.root=${root}/build
share.build=${build.root}/share
lib.home=./lib
commons-beanutils.jar=${lib.home}/commons-beanutils.jar
junit.jar=${lib.home}/junit.jar



Running the view-classpath target produces the following output, which should be my classpath that compile-tests is using:

[echo] CLASSPATH::: C:\jasonm\prog\projectTemplate\lib\commons-beanutils.jar;
C:\jasonm\prog\projectTemplate\lib\junit.jar;
C:\jasonm\prog\projectTemplate\build\share


Currently I have one class, projecttemplate.StringBean that is being used by my test projecttemplate.TestStringBean. StringBean is compiling fine and I can see StringBean.class in build/share/projecttemplate as expected. The problem comes when running the compile-tests target:



If anyone can point out where I'm screwing up I'd really appreciate it!
[ March 11, 2005: Message edited by: Jason Menard ]
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If anyone is curious, here are the two classes in question. They're just test classes and they're not really supposed to do anything, just in case anyone is wondering.

StringBean.java


TestStringBean.java
 
town drunk
( and author)
Posts: 4118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jason,

Put commons-beanutils.jar and junit.jar in the same directory as your build, and the Try the following:



[ March 11, 2005: Message edited by: Max Habibi ]
[ March 11, 2005: Message edited by: Max Habibi ]
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.

Those are actually properties I have defined in a build.properties file which I neglected to mention.

lib.home=./lib
commons-beanutils.jar=${lib.home}/commons-beanutils.jar
junit.jar=${lib.home}/junit.jar

I should have pointed that out the first time, because otherwise it certainly does look like it might be an error. I'll go back and edit the original message to add those.

If I remove the references to StringBean in my TestStringBean class, it compiles fine.
[ March 11, 2005: Message edited by: Jason Menard ]
 
Max Habibi
town drunk
( and author)
Posts: 4118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hmm...I created the directory as described, and it did compile for me. Try taking a look here
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help. You helped me narrow it down to a JBuilder issue. I told it to not use the Borland compiler and that seemed to do the trick. Thanks again.
 
Willie Smits increased rainfall 25% in three years by planting trees. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic