How do I build only one JAR file with classifier?

2019-08-01 03:14发布

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>

1条回答
We Are One
2楼-- · 2019-08-01 03:33

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>
查看更多
登录 后发表回答