public String getType() { return artifact.getExtension(); }
public String getExtension() { return artifact.getExtension(); }
/** * 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() ) ); } }
/** * 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(); }
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; }
public static ArtifactHandler newHandler( Artifact artifact ) { String type = artifact.getProperty( ArtifactProperties.TYPE, artifact.getExtension() ); DefaultArtifactHandler handler = new DefaultArtifactHandler( type ); handler.setExtension( artifact.getExtension() ); handler.setLanguage( artifact.getProperty( ArtifactProperties.LANGUAGE, null ) ); String addedToClasspath = artifact.getProperty( ArtifactProperties.CONSTITUTES_BUILD_PATH, "" ); handler.setAddedToClasspath( Boolean.parseBoolean( addedToClasspath ) ); String includesDependencies = artifact.getProperty( ArtifactProperties.INCLUDES_DEPENDENCIES, "" ); handler.setIncludesDependencies( Boolean.parseBoolean( includesDependencies ) ); return handler; }
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() ); }
private File find( MavenProject project, Artifact artifact ) if ( "pom".equals( artifact.getExtension() ) )
artifactId = artifact.getArtifactId(); classifier = artifact.getClassifier(); extension = artifact.getExtension(); version = artifact.getVersion(); localRepo = session.getLocalRepository().getBasedir();
sv.setExtension( artifact.getExtension() ); sv.setVersion( getVersion() ); sv.setUpdated( lastUpdated );
sv.setExtension( artifact.getExtension() ); sv.setVersion( version ); sv.setUpdated( lastUpdated );
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; }
/** * @param artifact {@link Artifact} to check if it is a plugin * @return true if it is classified as {@value ArtifactPluginDescriptor#MULE_PLUGIN_CLASSIFIER} or * {@value #MULE_EXTENSION_CLASSIFIER} or it has a * {@value ArtifactDescriptor#MULE_ARTIFACT_JSON_DESCRIPTOR} file. */ private boolean isMulePlugin(Artifact artifact) { return artifact.getExtension().equals(MULE_PLUGIN_CLASSIFIER) || artifact.getExtension().equals(MULE_EXTENSION_CLASSIFIER); }
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())); }
@Override public File findArtifact(Artifact artifact) { File workspaceArtifactPath = workspaceLocationResolver.resolvePath(artifact.getArtifactId()); if (workspaceArtifactPath == null) { logger.debug("Couldn't resolve '{}' from workspace, it would be resolved against local repository or downloaded", artifact); // Cannot be resolved in workspace so delegate its resolution to the Maven local repository return null; } File artifactFile; if (artifact.getExtension().equals(POM)) { artifactFile = findPomFile(artifact, workspaceArtifactPath); } else { artifactFile = findClassPathURL(artifact, workspaceArtifactPath, classPath); } if (artifactFile != null && artifactFile.exists()) { logger.debug("Artifact '{}' resolved from workspace {}", artifact, artifactFile.getAbsolutePath()); return artifactFile.getAbsoluteFile(); } return null; }
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; }