You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Chris <sh...@yahoo.com> on 2008/03/11 20:30:21 UTC

How to exclude all test classes from jar?

I'd like to exclude all classes in the /test directory from the target 
jar file. The following does NOT work:

       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-jar-plugin</artifactId>
         <configuration>
           <excludes>
             <exclude>**/Test*.java</exclude>
           </excludes>
         </configuration>
       </plugin>

... because not all the classes in /test start with Test*. Basically, 
only the classes in the /target/classes should be included, and none of 
those in /target/test-classes.

How do I do it?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


RE: How to exclude all test classes from jar?

Posted by "Brian E. Fox" <br...@reply.infinity.nu>.
/target/test-classes are not included in the jar by default.

-----Original Message-----
From: news [mailto:news@ger.gmane.org] On Behalf Of Chris
Sent: Tuesday, March 11, 2008 3:30 PM
To: users@maven.apache.org
Subject: How to exclude all test classes from jar?

I'd like to exclude all classes in the /test directory from the target 
jar file. The following does NOT work:

       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-jar-plugin</artifactId>
         <configuration>
           <excludes>
             <exclude>**/Test*.java</exclude>
           </excludes>
         </configuration>
       </plugin>

... because not all the classes in /test start with Test*. Basically, 
only the classes in the /target/classes should be included, and none of 
those in /target/test-classes.

How do I do it?


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to exclude all test classes from jar?

Posted by Chris <sh...@yahoo.com>.
I see the problem. Eclipse was mistakenly putting all of my test classes 
into /target/classes instead of /target/test-classes. Must fix the 
Eclipse project.


Russ Tremain wrote:
> not quite sure I understand, are you saying you have test files
> in your <build><sourceDirectory> that you want to exclude?
> 
> if so, then the convention is to exclude them in the <build><resources>.. section.
> 
> classes in <build><testSourceDirectory> are by default excluded from the final jar.
> 
> At 2:30 PM -0500 3/11/08, Chris wrote:
>> I'd like to exclude all classes in the /test directory from the target jar file. The following does NOT work:
>>
>>      <plugin>
>>        <groupId>org.apache.maven.plugins</groupId>
>>        <artifactId>maven-jar-plugin</artifactId>
>>        <configuration>
>>          <excludes>
>>            <exclude>**/Test*.java</exclude>
>>          </excludes>
>>        </configuration>
>>      </plugin>
>>
>> ... because not all the classes in /test start with Test*. Basically, only the classes in the /target/classes should be included, and none of those in /target/test-classes.
>>
>> How do I do it?
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to exclude all test classes from jar?

Posted by Russ Tremain <Ru...@Sun.COM>.
not quite sure I understand, are you saying you have test files
in your <build><sourceDirectory> that you want to exclude?

if so, then the convention is to exclude them in the <build><resources>.. section.

classes in <build><testSourceDirectory> are by default excluded from the final jar.

At 2:30 PM -0500 3/11/08, Chris wrote:
>I'd like to exclude all classes in the /test directory from the target jar file. The following does NOT work:
>
>      <plugin>
>        <groupId>org.apache.maven.plugins</groupId>
>        <artifactId>maven-jar-plugin</artifactId>
>        <configuration>
>          <excludes>
>            <exclude>**/Test*.java</exclude>
>          </excludes>
>        </configuration>
>      </plugin>
>
>... because not all the classes in /test start with Test*. Basically, only the classes in the /target/classes should be included, and none of those in /target/test-classes.
>
>How do I do it?
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>For additional commands, e-mail: users-help@maven.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org