public static Collection<Artifact> toArtifacts( Collection<org.apache.maven.artifact.Artifact> artifactsToConvert ) { List<Artifact> artifacts = new ArrayList<>(); for ( org.apache.maven.artifact.Artifact a : artifactsToConvert ) { artifacts.add( toArtifact( a ) ); } return artifacts; }
public static void toArtifacts( Collection<org.apache.maven.artifact.Artifact> artifacts, Collection<? extends DependencyNode> nodes, List<String> trail, DependencyFilter filter ) { for ( DependencyNode node : nodes ) { org.apache.maven.artifact.Artifact artifact = toArtifact( node.getDependency() ); List<String> nodeTrail = new ArrayList<>( trail.size() + 1 ); nodeTrail.addAll( trail ); nodeTrail.add( artifact.getId() ); if ( filter == null || filter.accept( node, Collections.<DependencyNode>emptyList() ) ) { artifact.setDependencyTrail( nodeTrail ); artifacts.add( artifact ); } toArtifacts( artifacts, node.getChildren(), nodeTrail, filter ); } }
public String getPathForRemoteArtifact( Artifact artifact, RemoteRepository repository, String context ) { return delegate.pathOf( RepositoryUtils.toArtifact( artifact ) ); }
/** * Tries to resolve the specified artifact from the artifacts of the given project. * * @param project The project to try to resolve the artifact from, must not be <code>null</code>. * @param requestedArtifact The artifact to resolve, must not be <code>null</code>. * @return The matching artifact from the project or <code>null</code> if not found. Note that this */ private Artifact findMatchingArtifact( MavenProject project, Artifact requestedArtifact ) { String requestedRepositoryConflictId = ArtifactIdUtils.toVersionlessId( requestedArtifact ); Artifact mainArtifact = RepositoryUtils.toArtifact( project.getArtifact() ); if ( requestedRepositoryConflictId.equals( ArtifactIdUtils.toVersionlessId( mainArtifact ) ) ) { return mainArtifact; } for ( Artifact attachedArtifact : RepositoryUtils.toArtifacts( project.getAttachedArtifacts() ) ) { if ( attachedArtifactComparison( requestedArtifact, attachedArtifact ) ) { return attachedArtifact; } } return null; }
public String getPathForLocalArtifact( Artifact artifact ) { if ( realLocalRepo ) { return delegate.pathOf( RepositoryUtils.toArtifact( artifact.setVersion( artifact.getBaseVersion() ) ) ); } return delegate.pathOf( RepositoryUtils.toArtifact( artifact ) ); }
String path = lrm.getPathForLocalArtifact( RepositoryUtils.toArtifact( artifact ) ); artifact.setFile( new File( lrm.getRepository().getBasedir(), path ) );
public static Dependency toDependency( org.apache.maven.artifact.Artifact artifact, Collection<org.apache.maven.model.Exclusion> exclusions ) { if ( artifact == null ) { return null; } Artifact result = toArtifact( artifact ); List<Exclusion> excl = null; if ( exclusions != null ) { excl = new ArrayList<>( exclusions.size() ); for ( org.apache.maven.model.Exclusion exclusion : exclusions ) { excl.add( toExclusion( exclusion ) ); } } return new Dependency( result, artifact.getScope(), artifact.isOptional(), excl ); }
private static org.apache.maven.artifact.Artifact toArtifact( Dependency dependency ) { if ( dependency == null ) { return null; } org.apache.maven.artifact.Artifact result = toArtifact( dependency.getArtifact() ); result.setScope( dependency.getScope() ); result.setOptional( dependency.isOptional() ); return result; }
public synchronized PluginDescriptor getPluginDescriptor( Plugin plugin, List<RemoteRepository> repositories, RepositorySystemSession session ) throws PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException { PluginDescriptorCache.Key cacheKey = pluginDescriptorCache.createKey( plugin, repositories, session ); PluginDescriptor pluginDescriptor = pluginDescriptorCache.get( cacheKey ); if ( pluginDescriptor == null ) { org.eclipse.aether.artifact.Artifact artifact = pluginDependenciesResolver.resolve( plugin, repositories, session ); Artifact pluginArtifact = RepositoryUtils.toArtifact( artifact ); pluginDescriptor = extractPluginDescriptor( pluginArtifact, plugin ); pluginDescriptor.setRequiredMavenVersion( artifact.getProperty( "requiredMavenVersion", null ) ); pluginDescriptorCache.put( cacheKey, pluginDescriptor ); } pluginDescriptor.setPlugin( plugin ); return pluginDescriptor; }
org.eclipse.aether.artifact.Artifact mainArtifact = RepositoryUtils.toArtifact( artifact ); mainArtifact = mainArtifact.setFile( source ); request.addArtifact( mainArtifact );
artifactRequest.setArtifact( RepositoryUtils.toArtifact( artifact ) ); artifactRequest.setRepositories( RepositoryUtils.toRepos( remoteRepositories ) );
private void createPluginRealm( PluginDescriptor pluginDescriptor, MavenSession session, ClassLoader parent, Map<String, ClassLoader> foreignImports, DependencyFilter filter ) throws PluginResolutionException, PluginContainerException { Plugin plugin = Objects.requireNonNull( pluginDescriptor.getPlugin(), "pluginDescriptor.plugin cannot be null" ); Artifact pluginArtifact = Objects.requireNonNull( pluginDescriptor.getPluginArtifact(), "pluginDescriptor.pluginArtifact cannot be null" ); MavenProject project = session.getCurrentProject(); final ClassRealm pluginRealm; final List<Artifact> pluginArtifacts; RepositorySystemSession repositorySession = session.getRepositorySession(); DependencyFilter dependencyFilter = project.getExtensionDependencyFilter(); dependencyFilter = AndDependencyFilter.newInstance( dependencyFilter, filter ); DependencyNode root = pluginDependenciesResolver.resolve( plugin, RepositoryUtils.toArtifact( pluginArtifact ), dependencyFilter, project.getRemotePluginRepositories(), repositorySession ); PreorderNodeListGenerator nlg = new PreorderNodeListGenerator(); root.accept( nlg ); pluginArtifacts = toMavenArtifacts( root, nlg ); pluginRealm = classRealmManager.createPluginRealm( plugin, parent, null, foreignImports, toAetherArtifacts( pluginArtifacts ) ); discoverPluginComponents( pluginRealm, plugin, pluginDescriptor ); pluginDescriptor.setClassRealm( pluginRealm ); pluginDescriptor.setArtifacts( pluginArtifacts ); }
throws ProjectBuildingException org.eclipse.aether.artifact.Artifact pomArtifact = RepositoryUtils.toArtifact( artifact ); pomArtifact = ArtifactDescriptorUtils.toPomArtifact( pomArtifact );
collect.setRootArtifact( RepositoryUtils.toArtifact( project.getArtifact() ) ); collect.setRequestContext( "project" ); collect.setRepositories( project.getRemoteProjectRepositories() );
org.eclipse.aether.artifact.Artifact mainArtifact = RepositoryUtils.toArtifact( artifact ); mainArtifact = mainArtifact.setFile( source ); request.addArtifact( mainArtifact );
private void addProjectArtifact(Properties props) { Artifact projectArtifact = this.project.getArtifact(); if (projectArtifact.getFile() != null && projectArtifact.getFile().isFile()) { props.setProperty(RepositoryUtils.toArtifact(projectArtifact).toString(), getProjectRelativePath(projectArtifact.getFile())); } }
private void addAttachedArtifacts(Properties props) { for (Artifact a : this.project.getAttachedArtifacts()) { props.setProperty(RepositoryUtils.toArtifact(a).toString(), getProjectRelativePath(a.getFile())); } }
private static Artifact findProjectArtifact(MavenProject project) { String extension = project.getArtifact().getArtifactHandler().getExtension(); String fileName = project.getModel().getBuild().getFinalName() + "." + extension; File f = new File(new File(project.getBasedir(), "target"), fileName); if (f.exists()) { Artifact ret = RepositoryUtils.toArtifact(project.getArtifact()); return ret.setFile(f); } else { return null; } }
private Artifact resolveSourceArtifact( Artifact dep ) throws ArtifactResolutionException { if( !matchArtifact(dep) ) { return null; } final ArtifactTypeRegistry typeReg = repoSession.getArtifactTypeRegistry(); final String extension = null; final DefaultArtifact artifact = new DefaultArtifact( dep.getGroupId(), dep.getArtifactId(), SOURCE_CLASSIFIER, extension, dep.getVersion(), typeReg.get(dep.getType())); final ArtifactRequest request = new ArtifactRequest(); request.setArtifact( artifact ); request.setRepositories(remoteRepos); getLog().debug( String.format("Resolving artifact %s from %s", artifact, remoteRepos )); final ArtifactResult result = repoSystem.resolveArtifact( repoSession, request ); return RepositoryUtils.toArtifact(result.getArtifact()); }
private Artifact getDependencyArtifact( Dependency dep ) { Artifact mavenArtifact = RepositoryUtils.toArtifact( dep.getArtifact() ); mavenArtifact.setScope( dep.getScope() ); mavenArtifact.setOptional( dep.isOptional() ); return mavenArtifact; }