简体   繁体   English

可以在Maven版本插件准备中使用配置文件吗?

[英]Can use profile in maven release plugin preparationGoals?

I have a project in which I make configuration for using maven-release-plugin . 我有一个项目,在其中进行配置以使用maven-release-plugin Configration is like this: 配置是这样的:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-release-plugin</artifactId>
    <version>2.5.3</version>
    <configuration>
       <autoVersionSubmodules>true</autoVersionSubmodules>
       <useReleaseProfile>true</useReleaseProfile>
       <releaseProfiles>profile1,profile2</releaseProfiles>
       <preparationGoals>
           clean verify -Pprofile3,profile4
       </preparationGoals>
     </configuration>
</plugin>

The problem is that I am using profile in preparationGoals but I keep getting error on build. 问题是我在preparationGoals中使用了配置文件,但是在构建时一直出现错误。 The error is like this: 错误是这样的:

[INFO] [ERROR] Unknown lifecycle phase "profile4". 
You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. 
Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy.

As you can see I use version 2.5.3 of maven-release-plugin. 如您所见,我使用的是maven-release-plugin的2.5.3版本。 I used to used version 2.2.2 of maven-release-plugin and it worked just fine. 我曾经使用过2.2.2版的maven-release-plugin,它工作得很好。

With maven-release-plugin:2.5.3 when I call mvn clean verify -Pprofile3,profile4 from command line it works just fine. 使用maven-release-plugin:2.5.3时,我mvn clean verify -Pprofile3,profile4调用mvn clean verify -Pprofile3,profile4即可正常工作。

You probably need to use the arguments parameter to specify the profiles (yet I haven't tried this). 您可能需要使用arguments参数来指定配置文件(但我还没有尝试过)。 See here . 这里 If you need different profiles during the release run you might need to provide separate configuration for the different goals. 如果在发布运行期间需要不同的配置文件,则可能需要为不同的目标提供单独的配置。

From the Preparation Goals Documentation , notably " Space delimited. " Here, the term "-Pprofile3,profile4" is interpreted as yet another goal to execute. 在“ 准备目标”文档中 ,尤其是“以空格分隔”。在这里,术语“ -Pprofile3,profile4”被解释为要执行的又一个目标。 Passing custom arguments is not supported in that place. 该位置不支持传递自定义参数。 Also note that clean & verify are already run during release:prepare , so you would run them twice. 另请注意,clean&verify已在release:prepare期间运行,因此您将运行两次。

From the comments below your questions; 根据您的问题下面的评论; As you already have a plugin for your desired task(s), make that plugin run directly as a preparation goal. 由于您已经具有用于所需任务的插件,因此请将该插件直接作为准备目标来运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM