From db28096fecbdebe596be2d6c01769e6428329d19 Mon Sep 17 00:00:00 2001 From: Yahav Itschak Date: Mon, 17 Jun 2024 09:31:14 +0300 Subject: [PATCH] Remove commons-collections and use Multimap from build-info (#116) --- build.gradle.kts | 4 +--- .../gradle/plugin/artifactory/task/ArtifactoryTask.java | 8 ++++---- .../gradle/plugin/artifactory/utils/PublicationUtils.java | 6 +++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index c79aa09..01021a4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,9 +15,8 @@ repositories { mavenCentral() } -val buildInfoVersion = "2.41.18" +val buildInfoVersion = "2.41.21" val fileSpecsVersion = "1.1.2" -val commonsCollections4Version = "4.4" val commonsLangVersion = "3.12.0" val commonsIoVersion = "2.11.0" val commonsTxtVersion = "1.10.0" @@ -41,7 +40,6 @@ dependencies { api("org.jfrog.buildinfo", "build-info-client", buildInfoVersion) api("org.jfrog.filespecs", "file-specs-java", fileSpecsVersion) - implementation("org.apache.commons", "commons-collections4", commonsCollections4Version) implementation("org.apache.commons", "commons-lang3", commonsLangVersion) implementation("org.apache.ivy", "ivy", "2.5.2") diff --git a/src/main/java/org/jfrog/gradle/plugin/artifactory/task/ArtifactoryTask.java b/src/main/java/org/jfrog/gradle/plugin/artifactory/task/ArtifactoryTask.java index 0db9e56..53d880b 100644 --- a/src/main/java/org/jfrog/gradle/plugin/artifactory/task/ArtifactoryTask.java +++ b/src/main/java/org/jfrog/gradle/plugin/artifactory/task/ArtifactoryTask.java @@ -1,8 +1,6 @@ package org.jfrog.gradle.plugin.artifactory.task; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; -import org.apache.commons.collections4.MultiMapUtils; -import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.lang3.StringUtils; import org.gradle.api.*; import org.gradle.api.artifacts.Configuration; @@ -20,6 +18,8 @@ import org.gradle.api.tasks.Optional; import org.gradle.api.tasks.*; import org.jfrog.build.api.builder.ModuleType; +import org.jfrog.build.api.multiMap.Multimap; +import org.jfrog.build.api.multiMap.SetMultimap; import org.jfrog.build.extractor.clientConfiguration.ArtifactSpecs; import org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration; import org.jfrog.gradle.plugin.artifactory.Constant; @@ -51,7 +51,7 @@ public class ArtifactoryTask extends DefaultTask { // Publication containers input private final Set publications = new HashSet<>(); // Properties input - private final MultiValuedMap properties = MultiMapUtils.newSetValuedHashMap(); + private final Multimap properties = new SetMultimap<>(); @Input public final ArtifactSpecs artifactSpecs = new ArtifactSpecs(); @@ -394,7 +394,7 @@ public Set getPublications() { } @Input - public MultiValuedMap getProperties() { + public Multimap getProperties() { return properties; } diff --git a/src/main/java/org/jfrog/gradle/plugin/artifactory/utils/PublicationUtils.java b/src/main/java/org/jfrog/gradle/plugin/artifactory/utils/PublicationUtils.java index 522f9f3..88d420e 100644 --- a/src/main/java/org/jfrog/gradle/plugin/artifactory/utils/PublicationUtils.java +++ b/src/main/java/org/jfrog/gradle/plugin/artifactory/utils/PublicationUtils.java @@ -1,6 +1,5 @@ package org.jfrog.gradle.plugin.artifactory.utils; -import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.lang3.StringUtils; import org.apache.ivy.core.IvyPatternHelper; import org.gradle.api.GradleException; @@ -14,6 +13,7 @@ import org.gradle.api.publish.ivy.plugins.IvyPublishPlugin; import org.gradle.api.publish.maven.MavenPublication; import org.gradle.api.publish.maven.plugins.MavenPublishPlugin; +import org.jfrog.build.api.multiMap.Multimap; import org.jfrog.build.api.util.FileChecksumCalculator; import org.jfrog.build.extractor.clientConfiguration.ArtifactSpec; import org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration; @@ -201,12 +201,12 @@ private static Map getPropsToAdd(ArtifactoryTask destination, Pu .name(project.getName()).version(project.getVersion().toString()) .classifier(artifact.getClassifier()) .type(artifact.getType()).build(); - MultiValuedMap artifactSpecsProperties = destination.artifactSpecs.getProperties(spec); + Multimap artifactSpecsProperties = destination.artifactSpecs.getProperties(spec); addProps(propsToAdd, artifactSpecsProperties); return propsToAdd; } - public static void addProps(Map target, MultiValuedMap props) { + public static void addProps(Map target, Multimap props) { for (Map.Entry entry : props.entries()) { // Make sure all GString are now Java Strings String key = entry.getKey();