/** {@inheritDoc} */ public String getId() { return artifact.getId(); }
/** {@inheritDoc} */ public String getId() { return artifact.getId(); }
private static String constructMessage( MavenProject project, Artifact artifact ) { return DEFAULT_MESSAGE + " (project: " + project.getId() + "; illegal attachment: " + artifact.getId() + ")"; }
private ModelSource createStubModelSource( Artifact artifact ) { StringBuilder buffer = new StringBuilder( 1024 ); buffer.append( "<?xml version='1.0'?>" ); buffer.append( "<project>" ); buffer.append( "<modelVersion>4.0.0</modelVersion>" ); buffer.append( "<groupId>" ).append( artifact.getGroupId() ).append( "</groupId>" ); buffer.append( "<artifactId>" ).append( artifact.getArtifactId() ).append( "</artifactId>" ); buffer.append( "<version>" ).append( artifact.getBaseVersion() ).append( "</version>" ); buffer.append( "<packaging>" ).append( artifact.getType() ).append( "</packaging>" ); buffer.append( "</project>" ); return new StringModelSource( buffer, artifact.getId() ); }
/** * @return {@link List} < {@link String} > with artifact ids * @throws OverConstrainedVersionException */ public List<String> getDependencyTrail() throws OverConstrainedVersionException { List<Artifact> trial = getTrail(); List<String> ret = new ArrayList<>( trial.size() ); for ( Artifact artifact : trial ) { ret.add( artifact.getId() ); } return ret; }
public AttachedArtifact( Artifact parent, String type, String classifier, ArtifactHandler artifactHandler ) { super( parent.getGroupId(), parent.getArtifactId(), parent.getVersionRange(), parent.getScope(), type, classifier, artifactHandler, parent.isOptional() ); setDependencyTrail( Collections.singletonList( parent.getId() ) ); this.parent = parent; if ( getId().equals( parent.getId() ) ) { throw new InvalidArtifactRTException( parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), parent.getType(), "An attached artifact must have a different ID than its corresponding main artifact." ); } }
/** * Attempts to resolve an {@link org.apache.maven.artifact.Artifact} to a {@link java.io.File}. * * @param artifact to resolve * @return a {@link java.io.File} to the resolved artifact, never <code>null</code>. * @throws org.apache.maven.plugin.MojoExecutionException if the artifact could not be resolved. */ public File resolveArtifactToFile( Artifact artifact ) throws MojoExecutionException { final Artifact resolvedArtifact = resolveArtifact( artifact ); final File jar = resolvedArtifact.getFile(); if ( jar == null ) { throw new MojoExecutionException( "Could not resolve artifact " + artifact.getId() + ". Please install it with \"mvn install:install-file ...\" or deploy it to a repository " + "with \"mvn deploy:deploy-file ...\"" ); } return jar; }
public AttachedArtifact( Artifact parent, String type, String classifier, ArtifactHandler artifactHandler ) { super( parent.getGroupId(), parent.getArtifactId(), parent.getVersionRange(), parent.getScope(), type, classifier, artifactHandler, parent.isOptional() ); setDependencyTrail( Collections.singletonList( parent.getId() ) ); this.parent = parent; if ( getId().equals( parent.getId() ) ) { throw new InvalidArtifactRTException( parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), parent.getType(), "An attached artifact must have a different ID" + " than its corresponding main artifact." ); } }
private void logMissingSiblingProjectArtifact( Artifact artifact ) { if ( logger == null || !logger.isDebugEnabled() ) { return; } if ( logger.isDebugEnabled() ) { StringBuffer message = new StringBuffer(); message.append( "WARNING: A dependency of the current project (or of one the plugins used in its build) was found in the reactor, " ); message.append( "\nbut had not been built at the time it was requested. It will be resolved from the repository instead." ); message.append( "\n\nCurrent Project: " ).append( getName() ); message.append( "\nRequested Dependency: " ).append( artifact.getId() ); message.append( "\n\nNOTE: You may need to run this build to the 'compile' lifecycle phase, or farther, in order to build the dependency artifact." ); message.append( "\n" ); logger.debug( message.toString() ); } else { logger.warn( "Requested project artifact: " + artifact.getId() + " is not available at this time. Resolving externally." ); } }
private static String constructMessage( List<Artifact> artifacts ) { StringBuilder buffer = new StringBuilder( 256 ); buffer.append( "Missing:\n" ); buffer.append( "----------\n" ); int counter = 0; for ( Artifact artifact : artifacts ) { String message = ( ++counter ) + ") " + artifact.getId(); buffer.append( constructMissingArtifactMessage( message, " ", artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(), artifact.getDownloadUrl(), artifact.getDependencyTrail() ) ); } buffer.append( "----------\n" ); int size = artifacts.size(); buffer.append( size ).append( " required artifact" ); if ( size > 1 ) { buffer.append( "s are" ); } else { buffer.append( " is" ); } buffer.append( " missing.\n\nfor artifact: " ); return buffer.toString(); }
private static String constructMessage( List<Artifact> artifacts ) { StringBuilder buffer = new StringBuilder( 256 ); buffer.append( "Missing:\n" ); buffer.append( "----------\n" ); int counter = 0; for ( Artifact artifact : artifacts ) { String message = ( ++counter ) + ") " + artifact.getId(); buffer.append( constructMissingArtifactMessage( message, " ", artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier(), artifact.getDownloadUrl(), artifact.getDependencyTrail() ) ); } buffer.append( "----------\n" ); int size = artifacts.size(); buffer.append( size ).append( " required artifact" ); if ( size > 1 ) { buffer.append( "s are" ); } else { buffer.append( " is" ); } buffer.append( " missing.\n\nfor artifact: " ); return buffer.toString(); }
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 ); } }
Collections.singletonList( project.getArtifact().getId() ), null );
Collections.singletonList( project.getArtifact().getId() ), collectionFilter );
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; }
throw new ProjectBuildingException( artifact.getId(), "Error resolving project artifact: " + e.getMessage(), e );