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 #114

Merged
merged 2 commits into from
Jun 13, 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
6 changes: 3 additions & 3 deletions .github/workflows/analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:
spotbugs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
# Install required tools
- name: Set up Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: "temurin"
distribution: "zulu"
java-version: "8"

# Run tests
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/frogbot-scan-and-fix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ jobs:
# The repository scanning will be triggered periodically on the following branches.
branch: [ "main" ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}

# Install prerequisites
- name: Set up Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: "8"
distribution: "temurin"
distribution: "zulu"

- uses: jfrog/frogbot@v2
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/frogbot-scan-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
runs-on: ubuntu-latest
environment: frogbot
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

# Install prerequisites
- name: Set up Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: "8"
distribution: "temurin"
distribution: "zulu"

- uses: jfrog/frogbot@v2
env:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ jobs:
- name: "Log if Already Exist"
run: echo "::warning::Version $LATEST_MVN_CENTRAL_VERSION already exist in the Gradle Gallery."
if: ${{ env.SHOULD_NOT_PUBLISH == 'TRUE'}}
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: refs/tags/${{ env.LATEST_MVN_CENTRAL_VERSION }}
if: ${{ env.SHOULD_NOT_PUBLISH != 'TRUE'}}
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: "temurin"
distribution: "zulu"
java-version: "11"
if: ${{ env.SHOULD_NOT_PUBLISH != 'TRUE'}}
- name: "Publish to Gradle Gallery"
Expand Down
13 changes: 10 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,23 @@ jobs:
os: [ ubuntu-latest, windows-latest, macOS-latest ]
java-version: [ "8", "11" ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
# Install required tools
- name: Set up Java
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
distribution: "temurin"
distribution: "zulu"
java-version: ${{ matrix.java-version }}

# Install Go for the Artifactory setup in the next step
- name: Setup Go
yahavi marked this conversation as resolved.
Show resolved Hide resolved
uses: actions/setup-go@v5
with:
go-version: 1.22.x
cache: false

- name: Setup Artifactory
env:
RTLIC: ${{ secrets.RTLIC }}
Expand Down
7 changes: 4 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ repositories {
mavenCentral()
}

val buildInfoVersion = "2.41.12"
val buildInfoVersion = "2.41.18"
val fileSpecsVersion = "1.1.2"
val commonsCollections4Version = "4.4"
val commonsLangVersion = "3.12.0"
val commonsIoVersion = "2.11.0"
val commonsTxtVersion = "1.10.0"
Expand All @@ -40,9 +41,9 @@ dependencies {
api("org.jfrog.buildinfo", "build-info-client", buildInfoVersion)
api("org.jfrog.filespecs", "file-specs-java", fileSpecsVersion)

implementation("org.apache.commons", "commons-collections4", commonsCollections4Version)
implementation("org.apache.commons", "commons-lang3", commonsLangVersion)
implementation("org.apache.ivy", "ivy", "2.5.2")
implementation("com.google.guava", "guava", "32.0.1-jre")

// Dependencies that are used by the build-info dependencies and need to be included in the UberJar
implementation("com.fasterxml.jackson.core", "jackson-databind", "2.14.1")
Expand Down Expand Up @@ -195,6 +196,6 @@ tasks.register<com.github.spotbugs.snom.SpotBugsTask>("spotBugs") {
}
}
excludeFilter.set(
file("${projectDir}/spotbugs-filter.xml")
file("${projectDir}/spotbugs-filter.xml")
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.commons.text.StringSubstitutor;
import org.gradle.testkit.runner.BuildResult;
Expand Down Expand Up @@ -53,7 +54,11 @@ public class GradleFunctionalTestBase {

@DataProvider
public Object[][] gradleVersions() {
return new Object[][]{{"6.8.1"}, {"7.5.1"}, {"7.6"}, {"8.1"}};
if (SystemUtils.IS_OS_MAC && SystemUtils.OS_ARCH.equals("aarch64")) {
// For Apple Silicon (ARM64), exclude Gradle 6 due to a known issue
return new Object[][]{{"7.5.1"}, {"7.6"}, {"8.8"}};
}
return new Object[][]{{"6.8.1"}, {"7.5.1"}, {"7.6"}, {"8.8"}};
}

@BeforeClass
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.jfrog.gradle.plugin.artifactory.extractor;

import com.google.common.collect.Sets;
import org.apache.commons.lang3.StringUtils;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
Expand Down Expand Up @@ -33,13 +32,10 @@
import java.io.File;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
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.getTypeString;
import static org.jfrog.gradle.plugin.artifactory.utils.PluginUtils.getModuleType;
Expand All @@ -62,7 +58,7 @@ public Module extractModule(Project project) {
*/
private Set<GradleDeployDetails> getCollectedDeployDetails(ArtifactoryTask artifactoryTask) {
if (artifactoryTask == null) {
return Sets.newHashSet();
return new HashSet<>();
}
return artifactoryTask.getDeployDetails();
}
Expand Down Expand Up @@ -129,7 +125,7 @@ private List<Dependency> calculateDependencies(Project project, String moduleId)
Map<String, String[][]> requestedByMap = artifactoryDependencyResolutionListener.getModulesHierarchyMap().get(moduleId);

Set<Configuration> configurationSet = project.getConfigurations();
List<Dependency> dependencies = newArrayList();
List<Dependency> 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());
Expand Down Expand Up @@ -164,10 +160,12 @@ private Dependency extractDependencyFromResolvedArtifact(Configuration configura
return null;
}
// New dependency to extract
Set<String> scopes = new HashSet<>();
scopes.add(configuration.getName());
DependencyBuilder dependencyBuilder = new DependencyBuilder()
.type(StringUtils.substringAfterLast(file.getName(), "."))
.id(depId)
.scopes(Sets.newHashSet(configuration.getName()));
.scopes(scopes);
if (requestedByMap != null) {
dependencyBuilder.requestedBy(requestedByMap.get(depId));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.jfrog.gradle.plugin.artifactory.task;

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.apache.commons.collections4.MultiMapUtils;
import org.apache.commons.collections4.MultiValuedMap;
import org.apache.commons.lang3.StringUtils;
import org.gradle.api.*;
import org.gradle.api.artifacts.Configuration;
Expand Down Expand Up @@ -51,7 +51,7 @@ public class ArtifactoryTask extends DefaultTask {
// Publication containers input
private final Set<Object> publications = new HashSet<>();
// Properties input
private final Multimap<String, CharSequence> properties = ArrayListMultimap.create();
private final MultiValuedMap<String, CharSequence> properties = MultiMapUtils.newSetValuedHashMap();
@Input
public final ArtifactSpecs artifactSpecs = new ArtifactSpecs();

Expand Down Expand Up @@ -394,7 +394,7 @@ public Set<Publication> getPublications() {
}

@Input
public Multimap<String, CharSequence> getProperties() {
public MultiValuedMap<String, CharSequence> getProperties() {
return properties;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.jfrog.gradle.plugin.artifactory.utils;

import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import org.gradle.api.Project;
import org.gradle.api.artifacts.ModuleVersionIdentifier;
import org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration;
Expand All @@ -13,6 +11,8 @@
import java.util.ArrayList;
import java.util.Objects;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;

public class ProjectUtils {

Expand Down Expand Up @@ -77,10 +77,12 @@ public static Iterable<GradleDeployDetails> filterIncludeExcludeDetails(Project
publisher.getIncludePatterns(),
publisher.getExcludePatterns());
if (publisher.isFilterExcludedArtifactsFromBuild()) {
return Iterables.filter(gradleDeployDetails, new IncludeExcludePredicate(project, patterns, isInclude));
} else {
return isInclude ? Iterables.filter(gradleDeployDetails, new ProjectPredicate(project)) : new ArrayList<>();
return gradleDeployDetails.stream().filter(new IncludeExcludePredicate(project, patterns, isInclude)).collect(Collectors.toSet());
}
if (!isInclude) {
return new ArrayList<>();
}
return gradleDeployDetails.stream().filter(new ProjectPredicate(project)).collect(Collectors.toSet());
}

public static class ProjectPredicate implements Predicate<GradleDeployDetails> {
Expand All @@ -90,7 +92,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;
}
Expand All @@ -109,7 +112,8 @@ public IncludeExcludePredicate(Project project, IncludeExcludePatterns patterns,
this.include = include;
}

public boolean apply(@Nullable GradleDeployDetails input) {
@Override
public boolean test(@Nullable GradleDeployDetails input) {
if (input == null || !Objects.equals(input.getProject(), project)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.jfrog.gradle.plugin.artifactory.utils;

import com.google.common.collect.Multimap;
import org.apache.commons.collections4.MultiValuedMap;
import org.apache.commons.lang3.StringUtils;
import org.apache.ivy.core.IvyPatternHelper;
import org.gradle.api.GradleException;
Expand Down Expand Up @@ -201,12 +201,12 @@ private static Map<String, String> getPropsToAdd(ArtifactoryTask destination, Pu
.name(project.getName()).version(project.getVersion().toString())
.classifier(artifact.getClassifier())
.type(artifact.getType()).build();
Multimap<String, CharSequence> artifactSpecsProperties = destination.artifactSpecs.getProperties(spec);
MultiValuedMap<String, CharSequence> artifactSpecsProperties = destination.artifactSpecs.getProperties(spec);
addProps(propsToAdd, artifactSpecsProperties);
return propsToAdd;
}

public static void addProps(Map<String, String> target, Multimap<String, CharSequence> props) {
public static void addProps(Map<String, String> target, MultiValuedMap<String, CharSequence> props) {
for (Map.Entry<String, CharSequence> entry : props.entries()) {
// Make sure all GString are now Java Strings
String key = entry.getKey();
Expand Down
Loading