From 8e79b25f6644582db55d6a5cf608c2ff5cbbecf6 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Thu, 11 May 2023 16:04:32 +0200 Subject: [PATCH] Remove runtime dependency on guava (fixes #19, #26) --- pom.xml | 12 +++++------ .../builder/smart/ReactorBuildStats.java | 20 ++++++++++++------- .../maven/builder/smart/SmartBuilder.java | 5 ++--- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index 92d3c97..8fa7de7 100644 --- a/pom.xml +++ b/pom.xml @@ -52,12 +52,6 @@ ${mavenResolverVersion} provided - - com.google.guava - guava - 31.0.1-jre - provided - @@ -79,5 +73,11 @@ pom test + + com.google.guava + guava + 31.0.1-jre + test + diff --git a/src/main/java/io/takari/maven/builder/smart/ReactorBuildStats.java b/src/main/java/io/takari/maven/builder/smart/ReactorBuildStats.java index 1e99ba0..27e28ee 100644 --- a/src/main/java/io/takari/maven/builder/smart/ReactorBuildStats.java +++ b/src/main/java/io/takari/maven/builder/smart/ReactorBuildStats.java @@ -1,9 +1,15 @@ package io.takari.maven.builder.smart; -import com.google.common.collect.ImmutableMap; import org.apache.maven.project.MavenProject; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicLong; import java.util.function.Function; @@ -32,8 +38,8 @@ class ReactorBuildStats { private ReactorBuildStats(Map serviceTimes, Map bottleneckTimes) { - this.serviceTimes = ImmutableMap.copyOf(serviceTimes); - this.bottleneckTimes = ImmutableMap.copyOf(bottleneckTimes); + this.serviceTimes = Collections.unmodifiableMap(serviceTimes); + this.bottleneckTimes = Collections.unmodifiableMap(bottleneckTimes); } private static String projectGAV(MavenProject project) { @@ -41,13 +47,13 @@ private static String projectGAV(MavenProject project) { } public static ReactorBuildStats create(Collection projects) { - ImmutableMap.Builder serviceTimes = ImmutableMap.builder(); - ImmutableMap.Builder bottleneckTimes = ImmutableMap.builder(); + Map serviceTimes = new HashMap<>(); + Map bottleneckTimes = new HashMap<>(); projects.stream().map(ReactorBuildStats::projectGAV).forEach(key -> { serviceTimes.put(key, new AtomicLong()); bottleneckTimes.put(key, new AtomicLong()); }); - return new ReactorBuildStats(serviceTimes.build(), bottleneckTimes.build()); + return new ReactorBuildStats(serviceTimes, bottleneckTimes); } public void recordStart() { diff --git a/src/main/java/io/takari/maven/builder/smart/SmartBuilder.java b/src/main/java/io/takari/maven/builder/smart/SmartBuilder.java index f26cacd..578e85f 100644 --- a/src/main/java/io/takari/maven/builder/smart/SmartBuilder.java +++ b/src/main/java/io/takari/maven/builder/smart/SmartBuilder.java @@ -8,6 +8,7 @@ import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; import javax.inject.Inject; import javax.inject.Named; @@ -24,8 +25,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Joiner; - /** * Trivial Maven {@link Builder} implementation. All interesting stuff happens in * {@link SmartBuilderImpl} . @@ -84,7 +83,7 @@ public synchronized void build(final MavenSession session, final ReactorContext final int degreeOfConcurrency = session.getRequest().getDegreeOfConcurrency(); if (logger.isDebugEnabled()) { - logger.debug("Task segments : {}", Joiner.on(" ").join(taskSegments)); + logger.debug("Task segments : {}", taskSegments); logger.debug("Build maximum degree of concurrency is {}", degreeOfConcurrency); logger.debug("Total number of projects is {}", graph.getProjects().count()); }