本文整理汇总了Java中org.apache.maven.artifact.ArtifactUtils类的典型用法代码示例。如果您正苦于以下问题:Java ArtifactUtils类的具体用法?Java ArtifactUtils怎么用?Java ArtifactUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ArtifactUtils类属于org.apache.maven.artifact包,在下文中一共展示了ArtifactUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getVersions
import org.apache.maven.artifact.ArtifactUtils; //导入依赖的package包/类
/**
* Uses the {@link DefaultVersionsHelper} to find all available versions that match all the associations with this
* property.
*
* @param includeSnapshots Whether to include snapshot versions in our search.
* @return The (possibly empty) array of versions.
*/
public synchronized ArtifactVersion[] getVersions( boolean includeSnapshots )
{
Set<ArtifactVersion> result;
if ( includeSnapshots )
{
result = versions;
}
else
{
result = new TreeSet<>( getVersionComparator() );
for ( ArtifactVersion candidate : versions )
{
if ( ArtifactUtils.isSnapshot( candidate.toString() ) )
{
continue;
}
result.add( candidate );
}
}
return asArtifactVersionArray( result );
}
示例2: getVersions
import org.apache.maven.artifact.ArtifactUtils; //导入依赖的package包/类
public ArtifactVersion[] getVersions( boolean includeSnapshots )
{
Set<ArtifactVersion> result;
if ( includeSnapshots )
{
result = versions;
}
else
{
result = new TreeSet<>( versionComparator );
for ( ArtifactVersion candidate : versions )
{
if ( ArtifactUtils.isSnapshot( candidate.toString() ) )
{
continue;
}
result.add( candidate );
}
}
return result.toArray( new ArtifactVersion[result.size()] );
}
示例3: getNewVersion
import org.apache.maven.artifact.ArtifactUtils; //导入依赖的package包/类
private String getNewVersion( ExternalVersionStrategy strategy, MavenProject mavenProject )
throws ExternalVersionException
{
// snapshot detection against the old version.
boolean isSnapshot = ArtifactUtils.isSnapshot( mavenProject.getVersion() );
// lookup the new version
String newVersion = strategy.getVersion( mavenProject );
if ( newVersion != null )
{
newVersion = newVersion.trim();
}
boolean isNewSnapshot = ArtifactUtils.isSnapshot( newVersion );
// make sure we still have a SNAPSHOT if we had one previously.
if ( isSnapshot && !isNewSnapshot )
{
newVersion = newVersion + "-SNAPSHOT";
}
return newVersion;
}
示例4: getVersions
import org.apache.maven.artifact.ArtifactUtils; //导入依赖的package包/类
/**
* Uses the {@link DefaultVersionsHelper} to find all available versions that match all
* the associations with this property.
*
* @param includeSnapshots Whether to include snapshot versions in our search.
* @return The (possibly empty) array of versions.
*/
public synchronized ArtifactVersion[] getVersions( boolean includeSnapshots )
{
Set<ArtifactVersion> result;
if ( includeSnapshots )
{
result = versions;
}
else
{
result = new TreeSet<ArtifactVersion>( getVersionComparator() );
for ( ArtifactVersion candidate : versions )
{
if ( ArtifactUtils.isSnapshot( candidate.toString() ) )
{
continue;
}
result.add( candidate );
}
}
return asArtifactVersionArray( result );
}
示例5: getVersions
import org.apache.maven.artifact.ArtifactUtils; //导入依赖的package包/类
public ArtifactVersion[] getVersions( boolean includeSnapshots )
{
Set<ArtifactVersion> result;
if ( includeSnapshots )
{
result = versions;
}
else
{
result = new TreeSet<ArtifactVersion>( versionComparator );
for ( ArtifactVersion candidate : versions )
{
if ( ArtifactUtils.isSnapshot( candidate.toString() ) )
{
continue;
}
result.add( candidate );
}
}
return result.toArray( new ArtifactVersion[result.size()] );
}
示例6: toDescriptor
import org.apache.maven.artifact.ArtifactUtils; //导入依赖的package包/类
/**
* Converts the given artifact to a string of the form <code>groupId:artifactId:version:[type]:[classifier]</code>.
* @param artifact the artifact to encode as an artifact descriptor.
* @return the artifact descriptor, as a string.
*/
public static String toDescriptor(final Artifact artifact) {
Preconditions.checkNotNull(artifact);
final String artifactId = artifact.getArtifactId();
final String groupId = artifact.getGroupId();
final String type = artifact.getType();
final String version = artifact.getVersion();
final String classifier = artifact.getClassifier();
final StringBuilder builder = new StringBuilder(ArtifactUtils.key(
groupId, artifactId, version));
if (!StringUtils.isBlank(type)) {
builder.append(ARTIFACT_DESCRIPTOR_SEPARATOR + type);
if (!StringUtils.isBlank(classifier)) {
builder.append(ARTIFACT_DESCRIPTOR_SEPARATOR + classifier);
}
}
final String artifactDescription = builder.toString();
return artifactDescription;
}
示例7: SimpleReactorReader
import org.apache.maven.artifact.ArtifactUtils; //导入依赖的package包/类
private SimpleReactorReader(Collection<MavenProject> projects, Collection<Artifact> artifacts) {
repository = new WorkspaceRepository("reactor", new Object());
Map<String, MavenProject> projectsByGAV = new LinkedHashMap<>();
for (MavenProject project : projects) {
String projectKey = ArtifactUtils.key(project.getGroupId(), project.getArtifactId(), project.getVersion());
projectsByGAV.put(projectKey, project);
}
this.projectsByGAV = ImmutableMap.copyOf(projectsByGAV);
Map<String, Artifact> artifactsByGAVCE = new LinkedHashMap<>();
for (Artifact artifact : artifacts) {
artifactsByGAVCE.put(keyGAVCE(artifact), artifact);
}
this.artifactsByGAVCE = ImmutableMap.copyOf(artifactsByGAVCE);
}
示例8: areAllDependenciesInReactor
import org.apache.maven.artifact.ArtifactUtils; //导入依赖的package包/类
private boolean areAllDependenciesInReactor( Collection<MavenProject> projects, Collection<Dependency> dependencies )
{
Set<String> projectKeys = getReactorProjectKeys( projects );
for ( Dependency dependency : dependencies )
{
org.sonatype.aether.artifact.Artifact a = dependency.getArtifact();
String key = ArtifactUtils.key( a.getGroupId(), a.getArtifactId(), a.getVersion() );
if ( !projectKeys.contains( key ) )
{
return false;
}
}
return true;
}
示例9: findDependency
import org.apache.maven.artifact.ArtifactUtils; //导入依赖的package包/类
private static Artifact findDependency( MavenProject project, Artifact upStreamArtifact )
{
if ( upStreamArtifact == null || isThreadLockedAndEmpty(upStreamArtifact))
{
return null;
}
String key = ArtifactUtils.key( upStreamArtifact.getGroupId(), upStreamArtifact.getArtifactId(),
upStreamArtifact.getVersion() );
final Set<Artifact> deps = project.getDependencyArtifacts();
for ( Artifact dep : deps )
{
String depKey = ArtifactUtils.key( dep.getGroupId(), dep.getArtifactId(), dep.getVersion() );
if ( key.equals( depKey ) )
{
return dep;
}
}
return null;
}
示例10: CacheKey
import org.apache.maven.artifact.ArtifactUtils; //导入依赖的package包/类
public CacheKey( Artifact artifact, boolean resolveManagedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
{
File file = artifact.getFile();
this.artifact = ArtifactUtils.copyArtifact( artifact );
if ( "pom".equals( artifact.getType() ) && file != null )
{
pomHash = file.getPath().hashCode() + file.lastModified();
}
else
{
pomHash = 0;
}
this.resolveManagedVersions = resolveManagedVersions;
this.repositories.add( localRepository );
this.repositories.addAll( remoteRepositories );
int hash = 17;
hash = hash * 31 + artifactHashCode( artifact );
hash = hash * 31 + ( resolveManagedVersions ? 1 : 2 );
hash = hash * 31 + repositoriesHashCode( repositories );
this.hashCode = hash;
}
示例11: get
import org.apache.maven.artifact.ArtifactUtils; //导入依赖的package包/类
public ResolutionGroup get( Artifact artifact, boolean resolveManagedVersions, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
{
CacheKey cacheKey = newCacheKey( artifact, resolveManagedVersions, localRepository, remoteRepositories );
CacheRecord cacheRecord = cache.get( cacheKey );
if ( cacheRecord != null && !cacheRecord.isStale() )
{
Artifact pomArtifact = ArtifactUtils.copyArtifact( cacheRecord.getArtifact() );
Artifact relocatedArtifact = ArtifactUtils.copyArtifactSafe( cacheRecord.getRelocatedArtifact() );
Set<Artifact> artifacts =
ArtifactUtils.copyArtifacts( cacheRecord.getArtifacts(), new LinkedHashSet<Artifact>() );
Map<String, Artifact> managedVersions = cacheRecord.getManagedVersions();
if ( managedVersions != null )
{
managedVersions = ArtifactUtils.copyArtifacts( managedVersions, new LinkedHashMap<String, Artifact>() );
}
return new ResolutionGroup( pomArtifact, relocatedArtifact, artifacts, managedVersions,
cacheRecord.getRemoteRepositories() );
}
cache.remove( cacheKey );
return null;
}
示例12: ReactorReader
import org.apache.maven.artifact.ArtifactUtils; //导入依赖的package包/类
public ReactorReader( Map<String, MavenProject> reactorProjects )
{
projectsByGAV = reactorProjects;
projectsByGA = new HashMap<String, List<MavenProject>>( reactorProjects.size() * 2 );
for ( MavenProject project : reactorProjects.values() )
{
String key = ArtifactUtils.versionlessKey( project.getGroupId(), project.getArtifactId() );
List<MavenProject> projects = projectsByGA.get( key );
if ( projects == null )
{
projects = new ArrayList<MavenProject>( 1 );
projectsByGA.put( key, projects );
}
projects.add( project );
}
repository = new WorkspaceRepository( "reactor", new HashSet<String>( projectsByGAV.keySet() ) );
}
示例13: findArtifact
import org.apache.maven.artifact.ArtifactUtils; //导入依赖的package包/类
public File findArtifact( Artifact artifact )
{
String projectKey = ArtifactUtils.key( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() );
MavenProject project = projectsByGAV.get( projectKey );
if ( project != null )
{
File file = find( project, artifact );
if ( file == null && project != project.getExecutionProject() )
{
file = find( project.getExecutionProject(), artifact );
}
return file;
}
return null;
}
示例14: findVersions
import org.apache.maven.artifact.ArtifactUtils; //导入依赖的package包/类
public List<String> findVersions( Artifact artifact )
{
String key = ArtifactUtils.versionlessKey( artifact.getGroupId(), artifact.getArtifactId() );
List<MavenProject> projects = projectsByGA.get( key );
if ( projects == null || projects.isEmpty() )
{
return Collections.emptyList();
}
List<String> versions = new ArrayList<String>();
for ( MavenProject project : projects )
{
if ( find( project, artifact ) != null )
{
versions.add( project.getVersion() );
}
}
return Collections.unmodifiableList( versions );
}
示例15: testPluginArtifactMapExpressionReference
import org.apache.maven.artifact.ArtifactUtils; //导入依赖的package包/类
public void testPluginArtifactMapExpressionReference()
throws Exception
{
MojoExecution exec = newMojoExecution();
Artifact depArtifact = createArtifact( "group", "artifact", "1" );
List<Artifact> deps = new ArrayList<Artifact>();
deps.add( depArtifact );
exec.getMojoDescriptor().getPluginDescriptor().setArtifacts( deps );
MavenSession session = newMavenSession();
@SuppressWarnings( "unchecked" )
Map<String, Artifact> depResults =
(Map<String, Artifact>) new PluginParameterExpressionEvaluator( session, exec ).evaluate( "${plugin.artifactMap}" );
System.out.println( "Result: " + depResults );
assertNotNull( depResults );
assertEquals( 1, depResults.size() );
assertSame( "dependency artifact is wrong.",
depArtifact,
depResults.get( ArtifactUtils.versionlessKey( depArtifact ) ) );
}