“exec-maven-plugin”不执行

时间:2012-02-22 17:40:08

标签: maven mule exec-maven-plugin

我有以下我成功执行的配置文件(“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>

2 个答案:

答案 0 :(得分: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>

答案 1 :(得分:1)

该插件是在另一个更大的配置文件下定义的。当我真的没有时,我以为我正在将它添加到一般构建中。我将它移出了配置文件并且工作正常。学过的知识。谢谢你的回复。

相关问题