Maven:如何有条件地使用插件?
Maven: How to use a plug in conditionally?
我在 pom.xml 和 中定义了不同的配置文件(dev/local/qa/prod 等)我想为除名为 "local"。或者换句话说,我想为名为 "local" 的配置文件停用该插件,该插件将更改特定目录中 .sh 类型文件的权限。
我的插件是:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>script-chmod</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>sh</executable>
<arguments>
<argument>-c</argument>
<argument>chmod 744 ${SCRIPT_INSTALL_DIR}/*.sh</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
有办法吗?
在 <profiles>
部分之外配置插件并在本地配置文件中使用 exec.skip 属性:
<profile>
<id>local</id>
<properties>
<exec.skip>true</exec.skip>
</properties>
</profile>
此解决方案也有效:(注意此处 "phase" 属性下的 "none" 部分具有与为插件定义的相同执行 ID)
<profile>
<id>local</id>
<activation/>
<properties>
<INSTALL_MACHINE_LIST>....</INSTALL_MACHINE_LIST>
<COPY_MODE>auto</COPY_MODE>
<current_env>......</current_env>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>script-chmod</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
我在 pom.xml 和 中定义了不同的配置文件(dev/local/qa/prod 等)我想为除名为 "local"。或者换句话说,我想为名为 "local" 的配置文件停用该插件,该插件将更改特定目录中 .sh 类型文件的权限。
我的插件是:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>script-chmod</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>sh</executable>
<arguments>
<argument>-c</argument>
<argument>chmod 744 ${SCRIPT_INSTALL_DIR}/*.sh</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
有办法吗?
在 <profiles>
部分之外配置插件并在本地配置文件中使用 exec.skip 属性:
<profile>
<id>local</id>
<properties>
<exec.skip>true</exec.skip>
</properties>
</profile>
此解决方案也有效:(注意此处 "phase" 属性下的 "none" 部分具有与为插件定义的相同执行 ID)
<profile>
<id>local</id>
<activation/>
<properties>
<INSTALL_MACHINE_LIST>....</INSTALL_MACHINE_LIST>
<COPY_MODE>auto</COPY_MODE>
<current_env>......</current_env>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>script-chmod</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>