private Set<Artifact> processTransitiveDependencies( List<Dependency> dependencies, boolean sharedLibraries ) throws MojoExecutionException { final Set<Artifact> transitiveArtifacts = new LinkedHashSet<Artifact>(); for ( Dependency dependency : dependencies ) { if ( ! Artifact.SCOPE_PROVIDED.equals( dependency.getScope() ) && ! dependency.isOptional() ) { final Set<Artifact> transArtifactsFor = processTransitiveDependencies( dependency, sharedLibraries ); log.debug( "Found transitive dependencies for : " + dependency + " transDeps : " + transArtifactsFor ); transitiveArtifacts.addAll( transArtifactsFor ); } } return transitiveArtifacts; }
private static Artifact createDependencyArtifact( ArtifactFactory factory, Dependency dependency, String inheritedScope, ArtifactFilter inheritedFilter ) throws InvalidVersionSpecificationException { String effectiveScope = getEffectiveScope( dependency.getScope(), inheritedScope ); if ( effectiveScope == null ) { return null; } VersionRange versionRange = VersionRange.createFromVersionSpec( dependency.getVersion() ); Artifact dependencyArtifact = factory.createDependencyArtifact( dependency.getGroupId(), dependency.getArtifactId(), versionRange, dependency.getType(), dependency.getClassifier(), effectiveScope, dependency.isOptional() ); ArtifactFilter dependencyFilter = inheritedFilter; if ( dependencyFilter != null && !dependencyFilter.include( dependencyArtifact ) ) { return null; } if ( Artifact.SCOPE_SYSTEM.equals( effectiveScope ) ) { dependencyArtifact.setFile( new File( dependency.getSystemPath() ) ); } dependencyArtifact.setDependencyFilter( createDependencyFilter( dependency, dependencyFilter ) ); return dependencyArtifact; }
d.getClassifier(), d.getScope(), d.isOptional() );
d.getClassifier(), d.getScope(), d.isOptional() );
public static Dependency toDependency( org.apache.maven.model.Dependency dependency, ArtifactTypeRegistry stereotypes ) { ArtifactType stereotype = stereotypes.get( dependency.getType() ); if ( stereotype == null ) { stereotype = new DefaultArtifactType( dependency.getType() ); } boolean system = dependency.getSystemPath() != null && dependency.getSystemPath().length() > 0; Map<String, String> props = null; if ( system ) { props = Collections.singletonMap( ArtifactProperties.LOCAL_PATH, dependency.getSystemPath() ); } Artifact artifact = new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null, dependency.getVersion(), props, stereotype ); List<Exclusion> exclusions = new ArrayList<>( dependency.getExclusions().size() ); for ( org.apache.maven.model.Exclusion exclusion : dependency.getExclusions() ) { exclusions.add( toExclusion( exclusion ) ); } Dependency result = new Dependency( artifact, dependency.getScope(), dependency.getOptional() != null ? dependency.isOptional() : null, exclusions ); return result; }
private Dependency convert( org.apache.maven.model.Dependency dependency, ArtifactTypeRegistry stereotypes ) { ArtifactType stereotype = stereotypes.get( dependency.getType() ); if ( stereotype == null ) { stereotype = new DefaultArtifactType( dependency.getType() ); } boolean system = dependency.getSystemPath() != null && dependency.getSystemPath().length() > 0; Map<String, String> props = null; if ( system ) { props = Collections.singletonMap( ArtifactProperties.LOCAL_PATH, dependency.getSystemPath() ); } Artifact artifact = new DefaultArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), null, dependency.getVersion(), props, stereotype ); List<Exclusion> exclusions = new ArrayList<>( dependency.getExclusions().size() ); for ( org.apache.maven.model.Exclusion exclusion : dependency.getExclusions() ) { exclusions.add( convert( exclusion ) ); } Dependency result = new Dependency( artifact, dependency.getScope(), dependency.getOptional() != null ? dependency.isOptional() : null, exclusions ); return result; }
scope, inheritedScope, d.isOptional() );
versionRange, d.getType(), d.getClassifier(), d.getScope(), d.isOptional() ); if ( getLogger().isDebugEnabled() )
public static Dependency cloneDependency( Dependency src ) { Dependency result = null; if ( src != null ) { result = new Dependency(); result.setArtifactId( src.getArtifactId() ); result.setClassifier( src.getClassifier() ); result.setExclusions( cloneList( src.getExclusions(), DEPENDENCY_EXCLUSION_CLONER ) ); result.setGroupId( src.getGroupId() ); result.setOptional( src.isOptional() ); result.setScope( src.getScope() ); result.setSystemPath( src.getSystemPath() ); result.setType( src.getType() ); result.setVersion( src.getVersion() ); } return result; }
options.put( "optional", d.isOptional() );
public boolean isOptional() { return dependency.isOptional(); }
if (depend.isOptional() || "test".equals(depend.getScope())) { continue;
public void updatedOptionalFlag( Dependency dependency, boolean previousOptional ) { if ( !previousOptional && dependency.isOptional() ) { // It wasn't optional but now it is anymore handleDependency( context, dependency, "Dependency [" + dependency + "] is now optional but it was not bundled anyway.", "Dependency [" + dependency + "] is now optional. If it was included in the build as an overlay, " + "consider cleaning the target directory of the project (mvn clean)", "Dependency [" + dependency + "] is now optional", true ); } }
public List<ExtensionId> getSuggestedExtensions() { if (this.suggested == null) { this.suggested = new ArrayList<ExtensionId>(); for (Dependency mavenDependency : this.mavenModel.getDependencies()) { if (mavenDependency.isOptional()) { this.suggested.add(new ExtensionId(mavenDependency.getGroupId() + ":" + mavenDependency.getArtifactId(), mavenDependency.getVersion())); } } } return this.suggested; }
/** * {@inheritDoc} */ protected void handleDependency( WarPackagingContext context, Dependency dependency, String notBundledMessage, String warOrZipMessage, String standardMessage, boolean removeFile ) { if ( Artifact.SCOPE_PROVIDED.equals( dependency.getScope() ) || Artifact.SCOPE_TEST.equals( dependency.getScope() ) || dependency.isOptional() ) { context.getLog().debug( notBundledMessage ); } else { handleDependencyScope( context, dependency, warOrZipMessage, standardMessage, removeFile ); } }
/** * {@inheritDoc} */ public Artifact createDependencyArtifact( Dependency dependency ) throws InvalidVersionSpecificationException { return createDependencyArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion() == null ? VersionRange.createFromVersionSpec( "[0,]" ) : VersionRange.createFromVersionSpec( dependency.getVersion() ), dependency.getType(), dependency.getClassifier(), dependency.getScope(), dependency.isOptional() ); }
/** * {@inheritDoc} */ public Artifact createDependencyArtifact( Dependency dependency ) throws InvalidVersionSpecificationException { return createDependencyArtifact( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion() == null ? VersionRange.createFromVersionSpec( "[0,]" ) : VersionRange.createFromVersionSpec( dependency.getVersion() ), dependency.getType(), dependency.getClassifier(), dependency.getScope(), dependency.isOptional() ); }
private Dependency toAetherDependency(org.apache.maven.model.Dependency dependency) { Artifact artifact = new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), dependency.getType(), dependency.getVersion()); ImmutableList.Builder<Exclusion> exclusions = ImmutableList.builder(); for (org.apache.maven.model.Exclusion exclusion : dependency.getExclusions()) { exclusions.add(new Exclusion(exclusion.getGroupId(), exclusion.getArtifactId(), null, "*")); } return new Dependency(artifact, dependency.getScope(), dependency.isOptional(), exclusions.build()); }
private Dependency toAetherDependency(org.apache.maven.model.Dependency dependency) { Artifact artifact = new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(), dependency.getClassifier(), dependency.getType(), dependency.getVersion()); ImmutableList.Builder<Exclusion> exclusions = ImmutableList.builder(); for (org.apache.maven.model.Exclusion exclusion : dependency.getExclusions()) { exclusions.add(new Exclusion(exclusion.getGroupId(), exclusion.getArtifactId(), null, "*")); } return new Dependency(artifact, dependency.getScope(), dependency.isOptional(), exclusions.build()); }
public static ArtifactDependency createArtifactDependency(Dependency d) { ArtifactDependency dependency = new ArtifactDependency( new ArtifactRevisionIdentifier(d), d.getScope() ); dependency.setClassifier(d.getClassifier()); dependency.setOptional(d.isOptional()); for (Exclusion ex : d.getExclusions()) { ArtifactIdentifier id = new ArtifactIdentifier(ex.getArtifactId(), ex.getGroupId()); dependency.getExclusions().add(id); } return dependency; }