无法解析插件maven-antrun-plugin或其中一个依赖项

时间:2018-04-12 07:58:14

标签: maven maven-3 pom.xml maven-plugin parent-pom

我想在maven clean install期间每次在 src / main 中创建2个新目录。

最初我使用 maven-antrun-plugin 来做到这一点,但新版本的maven已停止支持此插件。

下面是我在pom.xml中的代码

<plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-antrun-plugin</artifactId>
              <version>1.7</version>
              <executions>
                  <execution>
                      <id>staticFolder</id>
                      <phase>generate-test-resources</phase>
                      <configuration>
                          <tasks>
                            <delete dir="./src/main/resources/static"/>
                            <mkdir dir="./src/main/resources/static"/>
                          </tasks>
                      </configuration>
                      <goals>
                          <goal>run</goal>
                      </goals>
                  </execution>
                  <execution>
                      <id>templatesFolder</id>
                      <phase>generate-test-resources</phase>
                      <configuration>
                          <tasks>
                             <delete dir="./src/main/resources/templates"/>
                             <mkdir dir="./src/main/resources/templates"/>
                          </tasks>
                      </configuration>
                      <goals>
                          <goal>run</goal>
                      </goals>
                  </execution>
              </executions>
            </plugin>

在maven clean install上面的代码中,它会导致构建失败并出现以下错误,

[WARNING] The POM for org.apache.maven.plugins:maven-antrun-plugin:jar:1.9 is missing, no dependency information available
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-antrun-plugin/1.9/maven-antrun-plugin-1.9.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 17.900 s
[INFO] Finished at: 2018-04-12T13:16:26+05:30
[INFO] Final Memory: 13M/124M
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-antrun-plugin:1.9 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-antrun-plugin:jar:1.9 in central (https://repo.maven.apache.org/maven2) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException

不确定是否有任何maven插件可用于在maven构建时创建新目录。请建议是否有。

Maven版本 - 3.5.2 | Ant版本 - 1.9.4

1 个答案:

答案 0 :(得分:0)

这根本行不通,因为maven-antrun-plugin版本1.9不存在maven.apache.org/plugins

除了在src中构建期间创建目录是一个坏主意......