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 runtime dependency on guava, fixes #19 #26

Merged
merged 1 commit into from
May 11, 2023
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
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