36 articles and counting
      

Maven ‘artifact could not be retrieved from repository

How many times have I seen this – ‘artifact org.apache.maven.plugins:maven-resources-plugin’ could not be retrieved from repository’ blah blah blah. I usually resolve this by re-running the commands over and over until the artifact does get resolved. Today though I thought enough was enough.

After a little digging about I discover that the plugins attached to lifecycle phases (eg. compile) are downloaded and stored automatically when they are needed. So calling ‘mvn compile’ means that all plugins attached to the compile phase, and the phases that come after it in the lifecycle (generate-sources, process-resources etc), are downloaded and executed and stored.

The plugins that you call from the command line (eg. mvn install) are downloaded and stored in the repository only when you call them from the command line. This is the case even if they are configured in your pom.xml.

You can try and force Maven to download the dependencies that it needs with the command “mvn dependency:go-offline” (see http://maven.apache.org/plugins/maven-dependency-plugin/).

For more information regarding the Maven life-cycle see http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html

plugins attached to lifecycle phases (generate-sources, compile, etc.) or plugins that you call from the command line (eg. mvn tomcat:deploy)?
The plugins attached to lifecycle phases should be downloaded and stored automatically, exactly at the moment they are needed. For example, if you call “mvn compile” from the command line, it was download, then execute all plugins attached to “validate”, then those attached to “generate-sources”, then “process-sources”, “generate-resources”, “process-resources” and “compile”. But not those attached to “test”, since this phase is later in the lifecycle (see