org.eclipse.aether.artifact.ArtifactTypeRegistry Java Examples
The following examples show how to use
org.eclipse.aether.artifact.ArtifactTypeRegistry.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LinkageCheckerRule.java From cloud-opensource-java with Apache License 2.0 | 6 votes |
/** Builds a class path for {@code bomProject}. */ private ClassPathResult findBomClasspath( MavenProject bomProject, RepositorySystemSession repositorySystemSession) throws EnforcerRuleException { ArtifactTypeRegistry artifactTypeRegistry = repositorySystemSession.getArtifactTypeRegistry(); ImmutableList<Artifact> artifacts = bomProject.getDependencyManagement().getDependencies().stream() .map(dependency -> RepositoryUtils.toDependency(dependency, artifactTypeRegistry)) .map(Dependency::getArtifact) .filter(artifact -> !Bom.shouldSkipBomMember(artifact)) .collect(toImmutableList()); ClassPathResult result = classPathBuilder.resolve(artifacts); ImmutableList<UnresolvableArtifactProblem> artifactProblems = result.getArtifactProblems(); if (!artifactProblems.isEmpty()) { throw new EnforcerRuleException("Failed to collect dependency: " + artifactProblems); } return result; }
Example #2
Source File: Bom.java From cloud-opensource-java with Apache License 2.0 | 6 votes |
public static Bom readBom(Path pomFile) throws MavenRepositoryException { RepositorySystem system = RepositoryUtility.newRepositorySystem(); RepositorySystemSession session = RepositoryUtility.newSession(system); MavenProject mavenProject = RepositoryUtility.createMavenProject(pomFile, session); String coordinates = mavenProject.getGroupId() + ":" + mavenProject.getArtifactId() + ":" + mavenProject.getVersion(); DependencyManagement dependencyManagement = mavenProject.getDependencyManagement(); List<org.apache.maven.model.Dependency> dependencies = dependencyManagement.getDependencies(); ArtifactTypeRegistry registry = session.getArtifactTypeRegistry(); ImmutableList<Artifact> artifacts = dependencies.stream() .map(dependency -> RepositoryUtils.toDependency(dependency, registry)) .map(Dependency::getArtifact) .filter(artifact -> !shouldSkipBomMember(artifact)) .collect(ImmutableList.toImmutableList()); Bom bom = new Bom(coordinates, artifacts); return bom; }
Example #3
Source File: LinkageMonitor.java From cloud-opensource-java with Apache License 2.0 | 5 votes |
/** * Returns a copy of {@code bom} replacing its managed dependencies that have locally-installed * snapshot versions. */ @VisibleForTesting static Bom copyWithSnapshot( RepositorySystem repositorySystem, RepositorySystemSession session, Bom bom, Map<String, String> localArtifacts) throws ModelBuildingException, ArtifactResolutionException { ImmutableList.Builder<Artifact> managedDependencies = ImmutableList.builder(); Model model = buildModelWithSnapshotBom(repositorySystem, session, bom.getCoordinates(), localArtifacts); ArtifactTypeRegistry registry = session.getArtifactTypeRegistry(); ImmutableList<Artifact> newManagedDependencies = model.getDependencyManagement().getDependencies().stream() .map(dependency -> RepositoryUtils.toDependency(dependency, registry)) .map(Dependency::getArtifact) .collect(toImmutableList()); for (Artifact managedDependency : newManagedDependencies) { if (Bom.shouldSkipBomMember(managedDependency)) { continue; } String version = localArtifacts.getOrDefault( managedDependency.getGroupId() + ":" + managedDependency.getArtifactId(), managedDependency.getVersion()); managedDependencies.add(managedDependency.setVersion(version)); } // "-SNAPSHOT" suffix for coordinate to distinguish easily. return new Bom(bom.getCoordinates() + "-SNAPSHOT", managedDependencies.build()); }
Example #4
Source File: GenerateMetadataMojo.java From syndesis with Apache License 2.0 | 5 votes |
private Artifact toArtifact(final Dependency dependency) { final ArtifactTypeRegistry registry = session.getArtifactTypeRegistry(); final ArtifactType type = registry.get(dependency.getType()); return new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), type.getExtension(), dependency.getVersion(), type); }
Example #5
Source File: GenerateMetadataMojo.java From syndesis with Apache License 2.0 | 5 votes |
private Artifact toArtifact(final org.apache.maven.artifact.Artifact artifact) { final ArtifactTypeRegistry registry = session.getArtifactTypeRegistry(); final ArtifactType type = registry.get(artifact.getType()); return new DefaultArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), type.getExtension(), artifact.getVersion(), type); }
Example #6
Source File: RepositorySystemSessionWrapper.java From wildfly-swarm with Apache License 2.0 | 4 votes |
@Override public ArtifactTypeRegistry getArtifactTypeRegistry() { return delegate.getArtifactTypeRegistry(); }
Example #7
Source File: RepositorySystemSessionWrapper.java From thorntail with Apache License 2.0 | 4 votes |
@Override public ArtifactTypeRegistry getArtifactTypeRegistry() { return delegate.getArtifactTypeRegistry(); }
Example #8
Source File: AetherUtils.java From takari-lifecycle with Eclipse Public License 1.0 | 4 votes |
public static ArtifactTypeRegistry newArtifactTypeRegistry(ArtifactHandlerManager handlerManager) { return new MavenArtifactTypeRegistry(handlerManager); }