Search code examples
mavenmaven-3pom.xmlmaven-pluginparent-pom

Plugin maven-antrun-plugin or one of its dependencies could not be resolved


I want to create 2 new directories in the src/main everytime during maven clean install.

Initially I was using maven-antrun-plugin to do that but the new version of maven has stopped supporting this plugin.

Below is my code in 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>

On maven clean install above code, it give build failure with following error,

[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

Not sure if there is any maven plugin that I can use to create new directories at the time of maven build. Please suggest if any.

Maven Version - 3.5.2 | Ant Version - 1.9.4


Solution

  • This will simply not work cause a version 1.9 of maven-antrun-plugin does not exist maven.apache.org/plugins

    Apart from that creating directories during the build in src is a bad idea...