Ant classpath and junit.jar

前端 未结 2 1285
太阳男子
太阳男子 2021-02-07 08:08

I have the an build.xml that allows me to run junit tests. Here is the relevant part:


    

        
相关标签:
2条回答
  • 2021-02-07 09:02

    You can always symlink your jar to another location if you are on linux. This way you could symlink it to a path that does not include the version. For example:

     ln -s plugins/org.junit4_4.5.0.v20090824/junit.jar /wherever/junit.jar
    

    You may want to have a libraries folder outside of the eclipse subdirectories. You could also consider using ivy or maven to manage your dependencies.

    I'm not sure why your above example fails, but the error message implies that junit.jar is not found. Are you sure that eclipse.home is set? You could echo it with:

     <echo message="${eclipse.home}">
    
    0 讨论(0)
  • 2021-02-07 09:03

    The JUnit library resides wherever you tell it to reside. Personally, I would forget entirely about linking against the jar files shipped with Eclipse and instead download the jars directly.

    If I have a project, say at path /project then I would try to put the dependency somewhere in that hierarchy, like at /project/test/lib/junit.jar. If my ant build file is then /project/build.xml then it's as simple as adding ./test/lib/junit.jar to the JUnit classpath. Trying to reference an arbitrary location on your machine is fragile (remember, Eclipse could be installed anywhere), particularly when using relative paths (since your project contents could also be stored anywhere).

    0 讨论(0)
提交回复
热议问题