public static Dependency clone( Dependency dependency ) { if ( dependency == null ) { return null; } Dependency cloned = new Dependency(); // Identification cloned.setGroupId( dependency.getGroupId() ); cloned.setArtifactId( dependency.getArtifactId() ); cloned.setVersion( dependency.getVersion() ); cloned.setClassifier( dependency.getClassifier() ); cloned.setType( dependency.getType() ); // The rest. cloned.setTransitive( dependency.isTransitive() ); cloned.setScope( dependency.getScope() ); cloned.setOptional( dependency.isOptional() ); cloned.setSystemPath( dependency.getSystemPath() ); cloned.setUrl( dependency.getUrl() ); cloned.setExclusions( cloneExclusions( dependency.getExclusions() ) ); return cloned; }
public Dependency asDependency() { Dependency dep = new Dependency(); dep.setGroupId( groupId ); dep.setArtifactId( artifactId ); dep.setVersion( version ); dep.setType( packaging ); return dep; }
public static String toKey( Dependency dep ) { StringBuffer key = new StringBuffer(); key.append( dep.getGroupId() ).append( ":" ); key.append( dep.getArtifactId() ).append( ":" ); key.append( dep.getVersion() ).append( ":" ); if ( dep.getClassifier() != null ) { key.append( dep.getClassifier() ); } key.append( ":" ); key.append( dep.getType() ); return key.toString(); }
String scope = dependency.getScope(); artifactRef.setGroupId( dependency.getGroupId() ); artifactRef.setArtifactId( dependency.getArtifactId() ); artifactRef.setVersion( dependency.getVersion() ); artifactRef.setClassifier( dependency.getClassifier() ); artifactRef.setType( dependency.getType() ); if ( CollectionUtils.isNotEmpty( dependency.getExclusions() ) ) for ( Exclusion exclusion : dependency.getExclusions() ) if ( dependency.isFromParent() ) edge.setScope( StringUtils.defaultIfEmpty( dependency.getScope(), DependencyScope.COMPILE ) ); if ( dependency.isOptional() )
private void addDependencies( List<Dependency> dependencies ) { for ( Dependency dep : dependencies ) { String key = DependencyGraphKeys.toManagementKey( dep ); Rules merged = (Rules) depMap.get( key ); if ( merged == null ) { // New map entry. merged = new Rules(); merged.artifact = new ArtifactReference(); merged.artifact.setGroupId( dep.getGroupId() ); merged.artifact.setArtifactId( dep.getArtifactId() ); merged.artifact.setClassifier( dep.getClassifier() ); merged.artifact.setType( dep.getType() ); } merged.artifact.setVersion( dep.getVersion() ); if ( StringUtils.isNotBlank( dep.getScope() ) ) { merged.scope = dep.getScope(); } merged.addAllExclusions( dep.getExclusions() ); depMap.put( key, merged ); } }
public static String toManagementKey( Dependency ref ) { StringBuffer key = new StringBuffer(); key.append( ref.getGroupId() ).append( ":" ); key.append( ref.getArtifactId() ); return key.toString(); }
/** * Method addExclusion * * @param exclusion */ public void addExclusion(Exclusion exclusion) { if ( !(exclusion instanceof Exclusion) ) { throw new ClassCastException( "Dependency.addExclusions(exclusion) parameter must be instanceof " + Exclusion.class.getName() ); } getExclusions().add( exclusion ); } //-- void addExclusion(Exclusion)
public static boolean isSystemScoped( Dependency dep ) { return StringUtils.equals( SYSTEM, dep.getScope() ); }
public static String toVersionlessKey( Dependency dep ) { StringBuffer key = new StringBuffer(); key.append( dep.getGroupId() ).append( ":" ); key.append( dep.getArtifactId() ).append( ":" ); if ( dep.getClassifier() != null ) { key.append( dep.getClassifier() ); } key.append( ":" ); key.append( dep.getType() ); return key.toString(); }
/** * Method removeExclusion * * @param exclusion */ public void removeExclusion(Exclusion exclusion) { if ( !(exclusion instanceof Exclusion) ) { throw new ClassCastException( "Dependency.removeExclusions(exclusion) parameter must be instanceof " + Exclusion.class.getName() ); } getExclusions().remove( exclusion ); } //-- void removeExclusion(Exclusion)