mirror of https://github.com/apache/maven.git
Remove empty dependency scope from the api (#1402)
This commit is contained in:
parent
76794c0237
commit
c813320848
|
@ -49,9 +49,12 @@ public enum DependencyScope {
|
||||||
NONE("none", false),
|
NONE("none", false),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty scope.
|
* Undefined. When no scope is explicitly given, UNDEFINED will be used, but its meaning will depend on
|
||||||
|
* whether the DependencyCoordinate is used in dependency management, in which case it means the scope is not
|
||||||
|
* explicitly managed by this managed dependency, or as a real dependency, in which case, the scope
|
||||||
|
* will default to {@link #COMPILE}.
|
||||||
*/
|
*/
|
||||||
EMPTY("", false),
|
UNDEFINED("", false),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile only.
|
* Compile only.
|
||||||
|
|
|
@ -55,18 +55,16 @@ public interface PathScope extends ExtensibleEnum {
|
||||||
PathScope MAIN_COMPILE = pathScope(
|
PathScope MAIN_COMPILE = pathScope(
|
||||||
"main-compile",
|
"main-compile",
|
||||||
ProjectScope.MAIN,
|
ProjectScope.MAIN,
|
||||||
DependencyScope.EMPTY,
|
|
||||||
DependencyScope.COMPILE_ONLY,
|
DependencyScope.COMPILE_ONLY,
|
||||||
DependencyScope.COMPILE,
|
DependencyScope.COMPILE,
|
||||||
DependencyScope.PROVIDED);
|
DependencyScope.PROVIDED);
|
||||||
|
|
||||||
PathScope MAIN_RUNTIME = pathScope(
|
PathScope MAIN_RUNTIME =
|
||||||
"main-runtime", ProjectScope.MAIN, DependencyScope.EMPTY, DependencyScope.COMPILE, DependencyScope.RUNTIME);
|
pathScope("main-runtime", ProjectScope.MAIN, DependencyScope.COMPILE, DependencyScope.RUNTIME);
|
||||||
|
|
||||||
PathScope TEST_COMPILE = pathScope(
|
PathScope TEST_COMPILE = pathScope(
|
||||||
"test-compile",
|
"test-compile",
|
||||||
ProjectScope.TEST,
|
ProjectScope.TEST,
|
||||||
DependencyScope.EMPTY,
|
|
||||||
DependencyScope.COMPILE,
|
DependencyScope.COMPILE,
|
||||||
DependencyScope.PROVIDED,
|
DependencyScope.PROVIDED,
|
||||||
DependencyScope.TEST_ONLY,
|
DependencyScope.TEST_ONLY,
|
||||||
|
@ -75,7 +73,6 @@ public interface PathScope extends ExtensibleEnum {
|
||||||
PathScope TEST_RUNTIME = pathScope(
|
PathScope TEST_RUNTIME = pathScope(
|
||||||
"test-runtime",
|
"test-runtime",
|
||||||
ProjectScope.TEST,
|
ProjectScope.TEST,
|
||||||
DependencyScope.EMPTY,
|
|
||||||
DependencyScope.COMPILE,
|
DependencyScope.COMPILE,
|
||||||
DependencyScope.RUNTIME,
|
DependencyScope.RUNTIME,
|
||||||
DependencyScope.PROVIDED,
|
DependencyScope.PROVIDED,
|
||||||
|
|
|
@ -111,11 +111,12 @@ public abstract class AbstractSession implements InternalSession {
|
||||||
|
|
||||||
public abstract ArtifactRepository toArtifactRepository(RemoteRepository repository);
|
public abstract ArtifactRepository toArtifactRepository(RemoteRepository repository);
|
||||||
|
|
||||||
public List<org.eclipse.aether.graph.Dependency> toDependencies(Collection<DependencyCoordinate> dependencies) {
|
public List<org.eclipse.aether.graph.Dependency> toDependencies(
|
||||||
return dependencies == null ? null : map(dependencies, this::toDependency);
|
Collection<DependencyCoordinate> dependencies, boolean managed) {
|
||||||
|
return dependencies == null ? null : map(dependencies, d -> toDependency(d, managed));
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract org.eclipse.aether.graph.Dependency toDependency(DependencyCoordinate dependency);
|
public abstract org.eclipse.aether.graph.Dependency toDependency(DependencyCoordinate dependency, boolean managed);
|
||||||
|
|
||||||
public List<org.eclipse.aether.artifact.Artifact> toArtifacts(Collection<Artifact> artifacts) {
|
public List<org.eclipse.aether.artifact.Artifact> toArtifacts(Collection<Artifact> artifacts) {
|
||||||
return artifacts == null ? null : map(artifacts, this::toArtifact);
|
return artifacts == null ? null : map(artifacts, this::toArtifact);
|
||||||
|
|
|
@ -54,12 +54,13 @@ public class DefaultDependencyCollector implements DependencyCollector {
|
||||||
|
|
||||||
Artifact rootArtifact =
|
Artifact rootArtifact =
|
||||||
request.getRootArtifact().map(session::toArtifact).orElse(null);
|
request.getRootArtifact().map(session::toArtifact).orElse(null);
|
||||||
Dependency root = request.getRoot().map(session::toDependency).orElse(null);
|
Dependency root =
|
||||||
|
request.getRoot().map(d -> session.toDependency(d, false)).orElse(null);
|
||||||
CollectRequest collectRequest = new CollectRequest()
|
CollectRequest collectRequest = new CollectRequest()
|
||||||
.setRootArtifact(rootArtifact)
|
.setRootArtifact(rootArtifact)
|
||||||
.setRoot(root)
|
.setRoot(root)
|
||||||
.setDependencies(session.toDependencies(request.getDependencies()))
|
.setDependencies(session.toDependencies(request.getDependencies(), false))
|
||||||
.setManagedDependencies(session.toDependencies(request.getManagedDependencies()))
|
.setManagedDependencies(session.toDependencies(request.getManagedDependencies(), true))
|
||||||
.setRepositories(session.toRepositories(session.getRemoteRepositories()));
|
.setRepositories(session.toRepositories(session.getRemoteRepositories()));
|
||||||
|
|
||||||
RepositorySystemSession systemSession = session.getSession();
|
RepositorySystemSession systemSession = session.getSession();
|
||||||
|
|
|
@ -280,11 +280,12 @@ public class DefaultSession extends AbstractSession {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public org.eclipse.aether.graph.Dependency toDependency(DependencyCoordinate dependency) {
|
public org.eclipse.aether.graph.Dependency toDependency(DependencyCoordinate dependency, boolean managed) {
|
||||||
|
org.eclipse.aether.graph.Dependency dep;
|
||||||
if (dependency instanceof DefaultDependencyCoordinate) {
|
if (dependency instanceof DefaultDependencyCoordinate) {
|
||||||
return ((DefaultDependencyCoordinate) dependency).getDependency();
|
dep = ((DefaultDependencyCoordinate) dependency).getDependency();
|
||||||
} else {
|
} else {
|
||||||
return new org.eclipse.aether.graph.Dependency(
|
dep = new org.eclipse.aether.graph.Dependency(
|
||||||
new org.eclipse.aether.artifact.DefaultArtifact(
|
new org.eclipse.aether.artifact.DefaultArtifact(
|
||||||
dependency.getGroupId(),
|
dependency.getGroupId(),
|
||||||
dependency.getArtifactId(),
|
dependency.getArtifactId(),
|
||||||
|
@ -294,5 +295,9 @@ public class DefaultSession extends AbstractSession {
|
||||||
null),
|
null),
|
||||||
dependency.getScope().id());
|
dependency.getScope().id());
|
||||||
}
|
}
|
||||||
|
if (!managed && "".equals(dep.getScope())) {
|
||||||
|
dep = dep.setScope(DependencyScope.COMPILE.id());
|
||||||
|
}
|
||||||
|
return dep;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,9 +70,10 @@ public interface InternalSession extends Session {
|
||||||
|
|
||||||
org.apache.maven.artifact.repository.ArtifactRepository toArtifactRepository(RemoteRepository repository);
|
org.apache.maven.artifact.repository.ArtifactRepository toArtifactRepository(RemoteRepository repository);
|
||||||
|
|
||||||
List<org.eclipse.aether.graph.Dependency> toDependencies(Collection<DependencyCoordinate> dependencies);
|
List<org.eclipse.aether.graph.Dependency> toDependencies(
|
||||||
|
Collection<DependencyCoordinate> dependencies, boolean managed);
|
||||||
|
|
||||||
org.eclipse.aether.graph.Dependency toDependency(DependencyCoordinate dependency);
|
org.eclipse.aether.graph.Dependency toDependency(DependencyCoordinate dependency, boolean managed);
|
||||||
|
|
||||||
List<org.eclipse.aether.artifact.Artifact> toArtifacts(Collection<Artifact> artifacts);
|
List<org.eclipse.aether.artifact.Artifact> toArtifacts(Collection<Artifact> artifacts);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue