private void injectDependencyDefaults( List<Dependency> dependencies ) { for ( Dependency dependency : dependencies ) { if ( StringUtils.isEmpty( dependency.getScope() ) ) { // we cannot set this directly in the MDO due to the interactions with dependency management dependency.setScope( "compile" ); } } }
@Deprecated public List<Dependency> getTestDependencies() { Set<Artifact> artifacts = getArtifacts(); if ( ( artifacts == null ) || artifacts.isEmpty() ) { return Collections.emptyList(); } List<Dependency> list = new ArrayList<>( artifacts.size() ); for ( Artifact a : getArtifacts() ) { Dependency dependency = new Dependency(); dependency.setArtifactId( a.getArtifactId() ); dependency.setGroupId( a.getGroupId() ); dependency.setVersion( a.getVersion() ); dependency.setScope( a.getScope() ); dependency.setType( a.getType() ); dependency.setClassifier( a.getClassifier() ); list.add( dependency ); } return Collections.unmodifiableList( list ); }
public List getSystemDependencies() { Set artifacts = getArtifacts(); if ( artifacts == null || artifacts.isEmpty() ) { return Collections.EMPTY_LIST; } List list = new ArrayList( artifacts.size() ); for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); // TODO: let the scope handler deal with this if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { Dependency dependency = new Dependency(); dependency.setArtifactId( a.getArtifactId() ); dependency.setGroupId( a.getGroupId() ); dependency.setVersion( a.getVersion() ); dependency.setScope( a.getScope() ); dependency.setType( a.getType() ); dependency.setClassifier( a.getClassifier() ); list.add( dependency ); } } return list; }
public List getTestDependencies() { Set artifacts = getArtifacts(); if ( artifacts == null || artifacts.isEmpty() ) { return Collections.EMPTY_LIST; } List list = new ArrayList( artifacts.size() ); for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); // TODO: let the scope handler deal with this // NOTE: [jc] scope == 'test' is the widest possible scope, so we don't really need to perform // this check... // if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) || // Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) // { // } Dependency dependency = new Dependency(); dependency.setArtifactId( a.getArtifactId() ); dependency.setGroupId( a.getGroupId() ); dependency.setVersion( a.getVersion() ); dependency.setScope( a.getScope() ); dependency.setType( a.getType() ); dependency.setClassifier( a.getClassifier() ); list.add( dependency ); } return list; }
public List getRuntimeDependencies() { Set artifacts = getArtifacts(); if ( artifacts == null || artifacts.isEmpty() ) { return Collections.EMPTY_LIST; } List list = new ArrayList( artifacts.size() ); for ( Iterator i = artifacts.iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); // TODO: let the scope handler deal with this if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) { Dependency dependency = new Dependency(); dependency.setArtifactId( a.getArtifactId() ); dependency.setGroupId( a.getGroupId() ); dependency.setVersion( a.getVersion() ); dependency.setScope( a.getScope() ); dependency.setType( a.getType() ); dependency.setClassifier( a.getClassifier() ); list.add( dependency ); } } return list; }
public List getCompileDependencies() { Set artifacts = getArtifacts(); if ( artifacts == null || artifacts.isEmpty() ) { return Collections.EMPTY_LIST; } List list = new ArrayList( artifacts.size() ); for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); // TODO: let the scope handler deal with this if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) || Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { Dependency dependency = new Dependency(); dependency.setArtifactId( a.getArtifactId() ); dependency.setGroupId( a.getGroupId() ); dependency.setVersion( a.getVersion() ); dependency.setScope( a.getScope() ); dependency.setType( a.getType() ); dependency.setClassifier( a.getClassifier() ); list.add( dependency ); } } return list; }
@Deprecated public List<Dependency> getSystemDependencies() { Set<Artifact> artifacts = getArtifacts(); if ( ( artifacts == null ) || artifacts.isEmpty() ) { return Collections.emptyList(); } List<Dependency> list = new ArrayList<>( artifacts.size() ); for ( Artifact a : getArtifacts() ) { // TODO let the scope handler deal with this if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { Dependency dependency = new Dependency(); dependency.setArtifactId( a.getArtifactId() ); dependency.setGroupId( a.getGroupId() ); dependency.setVersion( a.getVersion() ); dependency.setScope( a.getScope() ); dependency.setType( a.getType() ); dependency.setClassifier( a.getClassifier() ); list.add( dependency ); } } return Collections.unmodifiableList( list ); }
@Deprecated public List<Dependency> getCompileDependencies() { Set<Artifact> artifacts = getArtifacts(); if ( ( artifacts == null ) || artifacts.isEmpty() ) { return Collections.emptyList(); } List<Dependency> list = new ArrayList<>( artifacts.size() ); for ( Artifact a : getArtifacts() ) { // TODO let the scope handler deal with this if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) || Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { Dependency dependency = new Dependency(); dependency.setArtifactId( a.getArtifactId() ); dependency.setGroupId( a.getGroupId() ); dependency.setVersion( a.getVersion() ); dependency.setScope( a.getScope() ); dependency.setType( a.getType() ); dependency.setClassifier( a.getClassifier() ); list.add( dependency ); } } return Collections.unmodifiableList( list ); }
@Deprecated // used by the Maven ITs public List<Dependency> getRuntimeDependencies() { Set<Artifact> artifacts = getArtifacts(); if ( ( artifacts == null ) || artifacts.isEmpty() ) { return Collections.emptyList(); } List<Dependency> list = new ArrayList<>( artifacts.size() ); for ( Artifact a : getArtifacts() ) { // TODO let the scope handler deal with this if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) { Dependency dependency = new Dependency(); dependency.setArtifactId( a.getArtifactId() ); dependency.setGroupId( a.getGroupId() ); dependency.setVersion( a.getVersion() ); dependency.setScope( a.getScope() ); dependency.setType( a.getType() ); dependency.setClassifier( a.getClassifier() ); list.add( dependency ); } } return Collections.unmodifiableList( list ); }
private Dependency createSystemScopeDependency( Artifact artifact, File location, String suffix ) { String artifactId = artifact.getArtifactId(); if ( suffix != null ) { artifactId += "_" + suffix; } final Dependency dependency = new Dependency(); dependency.setGroupId( artifact.getGroupId() ); dependency.setArtifactId( artifactId ); dependency.setVersion( artifact.getBaseVersion() ); dependency.setScope( Artifact.SCOPE_SYSTEM ); dependency.setSystemPath( location.getAbsolutePath() ); return dependency; }
protected void mergeDependency_Scope( Dependency target, Dependency source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getScope(); if ( src != null ) { if ( sourceDominant || target.getScope() == null ) { target.setScope( src ); target.setLocation( "scope", source.getLocation( "scope" ) ); } } }
d.setScope( scope );
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; }
private void mergeDependencyWithDefaults( Dependency dep, Dependency def ) { if ( dep.getScope() == null && def.getScope() != null ) { dep.setScope( def.getScope() ); dep.setSystemPath( def.getSystemPath() ); } if ( dep.getVersion() == null && def.getVersion() != null ) { dep.setVersion( def.getVersion() ); } if ( dep.getClassifier() == null && def.getClassifier() != null ) { dep.setClassifier( def.getClassifier() ); } if ( dep.getType() == null && def.getType() != null ) { dep.setType( def.getType() ); } List exclusions = dep.getExclusions(); if ( exclusions == null || exclusions.isEmpty() ) { dep.setExclusions( def.getExclusions() ); } }
dependency.setScope( interpolatedTrimmed( parser.nextText(), "scope" ) );
public static Dependency createDependency(String scalar, Dependency dependency) { Matcher matcher = ModelResolver.DEPENDENCY_PATTERN.matcher(scalar); if (matcher.matches()) { //scope and version are present String version = matcher.group("version"); dependency.setVersion(version); String scope = matcher.group("scope"); dependency.setScope(scope); } else { matcher = ModelResolver.COORDINATE_PATTERN.matcher(scalar); //version is present if (matcher.matches()) { String version = matcher.group("version"); dependency.setVersion(version); } else { matcher = ModelResolver.GROUP_NAME_PATTERN.matcher(scalar); if (!matcher.matches()) { throw new IllegalArgumentException("Unexpected node: " + scalar); } } } //groupId and artifactId are always present String groupId = matcher.group("groupId"); String artifactId = matcher.group("artifactId"); dependency.setGroupId(groupId); dependency.setArtifactId(artifactId); return dependency; } }
public default Dependency dependency(String definition, String scope) { Dependency dependency = new Dependency(); String[] parts = definition.split(":"); dependency.setGroupId(parts[0]); dependency.setArtifactId(parts[1]); if (parts.length > 2) { dependency.setVersion(parts[3]); } if (scope != null) { dependency.setScope(scope); } return dependency; }
dependency.setScope( interpolatedTrimmed( parser.nextText(), "scope" ) );
public static Dependency parse(final Object value) { assert value != null; if (value instanceof String) { Dependency node = new Dependency(); String[] items = ((String) value).split(":"); switch (items.length) { case 4: node.setGroupId(items[0]); node.setArtifactId(items[1]); node.setVersion(items[2]); node.setScope(items[3]); return node; case 3: node.setGroupId(items[0]); node.setArtifactId(items[1]); node.setVersion(items[2]); return node; case 2: node.setGroupId(items[0]); node.setArtifactId(items[1]); return node; } } return null; } }
/** * Creates a {@link Dependency} object from this artifact with scope compile. * * @return a maven */ public Dependency getAsMavenDependency() { Dependency dependency = new Dependency(); dependency.setVersion(getVersion()); dependency.setGroupId(getGroupId()); dependency.setArtifactId(getArtifactId()); dependency.setClassifier(getClassifier()); dependency.setType(getType()); dependency.setScope(COMPILE_SCOPE); return dependency; }