[ 
https://issues.apache.org/jira/browse/MJAR-224?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15305557#comment-15305557
 ] 

Karl Heinz Marbaise commented on MJAR-224:
------------------------------------------

The following will define the configuration for all goals and executions:
{code:xml}
<plugin>
  <groupId>..</groupId>
  <artifactId>maven-jar-plugin</artifactId>
  <configuration>
    <excludes>
      <exclude>xyz/a/b/**</exclude>
    </excludes>
  </configuration>
</plugin>
{code}

If you like to limit exclusions for a particular execution/goal you need to go 
via this:

The following example will change the configuration for the {{default-jar}} 
which is done for the default life cycle binding (This one should be done via 
{{pluginManagement}} instead in general for specific purposes like this:
{code:xml}
<plugin>
  <groupId>..</groupId>
  <artifactId>maven-jar-plugin</artifactId>
  <executions>
    <execution>
      <id>default-jar</id>
      <configuration>
        <excludes>
          <exclude>xyz/a/b/**</exclude>
        </excludes>
      </configuration>
    <execution>
  </exectuions>
</plugin>
{code}

If you ilke to limit excludes for the primary artifact only you need to go via 
this:

{code:xml}
<plugin>
  <groupId>..</groupId>
  <artifactId>maven-jar-plugin</artifactId>
  <executions>
    <execution>
      <id>default-jar</id>
      <goals>
        <goal>jar</goal>
      <goals>
      <configuration>
        <excludes>
          <exclude>xyz/a/b/**</exclude>
        </excludes>
      </configuration>
    <execution>
  </exectuions>
</plugin>
{code}
But usually there is a smell in your build if you need such things. Usually you 
should separate those packages into a separate module than you don't need any 
excludes which makes configuration more simpler and follows conventions over 
configuration paradigm.

> Not possible to exclude classes from primary jar only
> -----------------------------------------------------
>
>                 Key: MJAR-224
>                 URL: https://issues.apache.org/jira/browse/MJAR-224
>             Project: Maven JAR Plugin
>          Issue Type: Bug
>            Reporter: Sebb
>
> The <excludes> config item can be used to exclude classes from a jar.
> However, if this is done for the main jar, the exclusion also applies to any 
> other jars created with a different classifier.
> It does not appear to be possible to exclude a class from the main jar and 
> include it in any others.
> This forces the use of other solutions such a the Maven Antrun Plugin



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to