Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Guava #793

Merged
merged 1 commit into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,7 +35,7 @@
import static org.jfrog.build.extractor.packageManager.PackageManagerUtils.createArtifactoryClientConfiguration;

public class BuildDockerCreator extends PackageManagerExtractor {
private final ArrayListMultimap<String, String> artifactProperties;
private final MultiValuedMap<String, String> artifactProperties;
private final ArtifactoryManagerBuilder artifactoryManagerBuilder;
private final ImageFileType imageFileType;
private final String sourceRepo;
Expand All @@ -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<String, String> artifactProperties, String sourceRepo, Log logger) {
MultiValuedMap<String, String> artifactProperties, String sourceRepo, Log logger) {
this.artifactoryManagerBuilder = artifactoryManagerBuilder;
this.artifactProperties = artifactProperties;
this.sourceRepo = sourceRepo;
Expand Down Expand Up @@ -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());

Expand Down Expand Up @@ -136,7 +137,7 @@ public BuildInfo execute() {
/**
* Update each layer's properties with artifactProperties.
*/
private void setImageLayersProps(DockerLayers layers, ArrayListMultimap<String, String> artifactProperties, ArtifactoryManagerBuilder artifactoryManagerBuilder) throws IOException {
private void setImageLayersProps(DockerLayers layers, MultiValuedMap<String, String> artifactProperties, ArtifactoryManagerBuilder artifactoryManagerBuilder) throws IOException {
if (layers == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -21,7 +22,7 @@
import static org.jfrog.build.extractor.packageManager.PackageManagerUtils.createArtifactoryClientConfiguration;

public class DockerPush extends DockerCommand {
private final ArrayListMultimap<String, String> artifactProperties;
private final MultiValuedMap<String, String> artifactProperties;


/**
Expand All @@ -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<String, String> artifactProperties, String targetRepository, String username,
String imageTag, String host, MultiValuedMap<String, String> artifactProperties, String targetRepository, String username,
String password, Log logger, Map<String, String> env) {
super(artifactoryManagerBuilder, imageTag, host, targetRepository, username, password, logger, env);
this.artifactProperties = artifactProperties;
Expand All @@ -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(),
Expand All @@ -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);
Expand All @@ -104,7 +105,7 @@ public BuildInfo execute() {
/**
* Update each layer's properties with artifactProperties.
*/
private void setImageLayersProps(DockerLayers layers, ArrayListMultimap<String, String> artifactProperties, ArtifactoryManagerBuilder artifactoryManagerBuilder) throws IOException {
private void setImageLayersProps(DockerLayers layers, MultiValuedMap<String, String> artifactProperties, ArtifactoryManagerBuilder artifactoryManagerBuilder) throws IOException {
if (layers == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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<String, String> artifactProperties = ArrayListMultimap.create();
private final MultiValuedMap<String, String> artifactProperties;
private String pullImageFromVirtual;
private String virtualDomainName;
private String host;
Expand All @@ -56,12 +56,12 @@ public DockerExtractorTest() {
localRepo1 = getKeyWithTimestamp(DOCKER_LOCAL_REPO);
remoteRepo = getKeyWithTimestamp(DOCKER_REMOTE_REPO);
virtualRepo = getKeyWithTimestamp(DOCKER_VIRTUAL_REPO);
artifactProperties.putAll(ImmutableMultimap.<String, String>builder()
.put("build.name", "docker-push-test")
.put("build.number", "1")
.put("build.timestamp", "321")
.put("property-key", "property-value")
.build());
artifactProperties = new ArrayListValuedHashMap<String, String>() {{
put("build.name", "docker-push-test");
put("build.number", "1");
put("build.timestamp", "321");
put("property-key", "property-value");
}};
}

@BeforeClass
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<String, String> properties;
private final MultiValuedMap<String, String> properties;
private final List<Artifact> artifactList = new ArrayList<>();
private final String deploymentRepo;
private final String version;
Expand All @@ -61,7 +62,7 @@ public class GoPublish extends GoCommand {
* @param version - The package's version.
* @param logger - The logger.
*/
public GoPublish(ArtifactoryManagerBuilder artifactoryManagerBuilder, ArrayListMultimap<String, String> properties, String repo, Path path, String version, String module, Log logger) throws IOException {
public GoPublish(ArtifactoryManagerBuilder artifactoryManagerBuilder, MultiValuedMap<String, String> 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();
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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<Path> pathFileTree = Files.walk(path)) {
Stream<Path> pathFileTree = Files.walk(path)) {
List<Path> 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()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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 {
Expand Down Expand Up @@ -202,7 +202,7 @@ private boolean excludeEntry(String entryName) {
private void scanEntries() {
Enumeration<? extends ZipEntry> entries = zipFile.getEntries();
ZipEntry zipEntry;
Set<String> allDirectories = Sets.newHashSet();
Set<String> allDirectories = new HashSet<>();
while (entries.hasMoreElements()) {
zipEntry = entries.nextElement();
if (!zipEntry.isDirectory() && isSubModule(zipEntry.getName())) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -176,7 +175,7 @@ public void goRunTest(Project project, String args, ArtifactoryManagerBuilder ar
@Test
public void goRunPublishTest() {
Path projectDir = null;
ArrayListMultimap<String, String> properties = ArrayListMultimap.create();
MultiValuedMap<String, String> properties = MultiMapUtils.newListValuedHashMap();
try {
// Run Go build on project1 locally
Project project = Project.PROJECT_1;
Expand Down
Loading
Loading