Issue
I added the plugin like so:
<maven.surefire.version>3.0.0-M5</maven.surefire.version>
[...]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<parallel>methods</parallel>
<useUnlimitedThreads>true</useUnlimitedThreads>
</configuration>
</plugin>
… and all went well.
I changed the version to 2.22.2 and got the error: Plugin 'org.apache.maven.plugins:maven-surefire-plugin:2.22.2' not found
.
However, when I do an artifact search from within IntelliJ, it does find that version. Okay, I revert the change back to the original version I had.
Now, when I ran mvn test
the following caught my eye:
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ regression-tests ---
Why isn't 3.0.0-M5 used? Where does 2.12.4 come from? I did a search in my pom.xml on 'surefire', but no other hits appear other than what I've shown above.
Looking through IntelliJ's Preferences, I've found the repo that's being used is https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-surefire-plugin/, and all versions mentioned are there.
Could someone explain to me what is going on? Why can't it find 2.22.2? Why does it show 2.12.4 is used while 3.0.0-M5 is in pom.xml?
For completeness' sake, here's my mvn:
❯ mvn --version
Apache Maven 3.8.2 (ea98e05a04480131370aa0c110b8c54cf726c06f)
Maven home: /opt/homebrew/Cellar/maven/3.8.2/libexec
Java version: 1.8.0_292, vendor: Azul Systems, Inc., runtime: /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "11.5.2", arch: "aarch64", family: "mac"
Solution
Okay, I revert the change back to the original version I had.
Invoke Reload action in Maven tool window after you change the pom.xml file.
You can see the plugin version which is used in Maven tool window:
You can also use Show Effective POM action in IDE to see all the actual dependencies, plugins and their versions which are used in this Maven project:
Answered By - Andrey