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

Getting ride of guava #12

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,18 @@
<artifactId>maven-core</artifactId>
<version>${mavenVersion}</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
<scope>provided</scope>
<scope>test</scope>
</dependency>

<!-- test dependencies -->
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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.
* <p>
Expand All @@ -38,7 +38,7 @@ class ProjectComparator {

public static Comparator<MavenProject> 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 <K> Comparator<K> create0(final DependencyGraph<K> dependencyGraph,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

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.
Expand Down Expand Up @@ -43,8 +42,8 @@ public ReactorBuildQueue(Collection<MavenProject> projects,
}
}

this.rootProjects = ImmutableSet.copyOf(rootProjects);
this.projects = ImmutableSet.copyOf(projects);
this.rootProjects = new LinkedHashSet<>(rootProjects);
this.projects = new LinkedHashSet<>(projects);
}

/**
Expand Down Expand Up @@ -103,7 +102,7 @@ public int getReadyCount() {
}

public Set<MavenProject> getReadyProjects() {
Set<MavenProject> projects = new HashSet<>(this.projects);
Set<MavenProject> projects = new LinkedHashSet<>(this.projects);
projects.removeAll(blockedProjects);
projects.removeAll(finishedProjects);
return projects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -39,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 = new LinkedHashMap<>(serviceTimes);
this.bottleneckTimes = new LinkedHashMap<>(bottleneckTimes);
}

private static String projectGA(MavenProject project) {
return project.getGroupId() + ":" + project.getArtifactId();
}

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 LinkedHashMap<>();
Map<String, AtomicLong> 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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} .
Expand Down Expand Up @@ -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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void testPriorityQueueOrder() {
TestProjectDependencyGraph graph = new TestProjectDependencyGraph(a, b, c);
graph.addDependency(b, a);

Comparator<MavenProject> cmp = ProjectComparator.create0(graph, new HashMap<>(), p -> id(p));
Comparator<MavenProject> cmp = ProjectComparator.create0(graph, new LinkedHashMap<>(), p -> id(p));

Queue<MavenProject> queue = new PriorityQueue<>(3, cmp);
queue.add(a);
Expand All @@ -35,7 +35,7 @@ public void testPriorityQueueOrder_historicalServiceTimes() {
TestProjectDependencyGraph graph = new TestProjectDependencyGraph(a, b, c);
graph.addDependency(b, a);

HashMap<String, AtomicLong> serviceTimes = new HashMap<>();
HashMap<String, AtomicLong> serviceTimes = new LinkedHashMap<>();
serviceTimes.put(id(a), new AtomicLong(1L));
serviceTimes.put(id(b), new AtomicLong(1L));
serviceTimes.put(id(c), new AtomicLong(3L));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void testBuildOrder() throws Exception {
TestProjectDependencyGraph graph = new TestProjectDependencyGraph(a, b, c);
graph.addDependency(b, a);

HashMap<String, AtomicLong> serviceTimes = new HashMap<>();
HashMap<String, AtomicLong> serviceTimes = new LinkedHashMap<>();
serviceTimes.put(id(a), new AtomicLong(1L));
serviceTimes.put(id(b), new AtomicLong(1L));
serviceTimes.put(id(c), new AtomicLong(3L));
Expand Down