10

私は Maven AntRun プラグイン 1.6 を使用していますが、その例から、実行する次の ant タスクをコーディングできません。

URL の例: http://maven.apache.org/plugins/maven-antrun-plugin/examples/classpaths.html

mvn antrun:run を実行すると、次のメッセージが表示されます。Ant ターゲットが定義されていません - スキップされました

私は何を間違っていますか?

これが私のPOMです:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.6</version>
            <executions>
                <execution>
                    <id>compile</id>
                    <phase>compile</phase>
                    <configuration>
                        <target>
                            <property name="compile_classpath" refid="maven.compile.classpath" />
                            <property name="runtime_classpath" refid="maven.runtime.classpath" />
                            <property name="test_classpath" refid="maven.test.classpath" />
                            <property name="plugin_classpath" refid="maven.plugin.classpath" />

                            <echo message="compile classpath: ${compile_classpath}" />
                            <echo message="runtime classpath: ${runtime_classpath}" />
                            <echo message="test classpath:    ${test_classpath}" />
                            <echo message="plugin classpath:  ${plugin_classpath}" />
                        </target>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
4

2 に答える 2

25

これを試して

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution>
                    <id>default-cli</id>
                    <configuration>
                        <target>
                            <property name="compile_classpath" refid="maven.compile.classpath" />
                            <property name="runtime_classpath" refid="maven.runtime.classpath" />
                            <property name="test_classpath" refid="maven.test.classpath" />
                            <property name="plugin_classpath" refid="maven.plugin.classpath" />

                            <echo message="compile classpath: ${compile_classpath}" />
                            <echo message="runtime classpath: ${runtime_classpath}" />
                            <echo message="test classpath:    ${test_classpath}" />
                            <echo message="plugin classpath:  ${plugin_classpath}" />
                        </target>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

IDに注意してください

<id>default-cli</id>

コマンドを実行します

mvn antrun:run

このようにする理由: 実際に「コンパイル」したくない場合は、「mvn compile」を実行して他の何かを実行すると、逆効果になる可能性があります。

于 2012-06-13T07:11:18.760 に答える
7

でmavenantrunプラグインをpom.xml構成したので、プラグイン用に構成されたライフサイクル目標を呼び出すだけで済みます。この場合

mvn compile

これは必要なことをします。

于 2011-06-08T02:17:25.097 に答える