2

我有以下我正在成功执行的配置文件(“mvn exec:exec -DrunMule”):

    <profile>
        <id>runMule</id>
        <activation>
            <property>
                <name>runMule</name>
            </property>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <version>1.2.1</version>
                    <configuration>
                        <executable>java</executable>
                        <arguments>
                            <argument>-classpath</argument>
                            <!-- automatically creates the classpath using all project dependencies, also adding the project build directory -->
                            <classpath/>
                            <argument>org.mule.MuleServer</argument>
                            <argument>-config</argument>
                            <argument>mule-config.xml</argument>
                        </arguments>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    </profile>

在同一 pom.xml 中执行 Maven 构建时,我试图将其转换为在特定阶段运行:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <version>1.2.1</version>
    <executions>
        <execution>
            <phase>validate</phase>
            <goals>
                <goal>java</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <mainClass>org.mule.MuleServer</mainClass>
        <arguments>
            <argument>-classpath</argument>
            <classpath/>
            <argument>-config</argument>
            <argument>mule-config.xml</argument>
        </arguments>
    </configuration>

当我执行“mvn clean install”时,这个新插件不会执行。我不清楚为什么它不会。

- - - - - - - 更新 - - - - - - -

曾经的建议是将配置放入执行中。这是我尝试过的,但仍然没有执行。

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <executions>
        <execution>
            <phase>validate</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>java</executable>
                <arguments>
                    <argument>-classpath</argument>
                    <classpath/>
                    <argument>org.mule.MuleServer</argument>
                    <argument>-config</argument>
                    <argument>mule-config.xml</argument>
                </arguments>
            </configuration>
        </execution>
    </executions>
</plugin>
4

2 回答 2

2

“配置”应在“执行”下:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <executions>
      <execution>
        <phase>validate</phase>
        <goals>
          <goal>exec</goal>
        </goals>
        <configuration>
           <executable>echo</executable>
           <arguments>
              <argument>"test"</argument>
           </arguments>
        </configuration>
      </execution>
    </executions>
  </plugin>
于 2012-02-22T18:02:47.857 回答
1

该插件是在另一个更大的配置文件下定义的。我以为我正在将它添加到一般构建中,而实际上我并没有。我把它从个人资料中移出,它起作用了。学过的知识。感谢您的回复。

于 2012-02-23T22:08:39.363 回答