Explain Codes LogoExplain Codes Logo

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

java
maven
dependency-management
plugin-management
Nikita BarsukovbyNikita Barsukov·Feb 3, 2025
TLDR

Ensure solid network connectivity to Maven Central - it's like the main power grid for Maven! If you're behind a proxy, correctly configure your proxy settings in settings.xml. Within your pom.xml, make sure to define the maven-resources-plugin with its specific version just like you'd put batteries in a remote control:

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.5</version> </plugin>

Check your Maven version (mvn -v) and update if needed - no one likes outdated software! If still in trouble, forcefully kickstart a fresh download by clearing the plugin from the local repository (~/.m2/repository/).

Verify Maven Central accessibility

First and foremost, make sure Maven Central Repository is accessible - because you can't draw water from a well that's dry, right? Check their official website or Twitter page for downtime notifications.

Check and sync your .m2 settings

Check if your settings.xml matches between MAVEN_HOME\conf\ and USER_HOME\.m2\. Inconsistencies between those twins can bring troubles. Navigate the network of proxy configuration and repository URLs in the settings, as if you're charting a treasure map!

Refresh the local repository

Toss out unnecessary or corrupted material from your local .m2 repository, as if you're doing some good old spring cleaning! Use the following command to trigger a clean-up:

mvn dependency:purge-local-repository

Force updates with -U flag to ensure you are not missing out any updates.

mvn -U clean install

Align Eclipse with Maven

For Eclipse users, sometimes the internal Maven doesn't play well. Make it use an external one: Window > Preferences > Maven > Installations. Ensure there's enough disk space, just like ensuring there's enough room for dessert!

Manual plugin installation

In an extreme case, go for a manual rescue operation! Download the .jar and .pom, then install them manually:

mvn install:install-file -Dfile=<path-to-file> -DpomFile=<path-to-pomfile> // Because sometimes, doing it by hand is better!
Download links:
- Jar: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.5/maven-resources-plugin-2.5.jar
- Pom: http://repo1.maven.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.5/maven-resources-plugin-2.5.pom

Manage plugins via POM

Put your plugins and their versions under a management plan in your pom.xml because having a plan is always better:

<build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.5</version> </plugin> </plugins> </pluginManagement> </build>

Smoothen your Maven journey

Warding off potential pitfalls and conflicting dependencies is as vital as having the right tools in your builder's toolkit.

Battle version conflicts

Scrutinize for version conflicts like Sherlock Holmes! Release the maven-enforcer-plugin into your pom.xml to detect these conflicts.

Decode build output

Decode the console output or debug logs like deciphering hieroglyphs; they might hold the key to your issue (mvn clean install -X).

Update plugin

Sometimes, the old ways don't open new doors. Check for a more recent version of the maven-resources-plugin.