From 901dfc3dfe41690d09c7961766c49b2b9684c92e Mon Sep 17 00:00:00 2001 From: Marvin Froeder Date: Wed, 31 Oct 2018 14:49:43 +1300 Subject: [PATCH] Getting ride of guava --- .settings/org.eclipse.jdt.core.prefs | 1 + pom.xml | 8 +++++++- .../maven/builder/smart/ProjectComparator.java | 6 +++--- .../maven/builder/smart/ReactorBuildQueue.java | 6 ++---- .../maven/builder/smart/ReactorBuildStats.java | 13 ++++++------- .../io/takari/maven/builder/smart/SmartBuilder.java | 10 ++++------ .../maven/builder/smart/ProjectComparatorTest.java | 4 ++-- .../builder/smart/ProjectExecutorServiceTest.java | 2 +- 8 files changed, 26 insertions(+), 24 deletions(-) diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index c269d10..1f99e4d 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -2,6 +2,7 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.forbiddenReference=error +org.eclipse.jdt.core.compiler.release=disabled org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 diff --git a/pom.xml b/pom.xml index 556e5ce..793d991 100644 --- a/pom.xml +++ b/pom.xml @@ -44,12 +44,18 @@ maven-core ${mavenVersion} provided + + + com.google.guava + guava + + com.google.guava guava 18.0 - provided + test diff --git a/src/main/java/io/takari/maven/builder/smart/ProjectComparator.java b/src/main/java/io/takari/maven/builder/smart/ProjectComparator.java index 407f5d0..37a14ab 100644 --- a/src/main/java/io/takari/maven/builder/smart/ProjectComparator.java +++ b/src/main/java/io/takari/maven/builder/smart/ProjectComparator.java @@ -1,9 +1,11 @@ package io.takari.maven.builder.smart; import java.util.Collection; +import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicLong; @@ -13,8 +15,6 @@ import org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.project.MavenProject; -import com.google.common.collect.ImmutableMap; - /** * Project comparator (factory) that uses project build time to establish build order. *

@@ -38,7 +38,7 @@ class ProjectComparator { public static Comparator create(MavenSession session) { final ProjectDependencyGraph dependencyGraph = session.getProjectDependencyGraph(); - return create0(DependencyGraph.fromMaven(dependencyGraph), ImmutableMap.of(), p -> id(p)); + return create0(DependencyGraph.fromMaven(dependencyGraph), Collections.emptyMap(), p -> id(p)); } static Comparator create0(final DependencyGraph dependencyGraph, diff --git a/src/main/java/io/takari/maven/builder/smart/ReactorBuildQueue.java b/src/main/java/io/takari/maven/builder/smart/ReactorBuildQueue.java index 7777c13..7f9622a 100644 --- a/src/main/java/io/takari/maven/builder/smart/ReactorBuildQueue.java +++ b/src/main/java/io/takari/maven/builder/smart/ReactorBuildQueue.java @@ -8,8 +8,6 @@ import org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.project.MavenProject; -import com.google.common.collect.ImmutableSet; - /** * Reactor build queue manages reactor modules that are waiting for their upstream dependencies * build to finish. @@ -43,8 +41,8 @@ public ReactorBuildQueue(Collection projects, } } - this.rootProjects = ImmutableSet.copyOf(rootProjects); - this.projects = ImmutableSet.copyOf(projects); + this.rootProjects = new HashSet<>(rootProjects); + this.projects = new HashSet<>(projects); } /** 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 d494f85..0728dbc 100644 --- a/src/main/java/io/takari/maven/builder/smart/ReactorBuildStats.java +++ b/src/main/java/io/takari/maven/builder/smart/ReactorBuildStats.java @@ -4,6 +4,7 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -15,8 +16,6 @@ import org.apache.maven.execution.ProjectDependencyGraph; import org.apache.maven.project.MavenProject; -import com.google.common.collect.ImmutableMap; - class ReactorBuildStats { private long startTime; @@ -39,8 +38,8 @@ class ReactorBuildStats { private ReactorBuildStats(Map serviceTimes, Map bottleneckTimes) { - this.serviceTimes = ImmutableMap.copyOf(serviceTimes); - this.bottleneckTimes = ImmutableMap.copyOf(bottleneckTimes); + this.serviceTimes = new LinkedHashMap<>(serviceTimes); + this.bottleneckTimes = new LinkedHashMap<>(bottleneckTimes); } private static String projectGA(MavenProject project) { @@ -48,13 +47,13 @@ private static String projectGA(MavenProject project) { } public static ReactorBuildStats create(Collection projects) { - ImmutableMap.Builder serviceTimes = ImmutableMap.builder(); - ImmutableMap.Builder bottleneckTimes = ImmutableMap.builder(); + Map serviceTimes = new LinkedHashMap<>(); + Map bottleneckTimes = new LinkedHashMap<>(); projects.stream().map(project -> projectGA(project)).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 2dc8f05..7003e34 100644 --- a/src/main/java/io/takari/maven/builder/smart/SmartBuilder.java +++ b/src/main/java/io/takari/maven/builder/smart/SmartBuilder.java @@ -24,8 +24,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} . @@ -33,14 +31,14 @@ @Singleton @Named("smart") public class SmartBuilder implements Builder { - + public static final String PROP_PROFILING = "smartbuilder.profiling"; - + private final Logger logger = LoggerFactory.getLogger(getClass()); private final LifecycleModuleBuilder moduleBuilder; - + @Inject public SmartBuilder(LifecycleModuleBuilder moduleBuilder) { this.moduleBuilder = moduleBuilder; @@ -55,7 +53,7 @@ public void build(final MavenSession session, final ReactorContext reactorContex // log overall build info final int degreeOfConcurrency = session.getRequest().getDegreeOfConcurrency(); - logger.info("Task segments : " + Joiner.on(" ").join(taskSegments)); + logger.info("Task segments : " + taskSegments); logger.info("Build maximum degree of concurrency is " + degreeOfConcurrency); logger.info("Total number of projects is " + graph.getSortedProjects().size()); diff --git a/src/test/java/io/takari/maven/builder/smart/ProjectComparatorTest.java b/src/test/java/io/takari/maven/builder/smart/ProjectComparatorTest.java index 156a96e..804b680 100644 --- a/src/test/java/io/takari/maven/builder/smart/ProjectComparatorTest.java +++ b/src/test/java/io/takari/maven/builder/smart/ProjectComparatorTest.java @@ -17,7 +17,7 @@ public void testPriorityQueueOrder() { TestProjectDependencyGraph graph = new TestProjectDependencyGraph(a, b, c); graph.addDependency(b, a); - Comparator cmp = ProjectComparator.create0(graph, new HashMap<>(), p -> id(p)); + Comparator cmp = ProjectComparator.create0(graph, new LinkedHashMap<>(), p -> id(p)); Queue queue = new PriorityQueue<>(3, cmp); queue.add(a); @@ -35,7 +35,7 @@ public void testPriorityQueueOrder_historicalServiceTimes() { TestProjectDependencyGraph graph = new TestProjectDependencyGraph(a, b, c); graph.addDependency(b, a); - HashMap serviceTimes = new HashMap<>(); + HashMap serviceTimes = new LinkedHashMap<>(); serviceTimes.put(id(a), new AtomicLong(1L)); serviceTimes.put(id(b), new AtomicLong(1L)); serviceTimes.put(id(c), new AtomicLong(3L)); diff --git a/src/test/java/io/takari/maven/builder/smart/ProjectExecutorServiceTest.java b/src/test/java/io/takari/maven/builder/smart/ProjectExecutorServiceTest.java index c4fa705..b30cd36 100644 --- a/src/test/java/io/takari/maven/builder/smart/ProjectExecutorServiceTest.java +++ b/src/test/java/io/takari/maven/builder/smart/ProjectExecutorServiceTest.java @@ -68,7 +68,7 @@ public void testBuildOrder() throws Exception { TestProjectDependencyGraph graph = new TestProjectDependencyGraph(a, b, c); graph.addDependency(b, a); - HashMap serviceTimes = new HashMap<>(); + HashMap serviceTimes = new LinkedHashMap<>(); serviceTimes.put(id(a), new AtomicLong(1L)); serviceTimes.put(id(b), new AtomicLong(1L)); serviceTimes.put(id(c), new AtomicLong(3L));