如何使用分类器仅构建一个JAR文件? [英] How do I build only one JAR file with classifier?

查看:89
本文介绍了如何使用分类器仅构建一个JAR文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Maven 2maven-jar-plugin来构建我的jar.

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

我只想生成带有classifierjar.有可能吗?

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

在我的示例中,我只想生成myjar-another-1.0.jar而不生成myjar-1.0.jar.

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

看看这个问题我试图跳过default-jar.但这似乎仅适用于Maven版本3(您还没有尝试过.

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.

父母要做

<modules>

谢谢!

这是我pom.xml的相关部分:

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>

推荐答案

只需将其用于插件元素:

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>

这篇关于如何使用分类器仅构建一个JAR文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆