Skip to content

Commit

Permalink
Remove runtime dependency on guava (fixes #19, #26)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet authored May 11, 2023
1 parent fff66e2 commit 8e79b25
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 16 deletions.
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@
<version>${mavenResolverVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
<scope>provided</scope>
</dependency>

<!-- test dependencies -->
<dependency>
Expand All @@ -79,5 +73,11 @@
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>31.0.1-jre</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
20 changes: 13 additions & 7 deletions src/main/java/io/takari/maven/builder/smart/ReactorBuildStats.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -32,22 +38,22 @@ class ReactorBuildStats {

private ReactorBuildStats(Map<String, AtomicLong> serviceTimes,
Map<String, AtomicLong> 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) {
return project.getGroupId() + ":" + project.getArtifactId() + ":" + project.getVersion();
}

public static ReactorBuildStats create(Collection<MavenProject> projects) {
ImmutableMap.Builder<String, AtomicLong> serviceTimes = ImmutableMap.builder();
ImmutableMap.Builder<String, AtomicLong> bottleneckTimes = ImmutableMap.builder();
Map<String, AtomicLong> serviceTimes = new HashMap<>();
Map<String, AtomicLong> 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() {
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/io/takari/maven/builder/smart/SmartBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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} .
Expand Down Expand Up @@ -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());
}
Expand Down

0 comments on commit 8e79b25

Please sign in to comment.