Skip to content

Commit

Permalink
Removed the unnecessary duplicated properties in ArtifactAssociation.…
Browse files Browse the repository at this point in the history
… Removed deprecated StringUtils from Plexus in SetMojo.
  • Loading branch information
jarmoniuk committed Feb 26, 2024
1 parent ecd15b0 commit 80bc644
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
* @since 1.0-alpha-3
*/
public interface ArtifactAssociation extends Comparable<ArtifactAssociation> {
String getGroupId();

String getArtifactId();

boolean isUsePluginRepositories();

Artifact getArtifact();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,6 @@ final class DefaultArtifactAssociation implements ArtifactAssociation {
this.usePluginRepositories = usePluginRepositories;
}

public String getGroupId() {
return artifact.getGroupId();
}

public String getArtifactId() {
return artifact.getArtifactId();
}

public Artifact getArtifact() {
return artifact;
}
Expand All @@ -66,11 +58,11 @@ public int compareTo(ArtifactAssociation o) {
}
DefaultArtifactAssociation that = (DefaultArtifactAssociation) o;

int rv = getGroupId().compareTo(that.getGroupId());
int rv = getArtifact().getGroupId().compareTo(that.getArtifact().getGroupId());
if (rv != 0) {
return rv;
}
rv = getArtifactId().compareTo(that.getArtifactId());
rv = getArtifact().getArtifactId().compareTo(that.getArtifact().getArtifactId());
if (rv != 0) {
return rv;
}
Expand All @@ -93,15 +85,15 @@ public boolean equals(Object o) {
if (usePluginRepositories != that.usePluginRepositories) {
return false;
}
if (!getArtifactId().equals(that.getArtifactId())) {
if (!getArtifact().getArtifactId().equals(that.getArtifact().getArtifactId())) {
return false;
}
return getGroupId().equals(that.getGroupId());
return getArtifact().getGroupId().equals(that.getArtifact().getGroupId());
}

public int hashCode() {
int result = getGroupId().hashCode();
result = 31 * result + getArtifactId().hashCode();
int result = getArtifact().getGroupId().hashCode();
result = 31 * result + getArtifact().getArtifactId().hashCode();
result = 31 * result + (usePluginRepositories ? 1 : 0);
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -636,14 +636,14 @@ public Map<Property, PropertyVersions> getVersionPropertiesMap(VersionProperties
}

for (PropertyVersionsBuilder propertyVersionsBuilder : propertyVersionsBuilders) {
final String name = propertyVersionsBuilder.getName();
builders.put(name, propertyVersionsBuilder);
if (!properties.containsKey(name)) {
final Property value = new Property(name);
getLog().debug("Property ${" + name + "}: Adding inferred version range of "
final String propertyName = propertyVersionsBuilder.getName();
builders.put(propertyName, propertyVersionsBuilder);
if (!properties.containsKey(propertyName)) {
final Property property = new Property(propertyName);
getLog().debug("Property ${" + propertyName + "}: Adding inferred version range of "
+ propertyVersionsBuilder.getVersionRange());
value.setVersion(propertyVersionsBuilder.getVersionRange());
properties.put(name, value);
property.setVersion(propertyVersionsBuilder.getVersionRange());
properties.put(propertyName, property);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ public ArtifactVersion[] getVersions(Collection<Artifact> artifacts) {
// see if the version is available for all associations
for (ArtifactAssociation association : associations) {
for (Artifact artifact : artifacts) {
if (association.getGroupId().equals(artifact.getGroupId())
&& association.getArtifactId().equals(artifact.getArtifactId())) {
if (association.getArtifact().getGroupId().equals(artifact.getGroupId())
&& association.getArtifact().getArtifactId().equals(artifact.getArtifactId())) {
try {
result.add(artifact.getSelectedVersion());
} catch (OverConstrainedVersionException e) {
Expand All @@ -173,8 +173,8 @@ public ArtifactVersion[] getVersions(Collection<Artifact> artifacts) {
associations:
for (ArtifactAssociation association : associations) {
for (Artifact artifact : artifacts) {
if (association.getGroupId().equals(artifact.getGroupId())
&& association.getArtifactId().equals(artifact.getArtifactId())) {
if (association.getArtifact().getGroupId().equals(artifact.getGroupId())
&& association.getArtifact().getArtifactId().equals(artifact.getArtifactId())) {
try {
if (candidate
.toString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import java.util.TreeMap;
import java.util.regex.Pattern;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.maven.artifact.ArtifactUtils;
Expand All @@ -63,9 +64,8 @@
import org.codehaus.mojo.versions.utils.RegexUtils;
import org.codehaus.plexus.components.interactivity.Prompter;
import org.codehaus.plexus.components.interactivity.PrompterException;
import org.codehaus.plexus.util.StringUtils;

import static org.codehaus.plexus.util.StringUtils.isEmpty;
import static org.apache.commons.lang.StringUtils.isEmpty;

/**
* Sets the current project's version and based on that change propagates that change onto any child modules as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ private static List<PropertyInfo> createPropertyInfo(
setPropertyAssociations(Arrays.stream(e.getValue().getAssociations())
.map(a -> {
PropertyAssociation pa = new PropertyAssociation();
pa.setGroupId(a.getGroupId());
pa.setArtifactId(a.getArtifactId());
pa.setGroupId(a.getArtifact().getGroupId());
pa.setArtifactId(a.getArtifact().getArtifactId());
return pa;
})
.collect(Collectors.toList()));
Expand Down

0 comments on commit 80bc644

Please sign in to comment.