Search in sources :

Example 1 with NoLocalRepositoryManagerException

use of org.eclipse.aether.repository.NoLocalRepositoryManagerException in project spring-cloud-function by spring-cloud.

the class DependencyResolutionModule method dependencies.

public List<Dependency> dependencies(final Resource resource, final Properties properties) {
    initialize();
    try {
        ProjectBuildingRequest request = getProjectBuildingRequest(properties);
        request.setResolveDependencies(true);
        synchronized (DependencyResolver.class) {
            ProjectBuildingResult result = projectBuilder.build(new PropertiesModelSource(properties, resource), request);
            DependencyResolver.globals = null;
            DependencyResolutionResult dependencies = result.getDependencyResolutionResult();
            if (!dependencies.getUnresolvedDependencies().isEmpty()) {
                StringBuilder builder = new StringBuilder();
                for (Dependency dependency : dependencies.getUnresolvedDependencies()) {
                    List<Exception> errors = dependencies.getResolutionErrors(dependency);
                    for (Exception exception : errors) {
                        if (builder.length() > 0) {
                            builder.append("\n");
                        }
                        builder.append(exception.getMessage());
                    }
                }
                throw new RuntimeException(builder.toString());
            }
            return runtime(dependencies.getDependencies());
        }
    } catch (ProjectBuildingException | NoLocalRepositoryManagerException e) {
        throw new IllegalStateException("Cannot build model", e);
    }
}
Also used : ProjectBuildingException(org.apache.maven.project.ProjectBuildingException) DependencyResolutionResult(org.apache.maven.project.DependencyResolutionResult) Dependency(org.eclipse.aether.graph.Dependency) ProjectBuildingException(org.apache.maven.project.ProjectBuildingException) NoLocalRepositoryManagerException(org.eclipse.aether.repository.NoLocalRepositoryManagerException) IOException(java.io.IOException) DefaultProjectBuildingRequest(org.apache.maven.project.DefaultProjectBuildingRequest) ProjectBuildingRequest(org.apache.maven.project.ProjectBuildingRequest) ProjectBuildingResult(org.apache.maven.project.ProjectBuildingResult) NoLocalRepositoryManagerException(org.eclipse.aether.repository.NoLocalRepositoryManagerException)

Aggregations

IOException (java.io.IOException)1 DefaultProjectBuildingRequest (org.apache.maven.project.DefaultProjectBuildingRequest)1 DependencyResolutionResult (org.apache.maven.project.DependencyResolutionResult)1 ProjectBuildingException (org.apache.maven.project.ProjectBuildingException)1 ProjectBuildingRequest (org.apache.maven.project.ProjectBuildingRequest)1 ProjectBuildingResult (org.apache.maven.project.ProjectBuildingResult)1 Dependency (org.eclipse.aether.graph.Dependency)1 NoLocalRepositoryManagerException (org.eclipse.aether.repository.NoLocalRepositoryManagerException)1