Skip to content

Commit

Permalink
Merge pull request #173 from ppalaga/220105-scope
Browse files Browse the repository at this point in the history
Allow DependencySpecs with a custom scope
  • Loading branch information
aloubyansky authored Jan 5, 2023
2 parents 741aa6a + 90c6348 commit 9f384b5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ public List<Dependency> toAetherDependencies() {
final ArtifactKey key = ArtifactKey.fromString(e);
exclusions.add(new Exclusion(key.getGroupId(), key.getArtifactId(), key.getClassifier(), key.getType()));
}
String scope = dep.getScope();
if (scope == null || scope.isEmpty()) {
scope = "compile";
}
result.add(new Dependency(new DefaultArtifact(coords.getGroupId(),
coords.getArtifactId(), coords.getClassifier(), coords.getType(), coords.getVersion()), "compile", null,
coords.getArtifactId(), coords.getClassifier(), coords.getType(), coords.getVersion()), scope, null,
exclusions));
}
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
public class DependencySpec {

private String artifact;
private String scope;
private List<String> exclusions = Collections.emptyList();

public String getArtifact() {
Expand All @@ -16,6 +17,14 @@ public void setArtifact(String artifact) {
this.artifact = artifact;
}

public String getScope() {
return scope;
}

public void setScope(String scope) {
this.scope = scope;
}

public List<String> getExclusions() {
return exclusions;
}
Expand All @@ -26,13 +35,19 @@ public void setExclusions(List<String> exclusions) {

@Override
public String toString() {
if (exclusions.isEmpty()) {
if (exclusions.isEmpty() && (scope == null || scope.isEmpty())) {
return artifact;
}
final StringBuilder s = new StringBuilder();
s.append(artifact).append(" exclusions: ").append(exclusions.get(0));
for (int i = 1; i < exclusions.size(); ++i) {
s.append(',').append(exclusions.get(i));
s.append(artifact);
if (scope != null && !scope.isEmpty()) {
s.append('(').append(scope).append(')');
}
if (!exclusions.isEmpty()) {
s.append(" exclusions: ").append(exclusions.get(0));
for (int i = 1; i < exclusions.size(); ++i) {
s.append(',').append(exclusions.get(i));
}
}
return s.toString();
}
Expand Down

0 comments on commit 9f384b5

Please sign in to comment.