You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by JesseLiu <je...@ecvision.com> on 2007/04/11 10:21:03 UTC

Exclude some classes when package a jar.

All,
I have a jar project.  When packaging,  I want  some specified class excuded from the jar file. How should I do ?

Thanks for any suggestions!

Re: Exclude some classes when package a jar.

Posted by John Redden <jr...@matrix-consultants.com>.
I often exclude classes by redefining their scope

as in

<scope>test</scope>  

Includes jars that I need for junit that don't end up in the war file.

hope this helps.


-John R.


On Wed, 2007-07-11 at 12:12 -0600, Tommy Knowlton wrote:
> I have a class that is a specialized implementation of a given  
> interface, and this specialized implementation cannot be distributed  
> to all customers. I wasn't able to find a way to exclude the class  
> from the jar, but I was able to exclude it from compilation, by  
> reflectively loading it if it's on the runtime classpath... thereby  
> erasing all compile-time dependence on this class.
> 
> Here's the POM excerpt:
> <project>
> 	…
>    <profiles>
>      <profile>
> 	…
> 	<build>
> 		<plugin>
>                  <artifactId>
>                      maven-compiler-plugin
>                  </artifactId>
>                  <configuration>
>                      <excludes>
>                          <exclude>**/ 
> MyDeploymentRestrictedClass.java</exclude>
>                      </excludes>
>                  </configuration>
>              </plugin>
> 	</build>
>      <profile>
>    <profiles>
> </project>
> 
> I realize it's not exactly the answer to the question you were  
> asking, but if your situation is similar (class is runtime-optional),  
> it may work for you.
> 
> HTH,
> \Tommy
> 
> On  30 Apr 2007, at 16:53 , Jerome Lacoste wrote:
> 
> > On 4/25/07, Trevor Torrez <ja...@gmail.com> wrote:
> >> How would you "post process" a jar and what phase would that process
> >> be bound to?
> >
> > using the assembly plugin during the package phase ?
> >
> > J
> >
> > ---------------------------------------------------------------------
> > 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
> 


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


Re: Exclude some classes when package a jar.

Posted by Tommy Knowlton <To...@KE4KUG.net>.
I have a class that is a specialized implementation of a given  
interface, and this specialized implementation cannot be distributed  
to all customers. I wasn't able to find a way to exclude the class  
from the jar, but I was able to exclude it from compilation, by  
reflectively loading it if it's on the runtime classpath... thereby  
erasing all compile-time dependence on this class.

Here's the POM excerpt:
<project>
	…
   <profiles>
     <profile>
	…
	<build>
		<plugin>
                 <artifactId>
                     maven-compiler-plugin
                 </artifactId>
                 <configuration>
                     <excludes>
                         <exclude>**/ 
MyDeploymentRestrictedClass.java</exclude>
                     </excludes>
                 </configuration>
             </plugin>
	</build>
     <profile>
   <profiles>
</project>

I realize it's not exactly the answer to the question you were  
asking, but if your situation is similar (class is runtime-optional),  
it may work for you.

HTH,
\Tommy

On  30 Apr 2007, at 16:53 , Jerome Lacoste wrote:

> On 4/25/07, Trevor Torrez <ja...@gmail.com> wrote:
>> How would you "post process" a jar and what phase would that process
>> be bound to?
>
> using the assembly plugin during the package phase ?
>
> J
>
> ---------------------------------------------------------------------
> 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: Exclude some classes when package a jar.

Posted by Jerome Lacoste <je...@gmail.com>.
On 4/25/07, Trevor Torrez <ja...@gmail.com> wrote:
> How would you "post process" a jar and what phase would that process
> be bound to?

using the assembly plugin during the package phase ?

J

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


Re: Exclude some classes when package a jar.

Posted by Trevor Torrez <ja...@gmail.com>.
How would you "post process" a jar and what phase would that process
be bound to?

On 4/11/07, Jerome Lacoste <je...@gmail.com> wrote:
> On 4/11/07, JesseLiu <je...@ecvision.com> wrote:
> > All,
> > I have a jar project.  When packaging,  I want  some specified class excuded from the jar file. How should I do ?
> >
> > Thanks for any suggestions!
>
> not sure if this is possible before the packaging. You can always
> post-process your jar to remove some classes,  but I wonder why you
> need that....
>
> What kind of classes do you need to remove ?
>
> Jerome
>
> ---------------------------------------------------------------------
> 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: Exclude some classes when package a jar.

Posted by Jerome Lacoste <je...@gmail.com>.
On 4/11/07, JesseLiu <je...@ecvision.com> wrote:
> All,
> I have a jar project.  When packaging,  I want  some specified class excuded from the jar file. How should I do ?
>
> Thanks for any suggestions!

not sure if this is possible before the packaging. You can always
post-process your jar to remove some classes,  but I wonder why you
need that....

What kind of classes do you need to remove ?

Jerome

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