Having tried this, I now see two problems.

First, the step that packages the jars reports this:
     [INFO] Building jar:
D:\svn-source\trunk\myproject\target\myproject-[version].jar
     [INFO] [jar:test-jar {execution: default}]
     [WARNING] JAR will be empty - no content was marked for inclusion!
     [INFO] Building jar:
D:\svn-source\trunk\myproject\target\myproject-[version]-tests.jar

where do you specify what should be included in the test jar?

Second, my company's official Maven build doesn't install the results.  At
the top level, we run "mvn clean package" instead of "mvn clean install". 
Can I hope to have the test jar automatically installed to the repository
immediately after building it so that  it can be found when the dependent
project looks for it?  I'm getting this error:

     [INFO] [resources:testResources]
     [INFO] Using default encoding to copy filtered resources.
     Downloading:
http://repo1.maven.org/maven2/com/mycompany/myproject/[version]/myproject-[version]-tests.jar
     [WARNING] Unable to get resource from repository central
(http://repo1.maven.org/maven2)
     [INFO]
------------------------------------------------------------------------
     [ERROR] BUILD ERROR
     [INFO]
------------------------------------------------------------------------
     [INFO] Failed to resolve artifact.

Thanks for getting me this far, and for any further assistance!


Ronn.Chinowutthichai wrote:
> 
> Yes the helper classes (in src/test/java) needs to be packaged and 
> installed to the repository so that another maven project can reference. 
> By default, maven-jar-plugin doesn't jar up class in src/test/java. By 
> default, all of the classes in src/test/java as well as src/test/resources 
> will be included in the jar. I don't see why it would matter if your unit 
> tests are jarred up as well.
> 
> The scope element tells that the dependencies are only for testing phase. 
> The type element tells it to look for test jar of the helper artifact 
> (rather than the helper jar itself).
> 
> When you are ready to run the project, go to your root pom and do a clean 
> install (this will make sure that your test jar is deployed to your local 
> repository)
> 
> Cheers,
> rOnn c.
> 
> 
> 
> 
> 
> 
> 
> jsweeney67 <[EMAIL PROTECTED]> 
> 11/15/2007 12:55 PM
> Please respond to
> "Maven Users List" <[email protected]>
> 
> 
> To
> [email protected]
> cc
> 
> Subject
> Re: JUnit and Maven - compiling helper classes
> 
> 
> 
> 
> 
> 
> 
> So, if I understand correctly, the helper classes need to be in a jar. 
> These
> classes now live in the same packages as the JUnit tests so should the jar
> exclude the actual test classes?
> 
> I then presume that the "scope" tag tells Maven to only look for the new 
> jar
> if tests are being run, correct?
> 
> Thanks!  I appreciate the response.
> 
> 
> Ronn.Chinowutthichai wrote:
>> 
>> You need to create a test-jar artifact out of your helper classes
>> 
>> Put this in the pom of your helper classes
>> 
>>             <plugin>
>>                 <groupId>org.apache.maven.plugins</groupId>
>>                 <artifactId>maven-jar-plugin</artifactId>
>>                 <executions>
>>                     <execution>
>>                         <goals>
>>                             <goal>test-jar</goal>
>>                         </goals>
>>                     </execution>
>>                 </executions>
>>             </plugin>
>> 
>> This will create a test-jar.
>> 
>> Then in the project that you depend on these helper classes in test 
>> packages, declare a dependency to it with a type tag.
>> 
>> i.e.,
>>         <dependency>
>>             <groupId>your group id</groupId>
>>             <artifactId>helper project</artifactId>
>>             <version>version</version>
>>             <type>test-jar</type>
>>             <scope>test</scope>
>>         </dependency>
>> 
>> Cheers,
>> rOnn c.
>> 
> 
> -- 
> View this message in context: 
> http://www.nabble.com/JUnit-and-Maven---compiling-helper-classes-tf4808900s177.html#a13760218
> 
> Sent from the Maven - Users mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> ######################################################################
> DISCLAIMER:
> This email and any attachment may contain confidential information.
> If you are not the intended recipient you are not authorized to copy
> or disclose all or any part of it without the prior written consent
> of Toyota.
> 
> Opinions expressed in this email and any attachments are those of the
> sender and not necessarily the opinions of Toyota.
> Please scan this email and any attachment(s) for viruses.
> Toyota does not accept any responsibility for problems caused by
> viruses, whether it is Toyota's fault or not.
> ######################################################################
> 
> 

-- 
View this message in context: 
http://www.nabble.com/JUnit-and-Maven---compiling-helper-classes-tf4808900s177.html#a14143321
Sent from the Maven - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to