Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2008

Tip: Looking for answers? Try searching our database.

maven test-resources

Thread view: 
ilkinulas - 16 May 2008 11:51 GMT
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
Owen Jacobson - 16 May 2008 17:31 GMT
> Hi,
> I am using maven2 and trying to add a directory to the test classpath.
[quoted text clipped - 28 lines]
>
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.