I tried to upgrade the Maven library version to 3.9.9. However, it fails with the RepositorySystem instance creation:
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.123 s <<< FAILURE! - in com.google.cloud.tools.opensource.classpath.ClassPathBuilderTest
[ERROR] testBomToPaths_firstElementsAreBomMembers(com.google.cloud.tools.opensource.classpath.ClassPathBuilderTest) Time elapsed: 0.081 s <<< ERROR!
java.lang.ExceptionInInitializerError
at com.google.cloud.tools.opensource.classpath.ClassPathBuilderTest.<init>(ClassPathBuilderTest.java:42)
Caused by: com.google.common.base.VerifyException: Couldn't retrieve RepositorySystem
at com.google.cloud.tools.opensource.classpath.ClassPathBuilderTest.<init>(ClassPathBuilderTest.java:42)
In this pull request, I added Verify.verifyNotNull(system, "Couldn't retrieve RepositorySystem"); to make the failure point clear (before this, it was failing a generic NullPointerException without a specific line number).
/**
* Creates a new system configured for file and HTTP repository resolution.
*/
public static RepositorySystem newRepositorySystem() {
DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
locator.addService(TransporterFactory.class, FileTransporterFactory.class);
locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
RepositorySystem system = locator.getService(RepositorySystem.class);
Verify.verifyNotNull(system, "Couldn't retrieve RepositorySystem");
return system;
}
Mojos are prevented to bootstrap new instance of RepositorySystem (for example by using deprecated ServiceLocator), they should reuse RepositorySystem instance provided by Maven instead. See MNG-7471.
(3.9.0 release note also includes this)
Memo:
When the problem only happens in mvn command and not in IntelliJ, having JUnit waiting for debugger is helpful: ./mvnw test -Dtest="ClassPathBuilderTest#testBomToPaths_firstElementsAreBomMembers" -Dmaven.surefire.debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I tried to upgrade the Maven library version to 3.9.9. However, it fails with the RepositorySystem instance creation:
In this pull request, I added Verify.verifyNotNull(system, "Couldn't retrieve RepositorySystem"); to make the failure point clear (before this, it was failing a generic NullPointerException without a specific line number).
/** * Creates a new system configured for file and HTTP repository resolution. */ public static RepositorySystem newRepositorySystem() { DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator(); locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class); locator.addService(TransporterFactory.class, FileTransporterFactory.class); locator.addService(TransporterFactory.class, HttpTransporterFactory.class); RepositorySystem system = locator.getService(RepositorySystem.class); Verify.verifyNotNull(system, "Couldn't retrieve RepositorySystem"); return system; }The release note (https://maven.apache.org/docs/3.9.9/release-notes.html) says:
(3.9.0 release note also includes this)
Memo:
When the problem only happens in mvn command and not in IntelliJ, having JUnit waiting for debugger is helpful: ./mvnw test -Dtest="ClassPathBuilderTest#testBomToPaths_firstElementsAreBomMembers" -Dmaven.surefire.debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005
b/416442478