【问题标题】:change deployed artifact name based on profile根据配置文件更改部署的工件名称
【发布时间】:2011-05-10 22:35:10
【问题描述】:

我在 Web 应用程序的 pom 文件中有一个构建配置文件,它为 qa 测试做了一些必要的事情(在我的代码中)。

我在 svn 上有这段代码,这段代码是在 Hudson 中编译的,它在 nexus 中部署工件..

Hudson 有两份工作,一份负责 qa 配置文件 (-P qa),另一份负责客户。

我需要的是在部署阶段更改我的 qa 配置文件中工件的名称,以便 nexus 有两个不同的 war 文件,一个用于 qa,一个用于客户。

我使用(在 Google 搜索后)以下看起来在 hudshon 中没有任何作用!

    <profile>
        <id>qa</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.5</version>
                    <configuration>
                        <classifier>qa</classifier>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

有人有什么想法吗?

【问题讨论】:

    标签: maven profile nexus classification maven-deploy-plugin


    【解决方案1】:

    您实际上需要在构建正在部署的包的插件上设置“分类器”配置选项:maven-(ear|ejb|jar|rar|war|shade)-plugin:

    例如,要使用 qa 分类器构建 WAR,您需要执行以下操作:

    <profile>
        <id>qa</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.1.1</version>
                    <configuration>
                        <classifier>qa</classifier>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>
    

    此外,除了设置分类器,您还可以设置以下任何一项(大多数默认设置为 project.build.finalName,因此设置该属性会更新其中的许多内容):

    • 一般
      • project.build.finalName
    • 战争插件
      • 战争名称
    • Ear|Jar|Rar|Shade 插件
      • 最终名称
    • EJB 插件
      • 罐子名称

    最后一点:我以前从未意识到这一点,但是查看文档,RAR 插件似乎不支持“分类”选项。 Shade 确实支持分类器概念,但它是通过“shadedClassifierName”属性实现的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多