Подтвердить что ты не робот

Maven Antrun не выполняет задачи

Я использую плагин Maven AntRun 1.6, и из их примера я не могу закодировать следующую задачу ant, которую нужно выполнить.

Пример URL: http://maven.apache.org/plugins/maven-antrun-plugin/examples/classpaths.html

Я просто получаю следующее сообщение, когда выполняю mvn antrun: run. Не определено ant цель - SKIPPED

Что я делаю неправильно?

Здесь мой 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>
4b9b3361

Ответ 1

Поскольку вы настроили плагин maven antrun в своем pom.xml, вам нужно только вызвать цель жизненного цикла, настроенную для плагина. В этом случае

mvn compile

Это сделает нужным.

Ответ 2

попробуйте это

<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" для выполнения чего-то другого может быть результативным.