use of com.google.cloud.tools.opensource.dependencies.NonTestDependencySelector in project cloud-opensource-java by GoogleCloudPlatform.
the class LinkageCheckerRule method findProjectClasspath.
/**
* Builds a class path for {@code mavenProject}.
*/
private static ClassPathResult findProjectClasspath(MavenProject mavenProject, RepositorySystemSession session, EnforcerRuleHelper helper) throws EnforcerRuleException {
try {
ProjectDependenciesResolver projectDependenciesResolver = helper.getComponent(ProjectDependenciesResolver.class);
DefaultRepositorySystemSession fullDependencyResolutionSession = new DefaultRepositorySystemSession(session);
// Clear artifact cache. Certain artifacts in the cache have dependencies without
// ${os.detected.classifier} interpolated. They are instantiated before 'verify' phase:
// https://github.com/GoogleCloudPlatform/cloud-opensource-java/issues/925
fullDependencyResolutionSession.setCache(new DefaultRepositoryCache());
// For netty-handler referencing its dependencies with ${os.detected.classifier}
// allowing duplicate entries
Map<String, String> properties = new HashMap<>();
properties.putAll(fullDependencyResolutionSession.getSystemProperties());
properties.putAll(OsProperties.detectOsProperties());
fullDependencyResolutionSession.setSystemProperties(properties);
fullDependencyResolutionSession.setDependencySelector(new AndDependencySelector(new NonTestDependencySelector(), new ExclusionDependencySelector(), new OptionalDependencySelector(), new FilteringZipDependencySelector()));
DependencyResolutionRequest dependencyResolutionRequest = new DefaultDependencyResolutionRequest(mavenProject, fullDependencyResolutionSession);
DependencyResolutionResult resolutionResult = projectDependenciesResolver.resolve(dependencyResolutionRequest);
return buildClassPathResult(resolutionResult);
} catch (ComponentLookupException e) {
throw new EnforcerRuleException("Unable to lookup a component " + e.getMessage(), e);
} catch (DependencyResolutionException e) {
return buildClasspathFromException(e);
}
}
Aggregations