How do I build only one JAR file with classifier?

醉酒当歌 提交于 2019-12-14 03:59:11

问题


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:


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>


来源:https://stackoverflow.com/questions/8354201/how-do-i-build-only-one-jar-file-with-classifier

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!