From 4053751b97f6fc07c985889d1e17c2d6a143cb63 Mon Sep 17 00:00:00 2001 From: yahavi Date: Fri, 7 Jun 2024 20:15:55 +0300 Subject: [PATCH] Remove Guava --- .../client/DeployableArtifactDetail.java | 2 - .../docker/extractor/BuildDockerCreator.java | 13 +- .../docker/extractor/DockerPush.java | 15 +- .../docker/extractor/DockerExtractorTest.java | 22 +-- .../extractor/go/extractor/GoPublish.java | 11 +- .../go/extractor/GoZipBallStreamer.java | 6 +- .../build/extractor/go/GoDriverTest.java | 2 +- .../go/extractor/GoDependencyTreeTest.java | 2 +- .../go/extractor/GoExtractorTest.java | 9 +- .../extractor/GradleModuleExtractor.java | 34 ++--- .../artifactory/task/ArtifactoryTask.java | 8 +- .../artifactory/task/helper/TaskHelper.java | 6 +- .../extractor/npm/extractor/NpmPublish.java | 17 ++- .../npm/extractor/NpmExtractorTest.java | 27 ++-- .../build/extractor/ModuleExtractorUtils.java | 60 +------- .../clientConfiguration/ArtifactSpecs.java | 8 +- .../ArtifactoryClientConfiguration.java | 137 ++---------------- .../artifactory/ArtifactoryManager.java | 8 +- .../artifactory/services/SetProperties.java | 13 +- .../deploy/DeployDetails.java | 31 ++-- .../util/DependenciesDownloaderHelper.java | 11 +- .../util/DeploymentUrlUtils.java | 4 +- .../util/PublishedItemsHelper.java | 14 +- .../spec/SingleSpecDeploymentProducer.java | 26 ++-- .../util/spec/SpecDeploymentProducer.java | 7 +- .../util/spec/SpecsHelper.java | 24 ++- .../util/spec/UploadSpecHelper.java | 16 +- .../extractor/executor/CommandExecutor.java | 3 +- .../org/jfrog/build/extractor/scan/Issue.java | 3 +- .../extractor/client/ArtifactSpecTest.java | 46 +++--- .../client/DeploymentUrlUtilsTest.java | 5 +- .../executor/CommandExecutorTest.java | 4 +- .../util/PublishedItemsHelperTest.java | 36 ++--- build-info-parent/pom.xml | 6 - build.gradle | 4 +- 35 files changed, 243 insertions(+), 397 deletions(-) diff --git a/build-info-client/src/main/java/org/jfrog/build/client/DeployableArtifactDetail.java b/build-info-client/src/main/java/org/jfrog/build/client/DeployableArtifactDetail.java index 2502f15f9..ab9489c5a 100644 --- a/build-info-client/src/main/java/org/jfrog/build/client/DeployableArtifactDetail.java +++ b/build-info-client/src/main/java/org/jfrog/build/client/DeployableArtifactDetail.java @@ -1,7 +1,5 @@ package org.jfrog.build.client; -import com.google.common.collect.ArrayListMultimap; - import java.io.Serializable; import java.util.Collection; import java.util.Map; diff --git a/build-info-extractor-docker/src/main/java/org/jfrog/build/extractor/docker/extractor/BuildDockerCreator.java b/build-info-extractor-docker/src/main/java/org/jfrog/build/extractor/docker/extractor/BuildDockerCreator.java index 4641f446e..a514fb1cc 100644 --- a/build-info-extractor-docker/src/main/java/org/jfrog/build/extractor/docker/extractor/BuildDockerCreator.java +++ b/build-info-extractor-docker/src/main/java/org/jfrog/build/extractor/docker/extractor/BuildDockerCreator.java @@ -2,12 +2,13 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.collect.ArrayListMultimap; +import org.apache.commons.collections4.MultiValuedMap; +import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; +import org.jfrog.build.api.util.Log; import org.jfrog.build.extractor.ci.BuildInfo; import org.jfrog.build.extractor.ci.Module; -import org.jfrog.build.api.util.Log; import org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration; import org.jfrog.build.extractor.clientConfiguration.ArtifactoryManagerBuilder; import org.jfrog.build.extractor.clientConfiguration.client.artifactory.ArtifactoryManager; @@ -34,7 +35,7 @@ import static org.jfrog.build.extractor.packageManager.PackageManagerUtils.createArtifactoryClientConfiguration; public class BuildDockerCreator extends PackageManagerExtractor { - private final ArrayListMultimap artifactProperties; + private final MultiValuedMap artifactProperties; private final ArtifactoryManagerBuilder artifactoryManagerBuilder; private final ImageFileType imageFileType; private final String sourceRepo; @@ -55,7 +56,7 @@ enum ImageFileType { * @param artifactProperties - Properties to be attached to the docker layers deployed to Artifactory. */ public BuildDockerCreator(ArtifactoryManagerBuilder artifactoryManagerBuilder, String imageFile, ImageFileType imageFileType, - ArrayListMultimap artifactProperties, String sourceRepo, Log logger) { + MultiValuedMap artifactProperties, String sourceRepo, Log logger) { this.artifactoryManagerBuilder = artifactoryManagerBuilder; this.artifactProperties = artifactProperties; this.sourceRepo = sourceRepo; @@ -91,7 +92,7 @@ public static void main(String[] ignored) { BuildDockerCreator dockerBuildCreate = new BuildDockerCreator(artifactoryManagerBuilder, imageFile, imageFileType, - ArrayListMultimap.create(clientConfiguration.publisher.getMatrixParams().asMultimap()), + new ArrayListValuedHashMap<>(clientConfiguration.publisher.getMatrixParams()), clientConfiguration.publisher.getRepoKey(), clientConfiguration.getLog()); @@ -136,7 +137,7 @@ public BuildInfo execute() { /** * Update each layer's properties with artifactProperties. */ - private void setImageLayersProps(DockerLayers layers, ArrayListMultimap artifactProperties, ArtifactoryManagerBuilder artifactoryManagerBuilder) throws IOException { + private void setImageLayersProps(DockerLayers layers, MultiValuedMap artifactProperties, ArtifactoryManagerBuilder artifactoryManagerBuilder) throws IOException { if (layers == null) { return; } diff --git a/build-info-extractor-docker/src/main/java/org/jfrog/build/extractor/docker/extractor/DockerPush.java b/build-info-extractor-docker/src/main/java/org/jfrog/build/extractor/docker/extractor/DockerPush.java index dd0268fa3..ebf669c68 100644 --- a/build-info-extractor-docker/src/main/java/org/jfrog/build/extractor/docker/extractor/DockerPush.java +++ b/build-info-extractor-docker/src/main/java/org/jfrog/build/extractor/docker/extractor/DockerPush.java @@ -1,11 +1,12 @@ package org.jfrog.build.extractor.docker.extractor; -import com.google.common.collect.ArrayListMultimap; +import org.apache.commons.collections4.MultiValuedMap; +import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; +import org.jfrog.build.api.util.Log; import org.jfrog.build.extractor.ci.BuildInfo; import org.jfrog.build.extractor.ci.Module; -import org.jfrog.build.api.util.Log; import org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration; import org.jfrog.build.extractor.clientConfiguration.ArtifactoryManagerBuilder; import org.jfrog.build.extractor.clientConfiguration.client.artifactory.ArtifactoryManager; @@ -21,7 +22,7 @@ import static org.jfrog.build.extractor.packageManager.PackageManagerUtils.createArtifactoryClientConfiguration; public class DockerPush extends DockerCommand { - private final ArrayListMultimap artifactProperties; + private final MultiValuedMap artifactProperties; /** @@ -36,7 +37,7 @@ public class DockerPush extends DockerCommand { * @param env - Environment variables to use during docker push execution. */ public DockerPush(ArtifactoryManagerBuilder artifactoryManagerBuilder, - String imageTag, String host, ArrayListMultimap artifactProperties, String targetRepository, String username, + String imageTag, String host, MultiValuedMap artifactProperties, String targetRepository, String username, String password, Log logger, Map env) { super(artifactoryManagerBuilder, imageTag, host, targetRepository, username, password, logger, env); this.artifactProperties = artifactProperties; @@ -58,7 +59,7 @@ public static void main(String[] ignored) { DockerPush dockerPush = new DockerPush(artifactoryManagerBuilder, dockerHandler.getImageTag(), dockerHandler.getHost(), - ArrayListMultimap.create(clientConfiguration.publisher.getMatrixParams().asMultimap()), + new ArrayListValuedHashMap<>(clientConfiguration.publisher.getMatrixParams()), clientConfiguration.publisher.getRepoKey(), clientConfiguration.publisher.getUsername(), clientConfiguration.publisher.getPassword(), @@ -85,7 +86,7 @@ public BuildInfo execute() { String imageId = DockerJavaWrapper.getImageIdFromTag(imageTag, host, env, logger); DockerImage image = new DockerImage(imageId, imageTag, "", targetRepository, artifactoryManagerBuilder, "", ""); Module module = image.generateBuildInfoModule(logger, DockerUtils.CommandType.Push); - if (module.getArtifacts() == null || module.getArtifacts().size() == 0) { + if (module.getArtifacts() == null || module.getArtifacts().isEmpty()) { logger.warn("Could not find docker image: " + imageTag + " in Artifactory."); } else { setImageLayersProps(image.getLayers(), artifactProperties, artifactoryManagerBuilder); @@ -104,7 +105,7 @@ public BuildInfo execute() { /** * Update each layer's properties with artifactProperties. */ - private void setImageLayersProps(DockerLayers layers, ArrayListMultimap artifactProperties, ArtifactoryManagerBuilder artifactoryManagerBuilder) throws IOException { + private void setImageLayersProps(DockerLayers layers, MultiValuedMap artifactProperties, ArtifactoryManagerBuilder artifactoryManagerBuilder) throws IOException { if (layers == null) { return; } diff --git a/build-info-extractor-docker/src/test/java/org/jfrog/build/extractor/docker/extractor/DockerExtractorTest.java b/build-info-extractor-docker/src/test/java/org/jfrog/build/extractor/docker/extractor/DockerExtractorTest.java index 88122867b..e31acf8c5 100644 --- a/build-info-extractor-docker/src/test/java/org/jfrog/build/extractor/docker/extractor/DockerExtractorTest.java +++ b/build-info-extractor-docker/src/test/java/org/jfrog/build/extractor/docker/extractor/DockerExtractorTest.java @@ -2,10 +2,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ImmutableMultimap; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; +import org.apache.commons.collections4.MultiValuedMap; +import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; +import org.apache.commons.compress.utils.Sets; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.SystemUtils; @@ -18,6 +17,7 @@ import org.testng.SkipException; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import org.testng.collections.Lists; import java.io.File; import java.io.IOException; @@ -43,7 +43,7 @@ public class DockerExtractorTest extends IntegrationTestsBase { private static final String SHORT_IMAGE_TAG_VIRTUAL = "3"; private static final String EXPECTED_REMOTE_PATH_KANIKO = "hello-world/latest"; private static final String DOCKER_HOST = "BITESTS_ARTIFACTORY_DOCKER_HOST"; - private final ArrayListMultimap artifactProperties = ArrayListMultimap.create(); + private final MultiValuedMap artifactProperties; private String pullImageFromVirtual; private String virtualDomainName; private String host; @@ -56,12 +56,12 @@ public DockerExtractorTest() { localRepo1 = getKeyWithTimestamp(DOCKER_LOCAL_REPO); remoteRepo = getKeyWithTimestamp(DOCKER_REMOTE_REPO); virtualRepo = getKeyWithTimestamp(DOCKER_VIRTUAL_REPO); - artifactProperties.putAll(ImmutableMultimap.builder() - .put("build.name", "docker-push-test") - .put("build.number", "1") - .put("build.timestamp", "321") - .put("property-key", "property-value") - .build()); + artifactProperties = new ArrayListValuedHashMap() {{ + put("build.name", "docker-push-test"); + put("build.number", "1"); + put("build.timestamp", "321"); + put("property-key", "property-value"); + }}; } @BeforeClass diff --git a/build-info-extractor-go/src/main/java/org/jfrog/build/extractor/go/extractor/GoPublish.java b/build-info-extractor-go/src/main/java/org/jfrog/build/extractor/go/extractor/GoPublish.java index 57375e1a2..4283ada4a 100644 --- a/build-info-extractor-go/src/main/java/org/jfrog/build/extractor/go/extractor/GoPublish.java +++ b/build-info-extractor-go/src/main/java/org/jfrog/build/extractor/go/extractor/GoPublish.java @@ -1,7 +1,8 @@ package org.jfrog.build.extractor.go.extractor; import com.fasterxml.jackson.databind.ObjectMapper; -import com.google.common.collect.ArrayListMultimap; +import org.apache.commons.collections4.MultiValuedMap; +import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; import org.apache.commons.compress.archivers.zip.ZipFile; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; @@ -46,7 +47,7 @@ public class GoPublish extends GoCommand { private static final String PKG_MOD_FILE_EXTENSION = "mod"; private static final String PKG_INFO_FILE_EXTENSION = "info"; - private final ArrayListMultimap properties; + private final MultiValuedMap properties; private final List artifactList = new ArrayList<>(); private final String deploymentRepo; private final String version; @@ -61,7 +62,7 @@ public class GoPublish extends GoCommand { * @param version - The package's version. * @param logger - The logger. */ - public GoPublish(ArtifactoryManagerBuilder artifactoryManagerBuilder, ArrayListMultimap properties, String repo, Path path, String version, String module, Log logger) throws IOException { + public GoPublish(ArtifactoryManagerBuilder artifactoryManagerBuilder, MultiValuedMap properties, String repo, Path path, String version, String module, Log logger) throws IOException { super(artifactoryManagerBuilder, path, module, logger); this.goDriver = new GoDriver(GO_CLIENT_CMD, null, path.toFile(), logger); this.moduleName = goDriver.getModuleName(); @@ -93,7 +94,7 @@ public static void main(String[] ignored) { GoPublish goPublish = new GoPublish( artifactoryManagerBuilder, - ArrayListMultimap.create(clientConfiguration.publisher.getMatrixParams().asMultimap()), + new ArrayListValuedHashMap<>(clientConfiguration.publisher.getMatrixParams()), clientConfiguration.publisher.getRepoKey(), Paths.get(packageManagerHandler.getPath() != null ? packageManagerHandler.getPath() : ".").toAbsolutePath(), clientConfiguration.goHandler.getGoPublishedVersion(), @@ -153,7 +154,7 @@ private void createAndDeployInfo(ArtifactoryManager artifactoryManager) throws E private File archiveProjectDir() throws IOException { File zipFile = File.createTempFile(LOCAL_TMP_PKG_PREFIX + LOCAL_PKG_FILENAME, PKG_ZIP_FILE_EXTENSION, path.toFile()); try (ZipOutputStream zos = new ZipOutputStream(Files.newOutputStream(zipFile.toPath())); - Stream pathFileTree = Files.walk(path)) { + Stream pathFileTree = Files.walk(path)) { List pathsList = pathFileTree // Remove .git dir content, directories and the temp zip file .filter(p -> !path.relativize(p).startsWith(".git/") && !Files.isDirectory(p) && !p.toFile().getName().equals(zipFile.getName())) diff --git a/build-info-extractor-go/src/main/java/org/jfrog/build/extractor/go/extractor/GoZipBallStreamer.java b/build-info-extractor-go/src/main/java/org/jfrog/build/extractor/go/extractor/GoZipBallStreamer.java index 9e92d4ed8..00187b100 100644 --- a/build-info-extractor-go/src/main/java/org/jfrog/build/extractor/go/extractor/GoZipBallStreamer.java +++ b/build-info-extractor-go/src/main/java/org/jfrog/build/extractor/go/extractor/GoZipBallStreamer.java @@ -34,7 +34,6 @@ package org.jfrog.build.extractor.go.extractor; -import com.google.common.collect.Sets; import org.apache.commons.compress.archivers.ArchiveOutputStream; import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; @@ -50,6 +49,7 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.Enumeration; +import java.util.HashSet; import java.util.Set; import java.util.zip.ZipEntry; @@ -75,7 +75,7 @@ public GoZipBallStreamer(ZipFile zipFile, String projectName, String version, Lo this.projectName = projectName; this.version = version; this.log = log; - excludedDirectories = Sets.newHashSet(); + excludedDirectories = new HashSet<>(); } public void writeDeployableZip(File deployableZip) throws IOException { @@ -202,7 +202,7 @@ private boolean excludeEntry(String entryName) { private void scanEntries() { Enumeration entries = zipFile.getEntries(); ZipEntry zipEntry; - Set allDirectories = Sets.newHashSet(); + Set allDirectories = new HashSet<>(); while (entries.hasMoreElements()) { zipEntry = entries.nextElement(); if (!zipEntry.isDirectory() && isSubModule(zipEntry.getName())) { diff --git a/build-info-extractor-go/src/test/java/org/jfrog/build/extractor/go/GoDriverTest.java b/build-info-extractor-go/src/test/java/org/jfrog/build/extractor/go/GoDriverTest.java index eaa77580c..83dae63c5 100644 --- a/build-info-extractor-go/src/test/java/org/jfrog/build/extractor/go/GoDriverTest.java +++ b/build-info-extractor-go/src/test/java/org/jfrog/build/extractor/go/GoDriverTest.java @@ -1,6 +1,6 @@ package org.jfrog.build.extractor.go; -import com.google.common.collect.Sets; +import org.apache.commons.compress.utils.Sets; import org.apache.commons.io.FileUtils; import org.jfrog.build.api.util.NullLog; import org.jfrog.build.extractor.executor.CommandResults; diff --git a/build-info-extractor-go/src/test/java/org/jfrog/build/extractor/go/extractor/GoDependencyTreeTest.java b/build-info-extractor-go/src/test/java/org/jfrog/build/extractor/go/extractor/GoDependencyTreeTest.java index ef1b468d5..062f5be56 100644 --- a/build-info-extractor-go/src/test/java/org/jfrog/build/extractor/go/extractor/GoDependencyTreeTest.java +++ b/build-info-extractor-go/src/test/java/org/jfrog/build/extractor/go/extractor/GoDependencyTreeTest.java @@ -1,6 +1,6 @@ package org.jfrog.build.extractor.go.extractor; -import com.google.common.collect.Sets; +import org.apache.commons.compress.utils.Sets; import org.jfrog.build.api.util.NullLog; import org.jfrog.build.extractor.scan.DependencyTree; import org.testng.annotations.Test; diff --git a/build-info-extractor-go/src/test/java/org/jfrog/build/extractor/go/extractor/GoExtractorTest.java b/build-info-extractor-go/src/test/java/org/jfrog/build/extractor/go/extractor/GoExtractorTest.java index aff85663c..a66af038b 100644 --- a/build-info-extractor-go/src/test/java/org/jfrog/build/extractor/go/extractor/GoExtractorTest.java +++ b/build-info-extractor-go/src/test/java/org/jfrog/build/extractor/go/extractor/GoExtractorTest.java @@ -1,12 +1,11 @@ package org.jfrog.build.extractor.go.extractor; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Sets; +import org.apache.commons.collections4.MultiMapUtils; +import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.jfrog.build.IntegrationTestsBase; -import org.jfrog.build.extractor.ci.Module; import org.jfrog.build.extractor.ci.*; import org.jfrog.build.extractor.clientConfiguration.ArtifactoryManagerBuilder; import org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails; @@ -66,7 +65,7 @@ private enum Project { this.targetDir = targetDir; this.name = name; this.version = version; - this.dependencies = Sets.newHashSet(dependencies); + this.dependencies = new HashSet<>(Arrays.asList(dependencies)); } private String getDependencyId() { @@ -176,7 +175,7 @@ public void goRunTest(Project project, String args, ArtifactoryManagerBuilder ar @Test public void goRunPublishTest() { Path projectDir = null; - ArrayListMultimap properties = ArrayListMultimap.create(); + MultiValuedMap properties = MultiMapUtils.newListValuedHashMap(); try { // Run Go build on project1 locally Project project = Project.PROJECT_1; diff --git a/build-info-extractor-gradle/src/main/groovy/org/jfrog/gradle/plugin/artifactory/extractor/GradleModuleExtractor.java b/build-info-extractor-gradle/src/main/groovy/org/jfrog/gradle/plugin/artifactory/extractor/GradleModuleExtractor.java index a5a52dd4e..45bba451b 100644 --- a/build-info-extractor-gradle/src/main/groovy/org/jfrog/gradle/plugin/artifactory/extractor/GradleModuleExtractor.java +++ b/build-info-extractor-gradle/src/main/groovy/org/jfrog/gradle/plugin/artifactory/extractor/GradleModuleExtractor.java @@ -1,8 +1,6 @@ package org.jfrog.gradle.plugin.artifactory.extractor; -import com.google.common.base.Predicate; -import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; +import org.apache.commons.compress.utils.Sets; import org.gradle.api.Project; import org.gradle.api.artifacts.Configuration; import org.gradle.api.artifacts.ModuleVersionIdentifier; @@ -31,14 +29,11 @@ import javax.annotation.Nullable; import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; +import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.StreamSupport; -import static com.google.common.collect.Lists.newArrayList; import static org.jfrog.build.api.util.FileChecksumCalculator.*; import static org.jfrog.build.extractor.BuildInfoExtractorUtils.getModuleIdString; import static org.jfrog.build.extractor.BuildInfoExtractorUtils.getTypeString; @@ -48,7 +43,7 @@ public class GradleModuleExtractor implements ModuleExtractor { @Override public Module extractModule(Project project) { - Set gradleDeployDetails = Sets.newHashSet(); + Set gradleDeployDetails = new HashSet<>(); String artifactName = project.getName(); ArtifactoryTask artifactoryTask = ProjectUtils.getBuildInfoTask(project); if (artifactoryTask != null) { @@ -81,10 +76,10 @@ public Module extractModule(Project project) { Iterable deployExcludeDetails; Iterable deployIncludeDetails; if (excludeArtifactsFromBuild) { - deployIncludeDetails = Iterables.filter(gradleDeployDetails, new IncludeExcludePredicate(project, patterns, true)); - deployExcludeDetails = Iterables.filter(gradleDeployDetails, new IncludeExcludePredicate(project, patterns, false)); + deployIncludeDetails = gradleDeployDetails.stream().filter(new IncludeExcludePredicate(project, patterns, true)).collect(Collectors.toSet()); + deployExcludeDetails = gradleDeployDetails.stream().filter(new IncludeExcludePredicate(project, patterns, false)).collect(Collectors.toSet()); } else { - deployIncludeDetails = Iterables.filter(gradleDeployDetails, new ProjectPredicate(project)); + deployIncludeDetails = gradleDeployDetails.stream().filter(new ProjectPredicate(project)).collect(Collectors.toSet()); deployExcludeDetails = new ArrayList<>(); } builder.artifacts(calculateArtifacts(deployIncludeDetails)) @@ -121,7 +116,7 @@ private List calculateDependencies(Project project, String moduleId) Map requestedByMap = artifactoryDependencyResolutionListener.getModulesHierarchyMap().get(moduleId); Set configurationSet = project.getConfigurations(); - List dependencies = newArrayList(); + List dependencies = new ArrayList<>(); for (Configuration configuration : configurationSet) { if (configuration.getState() != Configuration.State.RESOLVED) { log.info("Artifacts for configuration '{}' were not all resolved, skipping", configuration.getName()); @@ -171,7 +166,8 @@ private ProjectPredicate(Project project) { this.project = project; } - public boolean apply(@Nullable GradleDeployDetails input) { + @Override + public boolean test(@Nullable GradleDeployDetails input) { if (input == null) { return false; } @@ -184,21 +180,21 @@ private static class IncludeExcludePredicate implements Predicate deployDetails = new TreeSet<>(); - private final Multimap properties = ArrayListMultimap.create(); + private final MultiValuedMap properties = MultiMapUtils.newListValuedHashMap(); @Input - public Multimap getProperties() { + public MultiValuedMap getProperties() { return properties; } diff --git a/build-info-extractor-gradle/src/main/groovy/org/jfrog/gradle/plugin/artifactory/task/helper/TaskHelper.java b/build-info-extractor-gradle/src/main/groovy/org/jfrog/gradle/plugin/artifactory/task/helper/TaskHelper.java index 7fba2fe54..ff476410e 100644 --- a/build-info-extractor-gradle/src/main/groovy/org/jfrog/gradle/plugin/artifactory/task/helper/TaskHelper.java +++ b/build-info-extractor-gradle/src/main/groovy/org/jfrog/gradle/plugin/artifactory/task/helper/TaskHelper.java @@ -1,6 +1,6 @@ package org.jfrog.gradle.plugin.artifactory.task.helper; -import com.google.common.collect.Multimap; +import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.lang3.StringUtils; import org.gradle.api.Project; import org.gradle.api.Task; @@ -70,12 +70,12 @@ protected Map getPropsToAdd(PublishArtifactInfo artifact, String .name(project.getName()).version(project.getVersion().toString()) .classifier(artifact.getClassifier()) .type(artifact.getType()).build(); - Multimap artifactSpecsProperties = artifactoryTask.artifactSpecs.getProperties(spec); + MultiValuedMap artifactSpecsProperties = artifactoryTask.artifactSpecs.getProperties(spec); addProps(propsToAdd, artifactSpecsProperties); return propsToAdd; } - private void addProps(Map target, Multimap props) { + private void addProps(Map target, MultiValuedMap props) { for (Map.Entry entry : props.entries()) { // Make sure all GString are now Java Strings String key = entry.getKey(); diff --git a/build-info-extractor-npm/src/main/java/org/jfrog/build/extractor/npm/extractor/NpmPublish.java b/build-info-extractor-npm/src/main/java/org/jfrog/build/extractor/npm/extractor/NpmPublish.java index 7f670b16f..be1550372 100644 --- a/build-info-extractor-npm/src/main/java/org/jfrog/build/extractor/npm/extractor/NpmPublish.java +++ b/build-info-extractor-npm/src/main/java/org/jfrog/build/extractor/npm/extractor/NpmPublish.java @@ -1,19 +1,20 @@ package org.jfrog.build.extractor.npm.extractor; -import com.google.common.collect.ArrayListMultimap; +import org.apache.commons.collections4.MultiValuedMap; +import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; import org.apache.commons.compress.archivers.tar.TarArchiveEntry; import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.jfrog.build.api.builder.ModuleType; +import org.jfrog.build.api.util.Log; +import org.jfrog.build.client.ArtifactoryUploadResponse; import org.jfrog.build.extractor.builder.ArtifactBuilder; import org.jfrog.build.extractor.builder.ModuleBuilder; import org.jfrog.build.extractor.ci.Artifact; import org.jfrog.build.extractor.ci.BuildInfo; import org.jfrog.build.extractor.ci.Module; -import org.jfrog.build.api.util.Log; -import org.jfrog.build.client.ArtifactoryUploadResponse; import org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration; import org.jfrog.build.extractor.clientConfiguration.ArtifactoryManagerBuilder; import org.jfrog.build.extractor.clientConfiguration.client.artifactory.ArtifactoryManager; @@ -38,7 +39,7 @@ */ @SuppressWarnings({"unused", "WeakerAccess"}) public class NpmPublish extends NpmCommand { - private final ArrayListMultimap properties; + private final MultiValuedMap properties; private Artifact deployedArtifact; private boolean tarballProvided; private final String module; @@ -53,7 +54,7 @@ public class NpmPublish extends NpmCommand { * @param logger - The logger. * @param env - Environment variables to use during npm execution. */ - public NpmPublish(ArtifactoryManagerBuilder artifactoryManagerBuilder, ArrayListMultimap properties, Path path, String deploymentRepository, Log logger, Map env, String module) { + public NpmPublish(ArtifactoryManagerBuilder artifactoryManagerBuilder, MultiValuedMap properties, Path path, String deploymentRepository, Log logger, Map env, String module) { super(artifactoryManagerBuilder, deploymentRepository, logger, path, env); this.properties = properties; this.module = module; @@ -69,7 +70,7 @@ public static void main(String[] ignored) { ArtifactoryManagerBuilder artifactoryManagerBuilder = new ArtifactoryManagerBuilder().setClientConfiguration(clientConfiguration, clientConfiguration.publisher); ArtifactoryClientConfiguration.PackageManagerHandler npmHandler = clientConfiguration.packageManagerHandler; NpmPublish npmPublish = new NpmPublish(artifactoryManagerBuilder, - ArrayListMultimap.create(clientConfiguration.publisher.getMatrixParams().asMultimap()), + new ArrayListValuedHashMap<>(clientConfiguration.publisher.getMatrixParams()), Paths.get(npmHandler.getPath() != null ? npmHandler.getPath() : "."), clientConfiguration.publisher.getRepoKey(), clientConfiguration.getLog(), @@ -116,9 +117,9 @@ private void readPackageInfoFromTarball() throws IOException { throw new IOException("Publish path must be a '.tgz' file or a directory containing package.json"); } try (TarArchiveInputStream inputStream = new TarArchiveInputStream( - new GzipCompressorInputStream(new BufferedInputStream(new FileInputStream(path.toFile()))))) { + new GzipCompressorInputStream(new BufferedInputStream(Files.newInputStream(path.toFile().toPath()))))) { TarArchiveEntry entry; - while ((entry = inputStream.getNextTarEntry()) != null) { + while ((entry = inputStream.getNextEntry()) != null) { Path parent = Paths.get(entry.getName()).getParent(); if (parent != null && StringUtils.equals(parent.toString(), "package") && StringUtils.endsWith(entry.getName(), "package.json")) { npmPackageInfo.readPackageInfo(inputStream); diff --git a/build-info-extractor-npm/src/test/java/org/jfrog/build/extractor/npm/extractor/NpmExtractorTest.java b/build-info-extractor-npm/src/test/java/org/jfrog/build/extractor/npm/extractor/NpmExtractorTest.java index 7f548c7ba..a1702849d 100644 --- a/build-info-extractor-npm/src/test/java/org/jfrog/build/extractor/npm/extractor/NpmExtractorTest.java +++ b/build-info-extractor-npm/src/test/java/org/jfrog/build/extractor/npm/extractor/NpmExtractorTest.java @@ -1,7 +1,8 @@ package org.jfrog.build.extractor.npm.extractor; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ImmutableMultimap; +import org.apache.commons.collections4.MultiMapUtils; +import org.apache.commons.collections4.MultiValuedMap; +import org.apache.commons.collections4.multimap.ArrayListValuedHashMap; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; @@ -207,18 +208,26 @@ private void runNpmTest(Project project, Dependency[] expectedDependencies, Stri @DataProvider private Object[][] npmPublishProvider() { return new Object[][]{ - {Project.A, ArrayListMultimap.create(), Project.A.getTargetPath(), ""}, - {Project.A, ArrayListMultimap.create(ImmutableMultimap.of("a", "b")), Project.A.getTargetPath(), ""}, - {Project.B, ArrayListMultimap.create(), Project.B.getTargetPath(), Project.B.getPackedFileName()}, - {Project.B, ArrayListMultimap.create(ImmutableMultimap.of("a", "b", "c", "d")), Project.B.getTargetPath(), Project.B.getPackedFileName()}, - {Project.C, ArrayListMultimap.create(), Project.C.getTargetPath(), ""}, - {Project.C, ArrayListMultimap.create(ImmutableMultimap.of("a", "b", "a", "d")), Project.C.getTargetPath(), ""} + {Project.A, MultiMapUtils.emptyMultiValuedMap(), Project.A.getTargetPath(), ""}, + {Project.A, new ArrayListValuedHashMap() {{ + put("a", "b"); + }}, Project.A.getTargetPath(), ""}, + {Project.B, MultiMapUtils.emptyMultiValuedMap(), Project.B.getTargetPath(), Project.B.getPackedFileName()}, + {Project.B, new ArrayListValuedHashMap() {{ + put("a", "b"); + put("c", "d"); + }}, Project.B.getTargetPath(), Project.B.getPackedFileName()}, + {Project.C, MultiMapUtils.emptyMultiValuedMap(), Project.C.getTargetPath(), ""}, + {Project.C, new ArrayListValuedHashMap() {{ + put("a", "b"); + put("a", "d"); + }}, Project.C.getTargetPath(), ""} }; } @SuppressWarnings("unused") @Test(dataProvider = "npmPublishProvider") - public void npmPublishTest(Project project, ArrayListMultimap props, String targetPath, String packageName) { + public void npmPublishTest(Project project, MultiValuedMap props, String targetPath, String packageName) { Path projectDir = null; try { // Run npm publish diff --git a/build-info-extractor/src/main/java/org/jfrog/build/extractor/ModuleExtractorUtils.java b/build-info-extractor/src/main/java/org/jfrog/build/extractor/ModuleExtractorUtils.java index de29fd2fa..e6c7e9c80 100644 --- a/build-info-extractor/src/main/java/org/jfrog/build/extractor/ModuleExtractorUtils.java +++ b/build-info-extractor/src/main/java/org/jfrog/build/extractor/ModuleExtractorUtils.java @@ -1,18 +1,10 @@ package org.jfrog.build.extractor; -import com.fasterxml.jackson.core.JsonFactory; -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonParser; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector; -import com.google.common.base.Charsets; -import com.google.common.io.Files; +import com.fasterxml.jackson.core.type.TypeReference; import org.jfrog.build.extractor.ci.Module; import java.io.File; import java.io.IOException; -import java.io.StringReader; -import java.io.StringWriter; import static org.jfrog.build.extractor.BuildInfoExtractorUtils.createMapper; @@ -20,62 +12,22 @@ * Utilities for serializing/deserializing Module info as json */ public class ModuleExtractorUtils { - private static JsonFactory createJsonFactory() { - JsonFactory jsonFactory = new JsonFactory(); - ObjectMapper mapper = createMapper(); - mapper.setAnnotationIntrospector(new JacksonAnnotationIntrospector()); - jsonFactory.setCodec(mapper); - return jsonFactory; - } - - /** - * Given a Module object, serialize it as a json string. - * - * @param module The module to serialize - * @return The json string representing the serialized module - * @throws IOException - */ - public static String moduleToJsonString(Module module) throws IOException { - JsonFactory jsonFactory = createJsonFactory(); - - try (StringWriter writer = new StringWriter(); - JsonGenerator jsonGenerator = jsonFactory.createGenerator(writer)) { - jsonGenerator.useDefaultPrettyPrinter(); - jsonGenerator.writeObject(module); - - return writer.getBuffer().toString(); - } - } - - /** - * Given a serialized json module string, deserialize it into a Module object. - * - * @param json The serialized json module string - * @return A Module object deserialized from the provided string - * @throws IOException - */ - public static Module jsonStringToModule(String json) throws IOException { - JsonFactory jsonFactory = createJsonFactory(); - JsonParser parser = jsonFactory.createParser(new StringReader(json)); - return jsonFactory.getCodec().readValue(parser, Module.class); - } /** * Given a Module object, serialize it to a json string and write it to the provided file. * * @param module The module object * @param toFile The file to write the serialized module to - * @throws IOException + * @throws IOException in case of any serialization error. */ public static void saveModuleToFile(Module module, File toFile) throws IOException { - String moduleInfoJson = moduleToJsonString(module); if (!toFile.getParentFile().exists()) { toFile.getParentFile().mkdirs(); } if (!toFile.exists()) { toFile.createNewFile(); } - Files.asCharSink(toFile, Charsets.UTF_8).write(moduleInfoJson); + createMapper().writeValue(toFile, module); } /** @@ -83,10 +35,10 @@ public static void saveModuleToFile(Module module, File toFile) throws IOExcepti * * @param fromFile The file containing a serialized json string * @return The Module object deserialized from the content of the file - * @throws IOException + * @throws IOException in case of any deserialization error. */ public static Module readModuleFromFile(File fromFile) throws IOException { - String moduleInfoJson = Files.asCharSource(fromFile, Charsets.UTF_8).read(); - return jsonStringToModule(moduleInfoJson); + return createMapper().readValue(fromFile, new TypeReference() { + }); } } diff --git a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/ArtifactSpecs.java b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/ArtifactSpecs.java index d8b5e28c2..273e158f9 100644 --- a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/ArtifactSpecs.java +++ b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/ArtifactSpecs.java @@ -1,7 +1,7 @@ package org.jfrog.build.extractor.clientConfiguration; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; +import org.apache.commons.collections4.MultiMapUtils; +import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.lang3.StringUtils; import java.util.LinkedList; @@ -41,8 +41,8 @@ public ArtifactSpecs(String specsNotation) { * @param spec * @return */ - public Multimap getProperties(ArtifactSpec spec) { - Multimap props = ArrayListMultimap.create(); + public MultiValuedMap getProperties(ArtifactSpec spec) { + MultiValuedMap props = MultiMapUtils.newListValuedHashMap(); for (ArtifactSpec matcherSpec : this) { if (matcherSpec.matches(spec)) { Map matcherSpecProperties = matcherSpec.getProperties(); diff --git a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/ArtifactoryClientConfiguration.java b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/ArtifactoryClientConfiguration.java index 196d3be65..256938efa 100644 --- a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/ArtifactoryClientConfiguration.java +++ b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/ArtifactoryClientConfiguration.java @@ -1,7 +1,6 @@ package org.jfrog.build.extractor.clientConfiguration; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.ImmutableMap; +import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.lang3.StringUtils; import org.jfrog.build.api.util.CommonUtils; import org.jfrog.build.api.util.Log; @@ -14,135 +13,25 @@ import javax.crypto.BadPaddingException; import javax.crypto.IllegalBlockSizeException; import javax.crypto.NoSuchPaddingException; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.UnsupportedEncodingException; +import java.io.*; import java.net.URLEncoder; import java.security.InvalidAlgorithmParameterException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; -import java.util.Set; +import java.util.*; import java.util.concurrent.ConcurrentSkipListMap; import java.util.function.Predicate; import static org.jfrog.build.extractor.ModuleParallelDeployHelper.DEFAULT_DEPLOYMENT_THREADS; -import static org.jfrog.build.extractor.ci.BuildInfoConfigProperties.ACTIVATE_RECORDER; -import static org.jfrog.build.extractor.ci.BuildInfoConfigProperties.BUILD_INFO_CONFIG_PREFIX; -import static org.jfrog.build.extractor.ci.BuildInfoConfigProperties.ENV_VARS_EXCLUDE_PATTERNS; -import static org.jfrog.build.extractor.ci.BuildInfoConfigProperties.ENV_VARS_INCLUDE_PATTERNS; -import static org.jfrog.build.extractor.ci.BuildInfoConfigProperties.EXPORT_FILE; -import static org.jfrog.build.extractor.ci.BuildInfoConfigProperties.INCLUDE_ENV_VARS; -import static org.jfrog.build.extractor.ci.BuildInfoConfigProperties.PROPERTIES_FILE; -import static org.jfrog.build.extractor.ci.BuildInfoFields.AGENT_NAME; -import static org.jfrog.build.extractor.ci.BuildInfoFields.AGENT_VERSION; -import static org.jfrog.build.extractor.ci.BuildInfoFields.ARTIFACTORY_PLUGIN_VERSION; -import static org.jfrog.build.extractor.ci.BuildInfoFields.BACKWARD_COMPATIBLE_DEPLOYABLE_ARTIFACTS; -import static org.jfrog.build.extractor.ci.BuildInfoFields.BUILD_AGENT_NAME; -import static org.jfrog.build.extractor.ci.BuildInfoFields.BUILD_AGENT_VERSION; -import static org.jfrog.build.extractor.ci.BuildInfoFields.BUILD_NAME; -import static org.jfrog.build.extractor.ci.BuildInfoFields.BUILD_NUMBER; -import static org.jfrog.build.extractor.ci.BuildInfoFields.BUILD_NUMBERS_NOT_TO_DELETE; -import static org.jfrog.build.extractor.ci.BuildInfoFields.BUILD_PARENT_NAME; -import static org.jfrog.build.extractor.ci.BuildInfoFields.BUILD_PARENT_NUMBER; -import static org.jfrog.build.extractor.ci.BuildInfoFields.BUILD_PROJECT; -import static org.jfrog.build.extractor.ci.BuildInfoFields.BUILD_RETENTION_ASYNC; -import static org.jfrog.build.extractor.ci.BuildInfoFields.BUILD_RETENTION_COUNT; -import static org.jfrog.build.extractor.ci.BuildInfoFields.BUILD_RETENTION_DAYS; -import static org.jfrog.build.extractor.ci.BuildInfoFields.BUILD_RETENTION_MINIMUM_DATE; -import static org.jfrog.build.extractor.ci.BuildInfoFields.BUILD_ROOT; -import static org.jfrog.build.extractor.ci.BuildInfoFields.BUILD_STARTED; -import static org.jfrog.build.extractor.ci.BuildInfoFields.BUILD_TIMESTAMP; -import static org.jfrog.build.extractor.ci.BuildInfoFields.BUILD_URL; -import static org.jfrog.build.extractor.ci.BuildInfoFields.DELETE_BUILD_ARTIFACTS; -import static org.jfrog.build.extractor.ci.BuildInfoFields.DEPLOYABLE_ARTIFACTS; -import static org.jfrog.build.extractor.ci.BuildInfoFields.ENVIRONMENT_PREFIX; -import static org.jfrog.build.extractor.ci.BuildInfoFields.GENERATED_BUILD_INFO; -import static org.jfrog.build.extractor.ci.BuildInfoFields.INCREMENTAL; -import static org.jfrog.build.extractor.ci.BuildInfoFields.MIN_CHECKSUM_DEPLOY_SIZE_KB; -import static org.jfrog.build.extractor.ci.BuildInfoFields.PRINCIPAL; -import static org.jfrog.build.extractor.ci.BuildInfoFields.RELEASE_COMMENT; -import static org.jfrog.build.extractor.ci.BuildInfoFields.RELEASE_ENABLED; -import static org.jfrog.build.extractor.ci.BuildInfoFields.RUN_PARAMETERS; -import static org.jfrog.build.extractor.ci.BuildInfoFields.VCS_BRANCH; -import static org.jfrog.build.extractor.ci.BuildInfoFields.VCS_MESSAGE; -import static org.jfrog.build.extractor.ci.BuildInfoFields.VCS_REVISION; -import static org.jfrog.build.extractor.ci.BuildInfoFields.VCS_URL; +import static org.jfrog.build.extractor.ci.BuildInfoConfigProperties.*; +import static org.jfrog.build.extractor.ci.BuildInfoFields.*; import static org.jfrog.build.extractor.ci.BuildInfoProperties.BUILD_INFO_ISSUES_TRACKER_PREFIX; import static org.jfrog.build.extractor.ci.BuildInfoProperties.BUILD_INFO_PREFIX; -import static org.jfrog.build.extractor.ci.IssuesTrackerFields.AFFECTED_ISSUES; -import static org.jfrog.build.extractor.ci.IssuesTrackerFields.AGGREGATE_BUILD_ISSUES; -import static org.jfrog.build.extractor.ci.IssuesTrackerFields.AGGREGATION_BUILD_STATUS; -import static org.jfrog.build.extractor.ci.IssuesTrackerFields.ISSUES_TRACKER_NAME; -import static org.jfrog.build.extractor.ci.IssuesTrackerFields.ISSUES_TRACKER_VERSION; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.ADD_DEPLOYABLE_ARTIFACTS; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.ARTIFACT_SPECS; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.CONTEXT_URL; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.DOCKER_HOST; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.DOCKER_IMAGE_TAG; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.DOTNET_NUGET_PROTOCOL; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.DOTNET_USE_DOTNET_CORE_CLI; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.DOWN_SNAPSHOT_REPO_KEY; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.EVEN_UNSTABLE; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.EXCLUDE_PATTERNS; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.FILTER_EXCLUDED_ARTIFACTS_FROM_BUILD; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.GO_PUBLISHED_VERSION; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.HOST; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.INCLUDE_PATTERNS; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.IVY; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.IVY_ART_PATTERN; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.IVY_IVY_PATTERN; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.IVY_M2_COMPATIBLE; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.IVY_REPO_DEFINED; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.JIB_IMAGE_FILE; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.KANIKO_IMAGE_FILE; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.MATRIX; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.MAVEN; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.NAME; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.NO_PROXY; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.NPM_CI_COMMAND; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.PACKAGE_MANAGER_ARGS; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.PACKAGE_MANAGER_MODULE; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.PACKAGE_MANAGER_PATH; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.PASSWORD; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.PIP_ENV_ACTIVATION; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.PORT; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.PUBLICATIONS; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.PUBLISH_ARTIFACTS; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.PUBLISH_BUILD_INFO; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.PUBLISH_FORK_COUNT; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.RECORD_ALL_DEPENDENCIES; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.RELEASE_REPO_KEY; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.REPO_KEY; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.SNAPSHOT_REPO_KEY; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.URL; -import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.USERNAME; -import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.DEPRECATED_PROP_DEPLOY_PARAM_PROP_PREFIX; -import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.PROP_CONNECTION_RETRIES; -import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.PROP_CONTEXT_URL; -import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.PROP_DEPLOY_PARAM_PROP_PREFIX; -import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.PROP_DOCKER_PREFIX; -import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.PROP_DOTNET_PREFIX; -import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.PROP_GO_PREFIX; -import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.PROP_HTTPS_PROXY_PREFIX; -import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.PROP_INSECURE_TLS; -import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.PROP_MAX_CO_PER_ROUTE; -import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.PROP_MAX_TOTAL_CO; -import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.PROP_NPM_PREFIX; -import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.PROP_PACKAGE_MANAGER_PREFIX; -import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.PROP_PIP_PREFIX; -import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.PROP_PROXY_PREFIX; -import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.PROP_PUBLISH_PREFIX; -import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.PROP_RESOLVE_PREFIX; -import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.PROP_SO_TIMEOUT; -import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.PROP_TIMEOUT; +import static org.jfrog.build.extractor.ci.IssuesTrackerFields.*; +import static org.jfrog.build.extractor.clientConfiguration.ClientConfigurationFields.*; +import static org.jfrog.build.extractor.clientConfiguration.ClientProperties.*; import static org.jfrog.build.extractor.clientConfiguration.util.encryption.PropertyEncryptor.encryptedPropertiesToStream; /** @@ -817,7 +706,7 @@ public void setPassword(String password) { public abstract class RepositoryConfiguration extends AuthenticationConfiguration { - private ImmutableMap calculatedMatrixParams; + private Map calculatedMatrixParams; protected RepositoryConfiguration(String prefix) { super(prefix); @@ -994,24 +883,24 @@ public void addMatrixParams(Map vars) { } } - public void addMatrixParams(ArrayListMultimap vars) { + public void addMatrixParams(MultiValuedMap vars) { for (Map.Entry entry : vars.entries()) { addMatrixParam(entry.getKey(), entry.getValue()); } } - public ImmutableMap getMatrixParams() { + public Map getMatrixParams() { if (calculatedMatrixParams != null) { return calculatedMatrixParams; } // First, get value using deprecated key. // This check must be first, otherwise, build.gradle properties will override the CI (e.g Jenkins / teamcity) properties. Map result = getResolveMatrixParams(getDeprecatedMatrixParamPrefix()); - if (result.size() == 0) { + if (result.isEmpty()) { // Fallback to none deprecated key. result = getResolveMatrixParams(getMatrixParamPrefix()); } - this.calculatedMatrixParams = ImmutableMap.copyOf(result); + this.calculatedMatrixParams = Collections.unmodifiableMap(new LinkedHashMap<>(result)); return calculatedMatrixParams; } diff --git a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/client/artifactory/ArtifactoryManager.java b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/client/artifactory/ArtifactoryManager.java index 7c1626896..a4ea612cd 100644 --- a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/client/artifactory/ArtifactoryManager.java +++ b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/client/artifactory/ArtifactoryManager.java @@ -1,7 +1,6 @@ package org.jfrog.build.extractor.clientConfiguration.client.artifactory; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Lists; +import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.lang3.StringUtils; import org.apache.http.Header; import org.jfrog.build.api.dependency.BuildPatternArtifacts; @@ -28,6 +27,7 @@ import java.io.File; import java.io.IOException; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Properties; @@ -72,7 +72,7 @@ public void setProperties(String relativePath, String properties, boolean encode setPropertiesService.execute(jfrogHttpClient); } - public void setProperties(String relativePath, ArrayListMultimap properties, boolean encodeProperties) throws IOException { + public void setProperties(String relativePath, MultiValuedMap properties, boolean encodeProperties) throws IOException { SetProperties setPropertiesService = new SetProperties(relativePath, properties, encodeProperties, log); setPropertiesService.execute(jfrogHttpClient); } @@ -309,7 +309,7 @@ public String getLatestBuildNumber(String buildName, String latestType, String p if (versionService.execute(jfrogHttpClient).isOSS()) { throw new IllegalArgumentException(String.format("%s is not supported in Artifactory OSS.", latestType)); } - List artifactsRequest = Lists.newArrayList(); + List artifactsRequest = new ArrayList<>(); artifactsRequest.add(new BuildPatternArtifactsRequest(buildName, latestType, project)); List artifactsResponses = retrievePatternArtifacts(artifactsRequest); // Artifactory returns null if no build was found diff --git a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/client/artifactory/services/SetProperties.java b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/client/artifactory/services/SetProperties.java index f702def51..d0e648cd4 100644 --- a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/client/artifactory/services/SetProperties.java +++ b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/client/artifactory/services/SetProperties.java @@ -1,6 +1,7 @@ package org.jfrog.build.extractor.clientConfiguration.client.artifactory.services; -import com.google.common.collect.ArrayListMultimap; +import org.apache.commons.collections4.MultiMapUtils; +import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.HttpPut; @@ -18,12 +19,12 @@ public class SetProperties extends VoidJFrogService { public static final String SET_PROPERTIES_ENDPOINT = "api/storage/"; - private final ArrayListMultimap propertiesMap; + private final MultiValuedMap propertiesMap; private final boolean encodeProperties; private final String relativePath; private final String propertiesString; - private SetProperties(String relativePath, String propertiesString, ArrayListMultimap propertiesMap, boolean encodeProperties, Log log) { + private SetProperties(String relativePath, String propertiesString, MultiValuedMap propertiesMap, boolean encodeProperties, Log log) { super(log); this.relativePath = relativePath; this.propertiesMap = propertiesMap; @@ -35,7 +36,7 @@ public SetProperties(String relativePath, String propertiesString, boolean encod this(relativePath, propertiesString, null, encodeProperties, log); } - public SetProperties(String relativePath, ArrayListMultimap propertiesMap, boolean encodeProperties, Log log) { + public SetProperties(String relativePath, MultiValuedMap propertiesMap, boolean encodeProperties, Log log) { this(relativePath, null, propertiesMap, encodeProperties, log); } @@ -79,8 +80,8 @@ protected void ensureRequirements(JFrogHttpClient client) throws IOException { } } - private ArrayListMultimap mapPropsString(String props) { - ArrayListMultimap propsMap = ArrayListMultimap.create(); + private MultiValuedMap mapPropsString(String props) { + MultiValuedMap propsMap = MultiMapUtils.newListValuedHashMap(); String[] propsList = props.split(";"); for (String prop : propsList) { if (isNotEmpty(prop)) { diff --git a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/deploy/DeployDetails.java b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/deploy/DeployDetails.java index 5ce101632..27af64a9c 100644 --- a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/deploy/DeployDetails.java +++ b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/deploy/DeployDetails.java @@ -1,9 +1,7 @@ package org.jfrog.build.extractor.clientConfiguration.deploy; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Maps; -import com.google.common.collect.Multimap; -import com.google.common.collect.Multimaps; +import org.apache.commons.collections4.MultiMapUtils; +import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.lang3.StringUtils; import org.jfrog.build.api.BuildFileBean; import org.jfrog.build.api.producerConsumer.ProducerConsumerItem; @@ -47,7 +45,7 @@ public class DeployDetails implements Comparable, Serializable, P /** * Properties to attach to the deployed file as matrix params. */ - ArrayListMultimap properties; + MultiValuedMap properties; /** * Target deploy repository. */ @@ -60,6 +58,7 @@ public class DeployDetails implements Comparable, Serializable, P * The package type generated this artifact's deploy details. */ private PackageType packageType; + /** * @return Return the target deployment repository. */ @@ -75,7 +74,7 @@ public File getFile() { return file; } - public ArrayListMultimap getProperties() { + public MultiValuedMap getProperties() { return properties; } @@ -88,11 +87,11 @@ public String getSha256() { } public void setSha256(String sha256) { - this.sha256=sha256; + this.sha256 = sha256; } public void setArtifactPath(String artifactPath) { - this.artifactPath=artifactPath; + this.artifactPath = artifactPath; } public Boolean getDeploySucceeded() { @@ -165,10 +164,8 @@ public DeployDetails build() { public Builder bean(BuildFileBean bean) { Properties beanProperties = bean.getProperties(); if (beanProperties != null) { - ArrayListMultimap multimap = ArrayListMultimap.create(); - for (Map.Entry entry : Maps.fromProperties(beanProperties).entrySet()) { - multimap.put(entry.getKey(), entry.getValue()); - } + MultiValuedMap multimap = MultiMapUtils.newListValuedHashMap(); + beanProperties.forEach((key, value) -> multimap.put((String) key, (String) value)); deployDetails.properties = multimap; } deployDetails.sha1 = bean.getSha1(); @@ -218,7 +215,7 @@ public Builder packageType(PackageType packageType) { public Builder addProperty(String key, String value) { if (deployDetails.properties == null) { - deployDetails.properties = ArrayListMultimap.create(); + deployDetails.properties = MultiMapUtils.newListValuedHashMap(); } deployDetails.properties.put(key, value); return this; @@ -226,16 +223,16 @@ public Builder addProperty(String key, String value) { public Builder addProperties(Map propertiesToAdd) { if (deployDetails.properties == null) { - deployDetails.properties = ArrayListMultimap.create(); + deployDetails.properties = MultiMapUtils.newListValuedHashMap(); } - deployDetails.properties.putAll(Multimaps.forMap(propertiesToAdd)); + deployDetails.properties.putAll(propertiesToAdd); return this; } - public Builder addProperties(Multimap propertiesToAdd) { + public Builder addProperties(MultiValuedMap propertiesToAdd) { if (deployDetails.properties == null) { - deployDetails.properties = ArrayListMultimap.create(); + deployDetails.properties = MultiMapUtils.newListValuedHashMap(); } deployDetails.properties.putAll(propertiesToAdd); diff --git a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/DependenciesDownloaderHelper.java b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/DependenciesDownloaderHelper.java index f74280baf..22c3501b0 100644 --- a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/DependenciesDownloaderHelper.java +++ b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/DependenciesDownloaderHelper.java @@ -1,6 +1,5 @@ package org.jfrog.build.extractor.clientConfiguration.util; -import com.google.common.io.Files; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.BooleanUtils; @@ -22,6 +21,8 @@ import org.jfrog.filespecs.entities.FilesGroup; import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; import java.security.NoSuchAlgorithmException; import java.util.*; import java.util.regex.Pattern; @@ -245,15 +246,15 @@ protected Map downloadFile(String downloadPath, String fileDesti protected Map downloadFileConcurrently(final String uriWithParams, long fileSize, final String fileDestination, String filePath) throws Exception { String[] downloadedFilesPaths; - File tempDir = Files.createTempDir(); - String tempPath = tempDir.getPath() + File.separatorChar + filePath; + Path tempDir = Files.createTempDirectory("downloadFileConcurrently"); + Path tempPath = tempDir.resolve(filePath); try { - downloadedFilesPaths = doConcurrentDownload(fileSize, uriWithParams, tempPath); + downloadedFilesPaths = doConcurrentDownload(fileSize, uriWithParams, tempPath.toString()); try (InputStream inputStream = concatenateFilesToSingleStream(downloadedFilesPaths)) { return downloader.saveDownloadedFile(inputStream, fileDestination); } } finally { - FileUtils.deleteDirectory(tempDir); + FileUtils.deleteDirectory(tempDir.toFile()); } } diff --git a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/DeploymentUrlUtils.java b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/DeploymentUrlUtils.java index e4b08a44f..9cf71f1bc 100644 --- a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/DeploymentUrlUtils.java +++ b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/DeploymentUrlUtils.java @@ -1,6 +1,6 @@ package org.jfrog.build.extractor.clientConfiguration.util; -import com.google.common.collect.ArrayListMultimap; +import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.lang3.StringUtils; import org.jfrog.build.api.util.CommonUtils; import org.jfrog.build.extractor.UrlUtils; @@ -66,7 +66,7 @@ public static String encodePath(String unescaped) { } - public static String buildMatrixParamsString(ArrayListMultimap matrixParams, boolean encodeProperties) + public static String buildMatrixParamsString(MultiValuedMap matrixParams, boolean encodeProperties) throws UnsupportedEncodingException { StringBuilder matrix = new StringBuilder(); if (matrixParams != null && !matrixParams.isEmpty()) { diff --git a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/PublishedItemsHelper.java b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/PublishedItemsHelper.java index ea78e4474..1ead29be1 100644 --- a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/PublishedItemsHelper.java +++ b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/PublishedItemsHelper.java @@ -16,8 +16,8 @@ package org.jfrog.build.extractor.clientConfiguration.util; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; +import org.apache.commons.collections4.MultiMapUtils; +import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; import org.jfrog.build.extractor.clientConfiguration.util.spec.UploadSpecHelper; @@ -45,8 +45,8 @@ public class PublishedItemsHelper { * then the value is treated as a source only (target will be ""). * @return a Map containing the sources as keys and targets as values */ - public static Multimap getPublishedItemsPatternPairs(String publishedItemsPropertyValue) { - Multimap patternPairMap = HashMultimap.create(); + public static MultiValuedMap getPublishedItemsPatternPairs(String publishedItemsPropertyValue) { + MultiValuedMap patternPairMap = MultiMapUtils.newSetValuedHashMap(); if (StringUtils.isNotBlank(publishedItemsPropertyValue)) { List patternPairs = parsePatternsFromProperty(publishedItemsPropertyValue); @@ -148,9 +148,9 @@ public static String removeDoubleDotsFromPattern(String pattern) { * @throws IOException in case of any file system exception */ @Deprecated - public static Multimap buildPublishingData(File checkoutDir, String pattern, String targetPath) + public static MultiValuedMap buildPublishingData(File checkoutDir, String pattern, String targetPath) throws IOException { - final Multimap filePathsMap = HashMultimap.create(); + final MultiValuedMap filePathsMap = MultiMapUtils.newSetValuedHashMap(); File patternAbsolutePath = getAbsolutePath(checkoutDir, pattern); if (patternAbsolutePath.isFile()) { // The given pattern is an absolute path of just one file, let's add it to our result map @@ -211,7 +211,7 @@ public static Multimap buildPublishingData(File checkoutDir, Strin * @return a Multimap containing the targets as keys and the files as values */ @Deprecated - public static Multimap wildCardBuildPublishingData( + public static MultiValuedMap wildCardBuildPublishingData( File checkoutDir, String pattern, String targetPath, boolean flat, boolean isRecursive, boolean regexp) { if (!regexp) { pattern = PathsUtils.pathToRegExp(pattern); diff --git a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/spec/SingleSpecDeploymentProducer.java b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/spec/SingleSpecDeploymentProducer.java index 774a09563..1d63adcbe 100644 --- a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/spec/SingleSpecDeploymentProducer.java +++ b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/spec/SingleSpecDeploymentProducer.java @@ -1,6 +1,6 @@ package org.jfrog.build.extractor.clientConfiguration.util.spec; -import com.google.common.collect.Multimap; +import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; @@ -20,14 +20,13 @@ /** * Actual FileSpec performer, scans the file-system for matching files and creates the deployment data. * Handles a single Spec from the 'files' section of a FileSpec. - * * Created by Bar Belity on 07/03/2018. */ public class SingleSpecDeploymentProducer { private FilesGroup spec; private File workspace; - private Multimap buildProperties; + private MultiValuedMap buildProperties; private Pattern regexpPattern; private Pattern regexpExcludePattern; @@ -43,7 +42,7 @@ public class SingleSpecDeploymentProducer { private int separatorsCount; private Set symlinkSet = new HashSet<>(); - SingleSpecDeploymentProducer(FilesGroup spec, File workspace, Multimap buildProperties) { + SingleSpecDeploymentProducer(FilesGroup spec, File workspace, MultiValuedMap buildProperties) { this.spec = spec; this.workspace = workspace; this.buildProperties = buildProperties; @@ -52,6 +51,7 @@ public class SingleSpecDeploymentProducer { /** * Executes a single FileSpec. * Find all files matching the spec, create and publish its DeployDetails. + * * @param deploymentSet Set containing the DeployDetails to deploy */ public void executeSpec(Set deploymentSet, ProducerConsumerExecutor executor) @@ -136,8 +136,9 @@ private void init() throws FileNotFoundException { /** * Check all file candidates for upload in the provided directory, to specified depth. - * @param dir base directory to start search for files - * @param depth level of folders to search in + * + * @param dir base directory to start search for files + * @param depth level of folders to search in * @param deploymentSet Set containing the DeployDetails to deploy */ private void collectFiles(String dir, int depth, Set deploymentSet, ProducerConsumerExecutor executor) @@ -195,7 +196,8 @@ private void collectFiles(String dir, int depth, Set deploymentSe /** * Receives a candidate file to upload, creates DeployDetails for the file in case should upload it. * Adds the DeployDetails to the BlockingQueue. - * @param file upload candidate + * + * @param file upload candidate * @param deploymentSet Set containing the DeployDetails to deploy */ private void processDeployCandidate(File file, Set deploymentSet, ProducerConsumerExecutor executor) @@ -223,11 +225,12 @@ private void processDeployCandidate(File file, Set deploymentSet, /** * Checks if the provided file path matches spec's patterns - * @param filePath to candidate file - * @param regexpPattern regexp to matched files + * + * @param filePath to candidate file + * @param regexpPattern regexp to matched files * @param regexpExcludePattern regexp to excluded files - * @param workspaceDir File object that represents the workspace - * @param baseDirFile the directory to get files from + * @param workspaceDir File object that represents the workspace + * @param baseDirFile the directory to get files from * @return true if the file path matches all terms */ private static boolean isFileMatchPattern(String filePath, Pattern regexpPattern, Pattern regexpExcludePattern, @@ -250,6 +253,7 @@ private static boolean isFileMatchPattern(String filePath, Pattern regexpPattern /** * Throws exception if more than 1M files to deploy found + * * @param numberOfFiles the number of artifacts to deploy */ private static void validateUploadLimit(int numberOfFiles) { diff --git a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/spec/SpecDeploymentProducer.java b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/spec/SpecDeploymentProducer.java index 501f19571..79948e93a 100644 --- a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/spec/SpecDeploymentProducer.java +++ b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/spec/SpecDeploymentProducer.java @@ -1,6 +1,6 @@ package org.jfrog.build.extractor.clientConfiguration.util.spec; -import com.google.common.collect.Multimap; +import org.apache.commons.collections4.MultiValuedMap; import org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails; import org.jfrog.build.extractor.producerConsumer.ProducerRunnableBase; import org.jfrog.filespecs.FileSpec; @@ -12,7 +12,6 @@ /** * Producer object to use with the ProducerConsumerExecutor during artifact deployment by filespec operation. - * * Created by Bar Belity on 27/03/2018. */ public class SpecDeploymentProducer extends ProducerRunnableBase { @@ -24,9 +23,9 @@ public class SpecDeploymentProducer extends ProducerRunnableBase { private FileSpec spec; private File workspace; - private Multimap buildProperties; + private MultiValuedMap buildProperties; - SpecDeploymentProducer(FileSpec spec, File workspace, Multimap buildProperties) { + SpecDeploymentProducer(FileSpec spec, File workspace, MultiValuedMap buildProperties) { this.spec = spec; this.workspace = workspace; this.buildProperties = buildProperties; diff --git a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/spec/SpecsHelper.java b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/spec/SpecsHelper.java index 9b9360ae7..ad2b7eba9 100644 --- a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/spec/SpecsHelper.java +++ b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/spec/SpecsHelper.java @@ -1,13 +1,13 @@ package org.jfrog.build.extractor.clientConfiguration.util.spec; -import com.google.common.collect.ArrayListMultimap; -import com.google.common.collect.Multimap; +import org.apache.commons.collections4.MultiMapUtils; +import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; +import org.jfrog.build.api.util.Log; import org.jfrog.build.extractor.builder.ArtifactBuilder; import org.jfrog.build.extractor.ci.Artifact; import org.jfrog.build.extractor.ci.Dependency; -import org.jfrog.build.api.util.Log; import org.jfrog.build.extractor.clientConfiguration.ArtifactoryManagerBuilder; import org.jfrog.build.extractor.clientConfiguration.client.artifactory.ArtifactoryManager; import org.jfrog.build.extractor.clientConfiguration.deploy.DeployDetails; @@ -21,11 +21,7 @@ import java.io.File; import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import static org.jfrog.build.api.util.CommonUtils.handleJavaTmpdirProperty; import static org.jfrog.build.client.PreemptiveHttpClientBuilder.CONNECTION_POOL_SIZE; @@ -61,8 +57,8 @@ public List uploadArtifactsBySpec(String uploadSpec, File workspace, return uploadArtifactsBySpec(uploadSpec, DEFAULT_NUMBER_OF_THREADS, workspace, createMultiMap(buildProperties), artifactoryManagerBuilder); } - private static Multimap createMultiMap(Map input) { - Multimap multimap = ArrayListMultimap.create(); + private static MultiValuedMap createMultiMap(Map input) { + MultiValuedMap multimap = MultiMapUtils.newListValuedHashMap(); for (Map.Entry entry : input.entrySet()) { multimap.put(entry.getKey(), entry.getValue()); } @@ -82,7 +78,7 @@ private static Multimap createMultiMap(Map input) { * checksums or in case of any file system exception */ public List uploadArtifactsBySpec(String uploadSpec, int numberOfThreads, File workspace, - Multimap buildProperties, + MultiValuedMap buildProperties, ArtifactoryManagerBuilder artifactoryManagerBuilder) throws Exception { FileSpec fileSpec = FileSpec.fromString(uploadSpec); FileSpecsValidation.validateUploadFileSpec(fileSpec, this.log); @@ -157,13 +153,13 @@ public boolean editPropertiesBySpec(String spec, ArtifactoryManager artifactoryM * @param props Spec's properties * @return created properties map */ - public static ArrayListMultimap getPropertiesMap(String props) { - ArrayListMultimap propertiesMap = ArrayListMultimap.create(); + public static MultiValuedMap getPropertiesMap(String props) { + MultiValuedMap propertiesMap = MultiMapUtils.newListValuedHashMap(); fillPropertiesMap(props, propertiesMap); return propertiesMap; } - public static void fillPropertiesMap(String props, ArrayListMultimap propertiesMap) { + public static void fillPropertiesMap(String props, MultiValuedMap propertiesMap) { if (StringUtils.isBlank(props)) { return; } diff --git a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/spec/UploadSpecHelper.java b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/spec/UploadSpecHelper.java index 2091feaed..396b8aae3 100644 --- a/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/spec/UploadSpecHelper.java +++ b/build-info-extractor/src/main/java/org/jfrog/build/extractor/clientConfiguration/util/spec/UploadSpecHelper.java @@ -1,7 +1,7 @@ package org.jfrog.build.extractor.clientConfiguration.util.spec; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; +import org.apache.commons.collections4.MultiValuedMap; +import org.apache.commons.collections4.multimap.HashSetValuedHashMap; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.BooleanUtils; @@ -18,9 +18,7 @@ import java.util.Map; import java.util.regex.Pattern; -import static org.jfrog.build.api.util.FileChecksumCalculator.MD5_ALGORITHM; -import static org.jfrog.build.api.util.FileChecksumCalculator.SHA1_ALGORITHM; -import static org.jfrog.build.api.util.FileChecksumCalculator.SHA256_ALGORITHM; +import static org.jfrog.build.api.util.FileChecksumCalculator.*; import static org.jfrog.build.extractor.clientConfiguration.util.PathsUtils.removeUnescapedChar; /** @@ -40,7 +38,7 @@ public class UploadSpecHelper { */ public static DeployDetails buildDeployDetails(String targetPath, File artifactFile, String uploadTarget, String explode, String props, - Multimap buildProperties) + MultiValuedMap buildProperties) throws IOException, NoSuchAlgorithmException { String path = UploadSpecHelper.wildcardCalculateTargetPath(targetPath, artifactFile); path = StringUtils.replace(path, "//", "/"); @@ -153,9 +151,9 @@ protected static String getUploadPath(File file, Pattern pathPattern, String tar return PathsUtils.reformatRegexp(sourcePath, fileTargetPath.replace('\\', '/'), pathPattern); } - public static Multimap getUploadPathsMap(List files, File workspaceDir, String targetPath, - boolean isFlat, Pattern regexPattern, boolean isAbsolutePath) { - Multimap filePathsMap = HashMultimap.create(); + public static MultiValuedMap getUploadPathsMap(List files, File workspaceDir, String targetPath, + boolean isFlat, Pattern regexPattern, boolean isAbsolutePath) { + MultiValuedMap filePathsMap = new HashSetValuedHashMap<>(); boolean isTargetDirectory = StringUtils.endsWith(targetPath, "/"); for (File file : files) { diff --git a/build-info-extractor/src/main/java/org/jfrog/build/extractor/executor/CommandExecutor.java b/build-info-extractor/src/main/java/org/jfrog/build/extractor/executor/CommandExecutor.java index 2d5161e8b..f1f907123 100644 --- a/build-info-extractor/src/main/java/org/jfrog/build/extractor/executor/CommandExecutor.java +++ b/build-info-extractor/src/main/java/org/jfrog/build/extractor/executor/CommandExecutor.java @@ -1,6 +1,5 @@ package org.jfrog.build.extractor.executor; -import com.google.common.collect.Maps; import org.apache.commons.lang3.SystemUtils; import org.jfrog.build.api.util.Log; import org.jfrog.build.extractor.UrlUtils; @@ -182,7 +181,7 @@ private CommandResults getCommandResults(boolean terminatedProperly, List args, List credentials, Map env, Log logger) throws IOException { // Make sure to copy the environment variables map to avoid changing the original map or in case it is immutable. - Map newEnv = Maps.newHashMap(env); + Map newEnv = new HashMap<>(env); args = formatCommand(args, credentials, executablePath, newEnv); logCommand(logger, args, credentials); diff --git a/build-info-extractor/src/main/java/org/jfrog/build/extractor/scan/Issue.java b/build-info-extractor/src/main/java/org/jfrog/build/extractor/scan/Issue.java index 82c96d0f2..0246b9790 100644 --- a/build-info-extractor/src/main/java/org/jfrog/build/extractor/scan/Issue.java +++ b/build-info-extractor/src/main/java/org/jfrog/build/extractor/scan/Issue.java @@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonInclude; import org.apache.commons.lang3.StringUtils; -import javax.annotation.Nonnull; import java.util.List; import java.util.Objects; @@ -96,7 +95,7 @@ public boolean isHigherSeverityThan(Issue o) { } @Override - public int compareTo(@Nonnull Issue otherIssue) { + public int compareTo(Issue otherIssue) { return Integer.compare(hashCode(), Objects.hashCode(otherIssue)); } diff --git a/build-info-extractor/src/test/java/org/jfrog/build/extractor/client/ArtifactSpecTest.java b/build-info-extractor/src/test/java/org/jfrog/build/extractor/client/ArtifactSpecTest.java index afc5a2de5..78c123872 100644 --- a/build-info-extractor/src/test/java/org/jfrog/build/extractor/client/ArtifactSpecTest.java +++ b/build-info-extractor/src/test/java/org/jfrog/build/extractor/client/ArtifactSpecTest.java @@ -1,9 +1,10 @@ package org.jfrog.build.extractor.client; -import com.google.common.collect.ImmutableMap; import org.jfrog.build.extractor.clientConfiguration.ArtifactSpec; import org.testng.annotations.Test; +import java.util.HashMap; + import static org.testng.Assert.*; @@ -14,7 +15,7 @@ public class ArtifactSpecTest { @Test - public void stringConstruction() throws Exception { + public void stringConstruction() { ArtifactSpec standard = ArtifactSpec.newSpec("conf grp:art:ver:cls@jar k1:v1, k2:v2 , k3: v3"); ArtifactSpec noPropSpaces = ArtifactSpec.newSpec("conf grp:art:ver:cls@jar k1:v1,k2:v2,k3:v3"); ArtifactSpec noConf = ArtifactSpec.newSpec("grp:art:ver:cls@jar k1:v1, k2:v2 , k3: v3"); @@ -26,41 +27,50 @@ public void stringConstruction() throws Exception { assertEquals(standard.getVersion(), "ver"); assertEquals(standard.getClassifier(), "cls"); assertEquals(standard.getType(), "jar"); - assertEquals(standard.getProperties(), ImmutableMap.of("k1", "v1", "k2", "v2", "k3", "v3")); - + assertEquals(standard.getProperties(), new HashMap() {{ + put("k1", "v1"); + put("k2", "v2"); + put("k3", "v3"); + }}); assertEquals(noPropSpaces.getConfiguration(), "conf"); assertEquals(noPropSpaces.getGroup(), "grp"); assertEquals(noPropSpaces.getName(), "art"); assertEquals(noPropSpaces.getVersion(), "ver"); assertEquals(noPropSpaces.getClassifier(), "cls"); assertEquals(noPropSpaces.getType(), "jar"); - assertEquals(noPropSpaces.getProperties(), ImmutableMap.of("k1", "v1", "k2", "v2", "k3", "v3")); - + assertEquals(noPropSpaces.getProperties(), new HashMap() {{ + put("k1", "v1"); + put("k2", "v2"); + put("k3", "v3"); + }}); assertEquals(noConf.getConfiguration(), "*"); assertEquals(noConf.getGroup(), "grp"); assertEquals(noConf.getName(), "art"); assertEquals(noConf.getVersion(), "ver"); assertEquals(noConf.getClassifier(), "cls"); assertEquals(noConf.getType(), "jar"); - assertEquals(noConf.getProperties(), ImmutableMap.of("k1", "v1", "k2", "v2", "k3", "v3")); + assertEquals(noConf.getProperties(), new HashMap() {{ + put("k1", "v1"); + put("k2", "v2"); + put("k3", "v3"); + }}); - try { - ArtifactSpec noProps = ArtifactSpec.newSpec("all grp:art:ver:cls@jar"); - fail("Artifact spec cannot be constructed from string without a properties notation."); - } catch (IllegalArgumentException e) { - //Expected - } + assertThrows(IllegalArgumentException.class, () -> ArtifactSpec.newSpec("all grp:art:ver:cls@jar")); assertEquals(allConf.getConfiguration(), "*"); assertEquals(allConf.getGroup(), "grp"); assertEquals(allConf.getName(), "art"); assertEquals(allConf.getVersion(), "ver"); assertEquals(allConf.getClassifier(), "cls"); assertEquals(allConf.getType(), "jar"); - assertEquals(allConf.getProperties(), ImmutableMap.of("k1", "v1", "k2", "v2", "k3", "v3")); + assertEquals(allConf.getProperties(), new HashMap() {{ + put("k1", "v1"); + put("k2", "v2"); + put("k3", "v3"); + }}); } @Test - public void matches() throws Exception { + public void matches() { ArtifactSpec spec = ArtifactSpec.builder().configuration("conf").group("grp").name("art").version("ver").classifier("cls") .type("jar").build(); @@ -89,7 +99,7 @@ public void matches() throws Exception { } @Test - public void matchesWithNull1() throws Exception { + public void matchesWithNull1() { ArtifactSpec spec = ArtifactSpec.builder().configuration(null).group("org.jfrog").name("shared") .version("1.0") @@ -99,9 +109,9 @@ public void matchesWithNull1() throws Exception { } @Test - public void matchesWithNull2() throws Exception { + public void matchesWithNull2() { ArtifactSpec spec = ArtifactSpec.builder().group("org.jfrog").name("shared") - .version("1.0").build(); + .version("1.0").build(); someTests(spec); } diff --git a/build-info-extractor/src/test/java/org/jfrog/build/extractor/client/DeploymentUrlUtilsTest.java b/build-info-extractor/src/test/java/org/jfrog/build/extractor/client/DeploymentUrlUtilsTest.java index 6eee87c61..d4eadf916 100644 --- a/build-info-extractor/src/test/java/org/jfrog/build/extractor/client/DeploymentUrlUtilsTest.java +++ b/build-info-extractor/src/test/java/org/jfrog/build/extractor/client/DeploymentUrlUtilsTest.java @@ -1,6 +1,7 @@ package org.jfrog.build.extractor.client; -import com.google.common.collect.ArrayListMultimap; +import org.apache.commons.collections4.MultiMapUtils; +import org.apache.commons.collections4.MultiValuedMap; import org.jfrog.build.extractor.clientConfiguration.ClientProperties; import org.jfrog.build.extractor.clientConfiguration.util.DeploymentUrlUtils; import org.testng.Assert; @@ -35,7 +36,7 @@ public void getDeploymentUrlWithEncodingNeeded() throws UnsupportedEncodingExcep public void testKeyWithMultiValuesParam() throws UnsupportedEncodingException { - ArrayListMultimap params = ArrayListMultimap.create(); + MultiValuedMap params = MultiMapUtils.newListValuedHashMap(); params.put("key", "valueA"); params.put("key", "valueB"); params.put("keyA", "valueA"); diff --git a/build-info-extractor/src/test/java/org/jfrog/build/extractor/executor/CommandExecutorTest.java b/build-info-extractor/src/test/java/org/jfrog/build/extractor/executor/CommandExecutorTest.java index c5cd361b2..4bcd113da 100644 --- a/build-info-extractor/src/test/java/org/jfrog/build/extractor/executor/CommandExecutorTest.java +++ b/build-info-extractor/src/test/java/org/jfrog/build/extractor/executor/CommandExecutorTest.java @@ -1,6 +1,5 @@ package org.jfrog.build.extractor.executor; -import com.google.common.collect.Maps; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.SystemUtils; import org.apache.commons.lang3.exception.ExceptionUtils; @@ -17,6 +16,7 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -98,7 +98,7 @@ public void testGenerateWindowsEnv() throws IOException { } File projectDir = Files.createTempDirectory("").toFile(); try { - Map env = Maps.newHashMap(System.getenv()); + Map env = new HashMap<>(System.getenv()); Path execPath = Paths.get("C:\\Program Files\\Go\\bin\\go"); CommandExecutor.addToWindowsPath(env, execPath); assertTrue(env.get("Path").startsWith("C:\\Program Files\\Go\\bin")); diff --git a/build-info-extractor/src/test/java/org/jfrog/build/extractor/util/PublishedItemsHelperTest.java b/build-info-extractor/src/test/java/org/jfrog/build/extractor/util/PublishedItemsHelperTest.java index a02e5cf64..8272d0f16 100644 --- a/build-info-extractor/src/test/java/org/jfrog/build/extractor/util/PublishedItemsHelperTest.java +++ b/build-info-extractor/src/test/java/org/jfrog/build/extractor/util/PublishedItemsHelperTest.java @@ -1,6 +1,6 @@ package org.jfrog.build.extractor.util; -import com.google.common.collect.Multimap; +import org.apache.commons.collections4.MultiValuedMap; import org.apache.commons.io.FilenameUtils; import org.jfrog.build.extractor.clientConfiguration.util.PublishedItemsHelper; import org.testng.annotations.BeforeClass; @@ -32,9 +32,9 @@ public void setup() { } public void testDoubleDotWithStartWildcard() throws IOException { - Multimap pairs = getPublishedItemsPatternPairs("../../saas/**/*.xml=>target/xml"); + MultiValuedMap pairs = getPublishedItemsPatternPairs("../../saas/**/*.xml=>target/xml"); for (final Map.Entry entry : pairs.entries()) { - Multimap buildPublishingData = getBuildPublishingData(entry); + MultiValuedMap buildPublishingData = getBuildPublishingData(entry); assertEquals(buildPublishingData.size(), 2, "Expected to find 2 files"); for (Map.Entry fileEntry : buildPublishingData.entries()) { String targetPath = PublishedItemsHelper.calculateTargetPath(fileEntry.getKey(), fileEntry.getValue()); @@ -45,10 +45,10 @@ public void testDoubleDotWithStartWildcard() throws IOException { } public void testAbsolutePath() throws IOException { - Multimap pairs = getPublishedItemsPatternPairs( + MultiValuedMap pairs = getPublishedItemsPatternPairs( absoluteFile.getAbsolutePath() + "=>jaja/gululu"); for (final Map.Entry entry : pairs.entries()) { - Multimap buildPublishingData = getBuildPublishingData(entry); + MultiValuedMap buildPublishingData = getBuildPublishingData(entry); assertEquals(buildPublishingData.size(), 1, "Expected to find 1 files"); assertTrue(buildPublishingData.containsValue(absoluteFile), "Expected to find the absolute file"); for (Map.Entry fileEntry : buildPublishingData.entries()) { @@ -59,9 +59,9 @@ public void testAbsolutePath() throws IOException { } public void testAbsolutePathSameWorkspace() throws IOException { - Multimap pairs = getPublishedItemsPatternPairs(checkoutDir.getAbsolutePath() + "/inner/*.gradle" + "=>test/props"); + MultiValuedMap pairs = getPublishedItemsPatternPairs(checkoutDir.getAbsolutePath() + "/inner/*.gradle" + "=>test/props"); for (final Map.Entry entry : pairs.entries()) { - Multimap buildPublishingData = getBuildPublishingData(entry); + MultiValuedMap buildPublishingData = getBuildPublishingData(entry); assertEquals(buildPublishingData.size(), 1, "Expected to find 1 file"); for (Map.Entry fileEntry : buildPublishingData.entries()) { String targetPath = PublishedItemsHelper.calculateTargetPath(fileEntry.getKey(), fileEntry.getValue()); @@ -72,14 +72,14 @@ public void testAbsolutePathSameWorkspace() throws IOException { public void testMultiPatterns() throws IOException { String pattern = "**/multi1/*=>test/multi1, **multi2/*=>test/multi2"; - Multimap pairs = getPublishedItemsPatternPairs(pattern); + MultiValuedMap pairs = getPublishedItemsPatternPairs(pattern); assertEquals(pairs.keySet().size(), 2, "Expected to find 2 keys"); } public void testAllWorkspace() throws IOException { - Multimap pairs = getPublishedItemsPatternPairs("**"); + MultiValuedMap pairs = getPublishedItemsPatternPairs("**"); for (final Map.Entry entry : pairs.entries()) { - Multimap buildPublishingData = getBuildPublishingData(entry); + MultiValuedMap buildPublishingData = getBuildPublishingData(entry); assertEquals(buildPublishingData.size(), 6, "Expected to find 6 files"); } } @@ -87,17 +87,17 @@ public void testAllWorkspace() throws IOException { public void testAbsolutePathWithDoubleStar() throws IOException { File resourceAsFile = getResourceAsFile("/root/workspace"); String fileAbsolutePath = FilenameUtils.separatorsToUnix(resourceAsFile.getAbsolutePath()); - Multimap pairs = getPublishedItemsPatternPairs(fileAbsolutePath + "/ant/**"); + MultiValuedMap pairs = getPublishedItemsPatternPairs(fileAbsolutePath + "/ant/**"); for (final Map.Entry entry : pairs.entries()) { - Multimap buildPublishingData = getBuildPublishingData(entry); + MultiValuedMap buildPublishingData = getBuildPublishingData(entry); assertEquals(buildPublishingData.size(), 7, "Expected to find 7 files"); } } public void testAllSpecificFilesFromCheckoutDir() throws IOException { - Multimap pairs = getPublishedItemsPatternPairs("**/*.blabla=>blabla"); + MultiValuedMap pairs = getPublishedItemsPatternPairs("**/*.blabla=>blabla"); for (final Map.Entry entry : pairs.entries()) { - Multimap buildPublishingData = getBuildPublishingData(entry); + MultiValuedMap buildPublishingData = getBuildPublishingData(entry); assertEquals(buildPublishingData.size(), 2, "Expected to find 2 files"); for (Map.Entry fileEntry : buildPublishingData.entries()) { String targetPath = PublishedItemsHelper.calculateTargetPath(fileEntry.getKey(), fileEntry.getValue()); @@ -107,9 +107,9 @@ public void testAllSpecificFilesFromCheckoutDir() throws IOException { } public void testEmptyTargetPath() throws IOException { - Multimap pairs = getPublishedItemsPatternPairs("../../**/**/*.xml"); + MultiValuedMap pairs = getPublishedItemsPatternPairs("../../**/**/*.xml"); for (final Map.Entry entry : pairs.entries()) { - Multimap buildPublishingData = getBuildPublishingData(entry); + MultiValuedMap buildPublishingData = getBuildPublishingData(entry); assertEquals(buildPublishingData.size(), 2, "Expected to find 2 files"); for (Map.Entry fileEntry : buildPublishingData.entries()) { String targetPath = PublishedItemsHelper.calculateTargetPath(fileEntry.getKey(), fileEntry.getValue()); @@ -118,11 +118,11 @@ public void testEmptyTargetPath() throws IOException { } } - private Multimap getPublishedItemsPatternPairs(String pattern) { + private MultiValuedMap getPublishedItemsPatternPairs(String pattern) { return PublishedItemsHelper.getPublishedItemsPatternPairs(pattern); } - private Multimap getBuildPublishingData(Map.Entry entry) throws IOException { + private MultiValuedMap getBuildPublishingData(Map.Entry entry) throws IOException { return PublishedItemsHelper.buildPublishingData(checkoutDir, entry.getKey(), entry.getValue()); } diff --git a/build-info-parent/pom.xml b/build-info-parent/pom.xml index 370978e34..55e7bd838 100644 --- a/build-info-parent/pom.xml +++ b/build-info-parent/pom.xml @@ -46,12 +46,6 @@ - - com.google.guava - guava - r08 - - org.apache.commons commons-lang3 diff --git a/build.gradle b/build.gradle index a450cddf0..c54358561 100644 --- a/build.gradle +++ b/build.gradle @@ -9,6 +9,7 @@ buildscript { commonsIoVersion = '2.11.0' commonsLang3Version = '3.12.0' commonsLoggingVersion = '1.2' + commonsCollections4Version = '4.4' dockerJavaVersion = '3.3.3' easymockclassextensionVersion = '3.2' eclipseAetherVersion = '1.1.0' @@ -18,7 +19,6 @@ buildscript { gradleVersionsPluginVersion = '0.42.0' groovyAllVersion = '3.0.13' - guavaVersion = '32.1.3-jre' httpClientVersion = '4.5.14' httpCoreVersion = '4.4.16' ivyVersion = '2.5.2' @@ -134,6 +134,7 @@ subprojects { implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: jacksonVersion implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: jacksonVersion implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: jacksonVersion + implementation group: 'org.apache.commons', name: 'commons-collections4', version: commonsCollections4Version implementation group: 'org.apache.commons', name: 'commons-compress', version: commonsCompressVersion implementation("org.apache.httpcomponents:httpclient:$httpClientVersion") { @@ -142,7 +143,6 @@ subprojects { implementation "org.apache.httpcomponents:httpcore:$httpCoreVersion" implementation "commons-codec:commons-codec:$commonsCodecVersion" - implementation group: 'com.google.guava', name: 'guava', 'version': guavaVersion implementation group: 'org.jfrog.filespecs', name: 'file-specs-java', version: fileSpecsJavaVersion testImplementation group: 'org.testng', name: 'testng', version: testNgVersion