3

I'm using Maven 2 and maven-jar-plugin to build my jar.

I'd like to generate only a jar with a classifier. Is it possible?

In my example I'd like to generate only the myjar-another-1.0.jar but not myjar-1.0.jar.

After take a look at this question I tried to skip the default-jar. But this seems to work only with version 3 of Maven (haven't tried thou.

The parent is to do the

<modules>

Thanks all!

Here is the relevant piece of my pom.xml:

Also tried in the global configuration segment.

<project>
         <!-- Definition of the Parent (only an aggregator) -->     
    <build>
      <plugins>
         <!-- <artifactId>maven-bundle-plugin</artifactId> -->
         <!-- surefire -->
         <!-- <artifactId>maven-source-plugin</artifactId> -->
         <plugin>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.3.2</version>
            <configuration>
                <classifier>another</classifier>
            </configuration>
            <executions>
                <execution>
                    <id>test-jar</id>
                    <goals>
                        <goal>test-jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
     </plugins>
   </build>
Community
  • 1
  • 1
ssedano
  • 8,322
  • 9
  • 60
  • 98

1 Answers1

6

Just use it for the plugin element:

  <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <classifier>another</classifier>
        </configuration>
      </plugin>
  </plugins>
kan
  • 28,279
  • 7
  • 71
  • 101
  • Works for me. Not working how? Maybe I don't understand the question? – kan Dec 02 '11 at 10:39
  • 1
    In my example I'd like to generate only the `myjar-another-1.0.jar` but not `myjar-1.0.jar`. What version? – ssedano Dec 02 '11 at 10:47
  • I'm using maven v2.2.1. I've added the plugin as in my answer into one of my projects and it's produced for me only myproj-0.0.1-another.jar What are you getting? – kan Dec 02 '11 at 10:51
  • I'm also getting the myjar-1.0.jar. It is possible to avoid it. @kan Thank you for your time! – ssedano Dec 02 '11 at 10:54
  • I'm not getting it, only the classified jar is generated. Maybe your pom has some other options, maybe it's influenced by something else. Publish here a minimal example which doesn't work for you. – kan Dec 02 '11 at 10:58