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),
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
|
|
@ -55,18 +55,16 @@ public interface PathScope extends ExtensibleEnum {
|
|||
PathScope MAIN_COMPILE = pathScope(
|
||||
"main-compile",
|
||||
ProjectScope.MAIN,
|
||||
DependencyScope.EMPTY,
|
||||
DependencyScope.COMPILE_ONLY,
|
||||
DependencyScope.COMPILE,
|
||||
DependencyScope.PROVIDED);
|
||||
|
||||
PathScope MAIN_RUNTIME = pathScope(
|
||||
"main-runtime", ProjectScope.MAIN, DependencyScope.EMPTY, DependencyScope.COMPILE, DependencyScope.RUNTIME);
|
||||
PathScope MAIN_RUNTIME =
|
||||
pathScope("main-runtime", ProjectScope.MAIN, DependencyScope.COMPILE, DependencyScope.RUNTIME);
|
||||
|
||||
PathScope TEST_COMPILE = pathScope(
|
||||
"test-compile",
|
||||
ProjectScope.TEST,
|
||||
DependencyScope.EMPTY,
|
||||
DependencyScope.COMPILE,
|
||||
DependencyScope.PROVIDED,
|
||||
DependencyScope.TEST_ONLY,
|
||||
|
@ -75,7 +73,6 @@ public interface PathScope extends ExtensibleEnum {
|
|||
PathScope TEST_RUNTIME = pathScope(
|
||||
"test-runtime",
|
||||
ProjectScope.TEST,
|
||||
DependencyScope.EMPTY,
|
||||
DependencyScope.COMPILE,
|
||||
DependencyScope.RUNTIME,
|
||||
DependencyScope.PROVIDED,
|
||||
|
|
|
@ -111,11 +111,12 @@ public abstract class AbstractSession implements InternalSession {
|
|||
|
||||
public abstract ArtifactRepository toArtifactRepository(RemoteRepository repository);
|
||||
|
||||
public List<org.eclipse.aether.graph.Dependency> toDependencies(Collection<DependencyCoordinate> dependencies) {
|
||||
return dependencies == null ? null : map(dependencies, this::toDependency);
|
||||
public List<org.eclipse.aether.graph.Dependency> toDependencies(
|
||||
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) {
|
||||
return artifacts == null ? null : map(artifacts, this::toArtifact);
|
||||
|
|
|
@ -54,12 +54,13 @@ public class DefaultDependencyCollector implements DependencyCollector {
|
|||
|
||||
Artifact rootArtifact =
|
||||
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()
|
||||
.setRootArtifact(rootArtifact)
|
||||
.setRoot(root)
|
||||
.setDependencies(session.toDependencies(request.getDependencies()))
|
||||
.setManagedDependencies(session.toDependencies(request.getManagedDependencies()))
|
||||
.setDependencies(session.toDependencies(request.getDependencies(), false))
|
||||
.setManagedDependencies(session.toDependencies(request.getManagedDependencies(), true))
|
||||
.setRepositories(session.toRepositories(session.getRemoteRepositories()));
|
||||
|
||||
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) {
|
||||
return ((DefaultDependencyCoordinate) dependency).getDependency();
|
||||
dep = ((DefaultDependencyCoordinate) dependency).getDependency();
|
||||
} else {
|
||||
return new org.eclipse.aether.graph.Dependency(
|
||||
dep = new org.eclipse.aether.graph.Dependency(
|
||||
new org.eclipse.aether.artifact.DefaultArtifact(
|
||||
dependency.getGroupId(),
|
||||
dependency.getArtifactId(),
|
||||
|
@ -294,5 +295,9 @@ public class DefaultSession extends AbstractSession {
|
|||
null),
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue