Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove empty dependency scope from the api #1402

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ public List<ArtifactRepository> toArtifactRepositories(List<RemoteRepository> re

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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ public DependencyCollectorResult collect(@Nonnull DependencyCollectorRequest req

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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,12 @@ public ArtifactRepository toArtifactRepository(RemoteRepository repository) {
}
}

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(),
Expand All @@ -294,5 +295,9 @@ public org.eclipse.aether.graph.Dependency toDependency(DependencyCoordinate dep
null),
dependency.getScope().id());
}
if (!managed && "".equals(dep.getScope())) {
dep = dep.setScope(DependencyScope.COMPILE.id());
}
return dep;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ List<org.apache.maven.artifact.repository.ArtifactRepository> toArtifactReposito

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);

Expand Down
Loading