maven test-resources

Discussion in 'Java' started by ilkinulas, May 16, 2008.

  1. ilkinulas

    ilkinulas Guest

    Hi,
    I am using maven2 and trying to add a directory to the test classpath.
    test-resources in the pom.xml is not appended to the test-classpath.
    Here's what maven prints when run with -X flag.

    [DEBUG] Test Classpath :
    [DEBUG] /home/ilkinulas/CVSHOME/DiameterPlatform/
    CreditControlApplication/target/classes
    [DEBUG] /home/ilkinulas/CVSHOME/DiameterPlatform/
    CreditControlApplication/target/test-classes
    [DEBUG] /home/ilkinulas/.m2/repository/org/springframework/spring-
    beans/2.0.6/spring-beans-2.0.6.jar
    [DEBUG] /home/ilkinulas/.m2/repository/aopalliance/aopalliance/1.0/
    aopalliance-1.0.jar
    [DEBUG] /home/ilkinulas/.m2/repository/org/springframework/spring-
    dao/2.0.6/spring-dao-2.0.6.jar
    [DEBUG] /home/ilkinulas/.m2/repository/junit/junit/3.8.1/
    junit-3.8.1.jar
    .....
    .....

    And in the pom.xml test resources is declared as follows:
    <build>
    <testResources>
    <testResource>
    <directory>code/testresources</directory>
    </testResource>
    </testResources>
    ......
    ......

    What else I can do to add a custom folder to the test classpath?

    thanks...

    --ilkin
     
    ilkinulas, May 16, 2008
    #1
    1. Advertisements

  2. On May 16, 6:51 am, ilkinulas <> wrote:
    > Hi,
    > I am using maven2 and trying to add a directory to the test classpath.
    > test-resources in the pom.xml is not appended to the test-classpath.
    > Here's what maven prints when run with -X flag.
    >
    > [DEBUG] Test Classpath :
    > [DEBUG]   /home/ilkinulas/CVSHOME/DiameterPlatform/
    > CreditControlApplication/target/classes
    > [DEBUG]   /home/ilkinulas/CVSHOME/DiameterPlatform/
    > CreditControlApplication/target/test-classes
    > [DEBUG]   /home/ilkinulas/.m2/repository/org/springframework/spring-
    > beans/2.0.6/spring-beans-2.0.6.jar
    > [DEBUG]   /home/ilkinulas/.m2/repository/aopalliance/aopalliance/1.0/
    > aopalliance-1.0.jar
    > [DEBUG]   /home/ilkinulas/.m2/repository/org/springframework/spring-
    > dao/2.0.6/spring-dao-2.0.6.jar
    > [DEBUG]   /home/ilkinulas/.m2/repository/junit/junit/3.8.1/
    > junit-3.8.1.jar
    > ....
    > ....
    >
    > And in the pom.xml test resources is declared as follows:
    >         <build>
    >                 <testResources>
    >                         <testResource>
    >                                 <directory>code/testresources</directory>
    >                         </testResource>
    >                 </testResources>
    >          ......
    >          ......
    >
    > What else I can do to add a custom folder to the test classpath?


    Resources are copied to the 'classes' or 'test-classes' directory as
    appropriate, not used from their original location in the source tree,
    for Java projects. If you absolutely need to add another element to
    the test classpath, maven-surefire-plugin has an option named
    additionalClasspathElements, which takes a list of path elements to
    add to the classpath:

    <plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
    <additionalClasspathElements>
    <element>code/testresources</element>
    </additionalClasspathElements>
    </configuration>
    </plugin>

    However, before you do this, you should really consider working with,
    rather than across, maven's defaults and store your test resources in
    src/test/resources, and let maven-resources-plugin copy them to target/
    test-classes during the build.

    -o
     
    Owen Jacobson, May 16, 2008
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sherman Haywood Cox II

    Maven and ejbc

    Sherman Haywood Cox II, Jul 25, 2003, in forum: Java
    Replies:
    0
    Views:
    544
    Sherman Haywood Cox II
    Jul 25, 2003
  2. steven

    maven and xdoclet

    steven, Nov 12, 2003, in forum: Java
    Replies:
    1
    Views:
    495
    Bryce (Work)
    Nov 12, 2003
  3. Marko Velic

    XP %HOME% and Maven

    Marko Velic, Jun 10, 2004, in forum: Java
    Replies:
    0
    Views:
    472
    Marko Velic
    Jun 10, 2004
  4. Marcin Cenkier
    Replies:
    1
    Views:
    5,865
    Marcin Cenkier
    Apr 12, 2006
  5. Russell E. Owen
    Replies:
    0
    Views:
    847
    Russell E. Owen
    Sep 8, 2006
  6. cyber Boy

    Maven test

    cyber Boy, Nov 7, 2008, in forum: Java
    Replies:
    3
    Views:
    819
  7. Skybuck Flying

    Call oddities: &Test() vs &Test vs Test

    Skybuck Flying, Oct 4, 2009, in forum: C Programming
    Replies:
    1
    Views:
    1,030
    Skybuck Flying
    Oct 4, 2009
  8. manos
    Replies:
    0
    Views:
    376
    manos
    Oct 6, 2007
Loading...