public String getClassifier() { return artifact.getClassifier(); }
public String getClassifier() { return artifact.getClassifier(); }
/** * Convert {@link Artifact} object to String for printing. * * @param artifact Artifact object * @return String representation of Artifact */ public static String artifactToString(Artifact artifact) { StringBuilder buffer = new StringBuilder(128); buffer.append(artifact.getGroupId()); buffer.append(':').append(artifact.getArtifactId()); buffer.append(':').append(artifact.getExtension()); if (artifact.getClassifier().length() > 0) { buffer.append(':').append(artifact.getClassifier()); } buffer.append(':').append(artifact.getVersion()); return buffer.toString(); }
/** * Determines whether the specified artifact refers to test classes. * * @param artifact The artifact to check, must not be {@code null}. * @return {@code true} if the artifact refers to test classes, {@code false} otherwise. */ private static boolean isTestArtifact( Artifact artifact ) { return ( "test-jar".equals( artifact.getProperty( "type", "" ) ) ) || ( "jar".equals( artifact.getExtension() ) && "tests".equals( artifact.getClassifier() ) ); } }
private boolean attachedArtifactComparison( Artifact requested, Artifact attached ) { // // We are taking as much as we can from the DefaultArtifact.equals(). The requested artifact has no file so // we want to remove that from the comparison. // return requested.getArtifactId().equals( attached.getArtifactId() ) && requested.getGroupId().equals( attached.getGroupId() ) && requested.getVersion().equals( attached.getVersion() ) && requested.getExtension().equals( attached.getExtension() ) && requested.getClassifier().equals( attached.getClassifier() ); }
public String getExpandedVersion( Artifact artifact ) { String key = getKey( artifact.getClassifier(), artifact.getExtension() ); return versions.get( key ).getVersion(); }
public static Artifact toPomArtifact( Artifact artifact ) { Artifact pomArtifact = artifact; if ( pomArtifact.getClassifier().length() > 0 || !"pom".equals( pomArtifact.getExtension() ) ) { pomArtifact = new DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), "pom", artifact.getVersion() ); } return pomArtifact; }
private DependencyNode findPlexusUtils( DependencyNode node ) { Artifact artifact = node.getDependency().getArtifact(); if ( AID.equals( artifact.getArtifactId() ) && GID.equals( artifact.getGroupId() ) && EXT.equals( artifact.getExtension() ) && "".equals( artifact.getClassifier() ) ) { return node; } for ( DependencyNode child : node.getChildren() ) { DependencyNode result = findPlexusUtils( child ); if ( result != null ) { return result; } } return null; }
private static String getId( Artifact artifact ) { return getId( artifact.getGroupId(), artifact.getArtifactId(), artifact.getExtension(), artifact.getClassifier(), artifact.getBaseVersion() ); }
groupId = artifact.getGroupId(); artifactId = artifact.getArtifactId(); classifier = artifact.getClassifier(); extension = artifact.getExtension(); version = artifact.getVersion();
sv.setClassifier( artifact.getClassifier() ); sv.setExtension( artifact.getExtension() ); sv.setVersion( getVersion() );
sv.setClassifier( artifact.getClassifier() ); sv.setExtension( artifact.getExtension() ); sv.setVersion( version );
public static org.apache.maven.artifact.Artifact toArtifact( Artifact artifact ) { if ( artifact == null ) { return null; } ArtifactHandler handler = newHandler( artifact ); /* * NOTE: From Artifact.hasClassifier(), an empty string and a null both denote "no classifier". However, some * plugins only check for null, so be sure to nullify an empty classifier. */ org.apache.maven.artifact.Artifact result = new org.apache.maven.artifact.DefaultArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), null, artifact.getProperty( ArtifactProperties.TYPE, artifact.getExtension() ), nullify( artifact.getClassifier() ), handler ); result.setFile( artifact.getFile() ); result.setResolved( artifact.getFile() != null ); List<String> trail = new ArrayList<>( 1 ); trail.add( result.getId() ); result.setDependencyTrail( trail ); return result; }
String key = SNAPSHOT + getKey( artifact.getClassifier(), artifact.getExtension() ); merge( infos, SNAPSHOT, key ); if ( !resolve( result, infos, key ) )
/** * Determines whether the specified artifact refers to test classes. * * @param artifact The artifact to check, must not be {@code null}. * @return {@code true} if the artifact refers to test classes, {@code false} otherwise. */ public static boolean isTestArtifact(Artifact artifact) { return ("test-jar".equals(artifact.getProperty("type", ""))) || ("jar".equals(artifact.getExtension()) && "tests".equals(artifact.getClassifier())); }
/** * Finds the direct {@link Dependency} from rootArtifact for the given groupId and artifactId. * * @param groupId of the artifact to be found * @param artifactId of the artifact to be found * @param classifier of the artifact to be found * @param directDependencies the rootArtifact direct {@link Dependency}s * @return {@link Optional} {@link Dependency} to the dependency. Could be empty it if not present in the list of direct * dependencies */ private Optional<Dependency> findDirectDependency(String groupId, String artifactId, Optional<String> classifier, List<Dependency> directDependencies) { return directDependencies.isEmpty() ? Optional.empty() : directDependencies.stream().filter( dependency -> dependency.getArtifact().getGroupId().equals(groupId) && dependency.getArtifact().getArtifactId().equals(artifactId) && ((classifier.isPresent() && dependency.getArtifact().getClassifier().equals(classifier.get()) || !classifier.isPresent()))) .findFirst(); }
/** * Gets the direct dependencies filter to be used when collecting Container dependencies. If the rootArtifact is a * {@link ArtifactClassificationType#MODULE} it will include {@value org.eclipse.aether.util.artifact.JavaScopes#COMPILE} * dependencies too if not just {@value org.eclipse.aether.util.artifact.JavaScopes#PROVIDED}. * * @param rootArtifactType the {@link ArtifactClassificationType} for rootArtifact * @return {@link Predicate} for selecting direct dependencies for the Container. */ private Predicate<Dependency> getContainerDirectDependenciesFilter(ArtifactClassificationType rootArtifactType) { return rootArtifactType.equals(MODULE) ? directDep -> directDep.getScope().equals(PROVIDED) || directDep.getScope().equals(COMPILE) : directDep -> directDep.getScope().equals(PROVIDED) || directDep.getArtifact().getClassifier().equals(MULE_PLUGIN_CLASSIFIER); }
/** * Finds direct dependencies declared with classifier {@value #MULE_SERVICE_CLASSIFIER}. Creates a List of * {@link ArtifactUrlClassification} for each service including their {@code compile} scope dependencies. * <p/> * Once identified and classified these Maven artifacts will be excluded from container classification. * * @param context {@link ClassPathClassifierContext} with settings for the classification process * @param directDependencies {@link List} of {@link Dependency} with direct dependencies for the rootArtifact * @param rootArtifactRemoteRepositories remote repositories defined at the rootArtifact. * @return a {@link List} of {@link ArtifactUrlClassification}s that would be the one used for the plugins class loaders. */ private List<ArtifactUrlClassification> buildServicesUrlClassification(final ClassPathClassifierContext context, final List<Dependency> directDependencies, final List<RemoteRepository> rootArtifactRemoteRepositories) { List<ArtifactClassificationNode> servicesClassified = newArrayList(); final Predicate<Dependency> muleServiceClassifiedDependencyFilter = dependency -> dependency.getArtifact().getClassifier().equals(MULE_SERVICE_CLASSIFIER); List<Artifact> serviceArtifactsDeclared = filterArtifacts(directDependencies, muleServiceClassifiedDependencyFilter); logger.debug("{} services defined to be classified", serviceArtifactsDeclared.size()); serviceArtifactsDeclared.stream() .forEach(serviceArtifact -> buildPluginUrlClassification(serviceArtifact, context, muleServiceClassifiedDependencyFilter, servicesClassified, rootArtifactRemoteRepositories)); return toServiceUrlClassification(resolveArtifactsUsingSemanticVersioning(servicesClassified)); }
private boolean accept(final Artifact artifact, final String pattern) { final String[] tokens = new String[] {artifact.getGroupId(), artifact.getArtifactId(), artifact.getExtension(), artifact.getClassifier(), artifact.getBaseVersion()}; final String[] patternTokens = pattern.split(MAVEN_COORDINATES_SEPARATOR); // Fail immediately if pattern tokens outnumber tokens to match boolean matched = (patternTokens.length <= tokens.length); for (int i = 0; matched && i < patternTokens.length; i++) { matched = matches(tokens[i], patternTokens[i]); } return matched; }
.filter(dependency -> dependency.getArtifact().getClassifier().equals(MULE_PLUGIN_CLASSIFIER)) .map(dependency -> dependency.getArtifact()) .collect(toList()); dependency -> dependency.getArtifact().getClassifier().equals(MULE_PLUGIN_CLASSIFIER) && dependency.getScope().equals(COMPILE); if (PLUGIN.equals(rootArtifactType)) {