Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:3.1 or one of its dependencies could not be resolved.



First of all, check the maven repositiory server is up.

1. Check Proxy is set up and working
First I thought it was a proxy problem, I made sure that maven settings.xml contained the proxy settings (settings.xml can exist in two places one in MAVEN_HOME. The other in %userprofile%.m2\ with the later having higher precedence):
<proxy>
  <id>optional</id>
  <active>true</active>
  <protocol>http</protocol>
  <username>optional-proxyuser</username>
  <password>optional-proxypass</password>
  <host>proxy.host.net</host>
  <port>80</port>
  <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
and checked that the proxy is working by trying to telnet to it:
telnet [proxy] [port number]


2. Check not Eclipse Issue
ran 'mvn compile' at command line level outside of eclipse - same issue.
If 'mvn compile' worked. But it doesn't work using the maven plugin in eclipse, see Maven plugin not using eclipse's proxy settings


3. Check not Cache Issue Deleted all contents in my local maven repository. (Default location: ~/.m2/repository) And then reran maven - same issue came up.


4. What worked for me
Automatically download & install missing plugin: By declaring the missing plugin in the POM file build section for pluginManagement Maven will automatically retrieve the required plugin. In the POM file, add this code for the version of the plugin you require:
  <build>
        <pluginManagement>
          <plugins>
            <plugin>
              <artifactId>maven-resources-plugin</artifactId>
              <version>2.7</version>
            </plugin>          
          </plugins>
        </pluginManagement>  
    </build>



Manually install missing plugin: I went to https://maven.apache.org/plugins/maven-resources-plugin/download.cgi and downloaded maven/plugins/maven-resources-plugin-3.1.0-source-release.zip. Copied it directly into the maven repository into the correct folder (C:\Users\xxxxxx\.m2\repository\org\apache\maven\plugins\maven-resources-plugin\3.1.0) and re-ran 'mvn compile'. This solved the problem.


If you still face the issues, then ran the command ‘mvn install’ to update all the required maven plugins.

Comments

Popular posts from this blog

Data Bound Controls in ASP.Net - Part 4 (FormView and DetailsView controls)

ASP.net: HttpHandlers

The Clickjacking attack and X-Frame-Options