Skip to content
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
target/
.bsp/
.metals/
.vscode/
36 changes: 17 additions & 19 deletions interface/src/main/java/coursierapi/Dependency.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ public final class Dependency implements Serializable {
private String version;
private final Set<Map.Entry<String, String>> exclusions;
private String configuration;
private String type;
private String classifier;
private Publication publication;
private boolean transitive;

Expand All @@ -22,8 +20,6 @@ private Dependency(Module module, String version) {
this.version = version;
this.exclusions = new HashSet<>();
this.configuration = "";
this.type = "";
this.classifier = "";
this.publication = null;
this.transitive = true;
}
Expand Down Expand Up @@ -76,12 +72,22 @@ public Dependency withConfiguration(String configuration) {
}

public Dependency withType(String type) {
this.type = type;
if (publication == null)
publication = new Publication("", type, "", "");
else
publication = publication.withType(type);
if (publication.isEmpty())
publication = null;
return this;
}

public Dependency withClassifier(String classifier) {
this.classifier = classifier;
if (publication == null)
publication = new Publication("", "", "", classifier);
else
publication = publication.withClassifier(classifier);
if (publication.isEmpty())
publication = null;
return this;
}

Expand All @@ -105,8 +111,6 @@ public boolean equals(Object obj) {
this.version.equals(other.version) &&
this.exclusions.equals(other.exclusions) &&
this.configuration.equals(other.configuration) &&
this.type.equals(other.type) &&
this.classifier.equals(other.classifier) &&
Objects.equals(this.publication, other.publication) &&
this.transitive == other.transitive;
}
Expand All @@ -115,7 +119,7 @@ public boolean equals(Object obj) {

@Override
public int hashCode() {
return 37 * (37 * (37 * (37 * (37 * (37 * (37 * (17 + module.hashCode()) + version.hashCode()) + exclusions.hashCode()) + configuration.hashCode()) + type.hashCode()) + classifier.hashCode()) + Objects.hashCode(publication)) + Boolean.hashCode(transitive);
return 37 * (37 * (37 * (37 * (37 * (17 + module.hashCode()) + version.hashCode()) + exclusions.hashCode()) + configuration.hashCode()) + Objects.hashCode(publication)) + Boolean.hashCode(transitive);
}

@Override
Expand All @@ -136,14 +140,6 @@ public String toString() {
b.append(", configuration=");
b.append(configuration);
}
if (!type.isEmpty()) {
b.append(", type=");
b.append(type);
}
if (!classifier.isEmpty()) {
b.append(", classifier=");
b.append(classifier);
}
if (publication != null) {
b.append(", publication=");
b.append(publication);
Expand Down Expand Up @@ -173,11 +169,13 @@ public String getConfiguration() {
}

public String getType() {
return type;
if (publication == null) return "";
return publication.getType();
}

public String getClassifier() {
return classifier;
if (publication == null) return "";
return publication.getClassifier();
}

public Publication getPublication() {
Expand Down
20 changes: 20 additions & 0 deletions interface/src/main/java/coursierapi/Publication.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,26 @@ public String getClassifier() {
return classifier;
}

public Publication withName(String updatedName) {
return new Publication(updatedName, this.type, this.extension, this.classifier);
}

public Publication withType(String updatedType) {
return new Publication(this.name, updatedType, this.extension, this.classifier);
}

public Publication withExtension(String updatedExtension) {
return new Publication(this.name, this.type, updatedExtension, this.classifier);
}

public Publication withClassifier(String updatedClassifier) {
return new Publication(this.name, this.type, this.extension, updatedClassifier);
}

public boolean isEmpty() {
return name.isEmpty() && type.isEmpty() && extension.isEmpty() && classifier.isEmpty();
}

@Override
public boolean equals(Object o) {
if (this == o)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,10 @@ object ApiHelper {
.map(e => (Organization(e.getKey), ModuleName(e.getValue)))
.toSet
val configuration = Configuration(dep.getConfiguration)
val tpe = Type(dep.getType)
val classifier = Classifier(dep.getClassifier)

val dep0 = Dependency(module0, dep.getVersion)
.withExclusions(exclusions)
.withConfiguration(configuration)
.withAttributes(Attributes(tpe, classifier))
.withTransitive(dep.isTransitive)

Option(dep.getPublication)
Expand Down