Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,11 @@ public MavenBuilderException(String message, ProblemCollector<BuilderProblem> pr
*/
protected static String buildMessage(String message, ProblemCollector<BuilderProblem> problems) {
StringBuilder msg = new StringBuilder(message);
problems.problems().forEach(problem -> msg.append("\n * ")
.append(problem.getSeverity().name())
.append(": ")
.append(problem.getMessage()));
problems.problems()
.forEach(problem -> msg.append("\n * ")
.append(problem.getSeverity().name())
.append(": ")
.append(problem.getMessage()));
return msg.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,8 +421,9 @@ protected void customizeContainer(PlexusContainer container) {
container.addComponent(mock(Maven.class), "org.apache.maven.Maven");

((DefaultPlexusContainer) container)
.addPlexusInjector(Collections.emptyList(), binder -> binder.bind(EventSpyDispatcher.class)
.toInstance(eventSpyDispatcherMock));
.addPlexusInjector(
Collections.emptyList(),
binder -> binder.bind(EventSpyDispatcher.class).toInstance(eventSpyDispatcherMock));
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -488,8 +488,9 @@ void performFor(String value, String locationKey, Consumer<String> mutator) {
nt.performFor(pa.getName(), "name", pa::setName);
nt.performFor(pa.getValue(), "value", pa::setValue);
});
a.map(Activation::getJdk).ifPresent(ja -> new Interpolation(activation, interpolator::interpolate)
.performFor(ja, "jdk", activation::setJdk));
a.map(Activation::getJdk)
.ifPresent(ja -> new Interpolation(activation, interpolator::interpolate)
.performFor(ja, "jdk", activation::setJdk));
}
return interpolatedActivations;
}
Expand Down Expand Up @@ -795,9 +796,10 @@ private Model interpolateModel(Model model, ModelBuildingRequest request, ModelP

// restore profiles with any activation to their value before full interpolation
List<Profile> interpolatedProfiles = model.getProfiles();
IntStream.range(0, interpolatedProfiles.size()).forEach(i -> interpolatedProfiles
.get(i)
.setActivation(originalProfiles.get(i).getActivation()));
IntStream.range(0, interpolatedProfiles.size())
.forEach(i -> interpolatedProfiles
.get(i)
.setActivation(originalProfiles.get(i).getActivation()));

return interpolatedModel;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,9 @@ public org.apache.maven.api.model.InputLocation toApiLocation() {
columnNumber,
source != null ? source.toApiSource() : null,
locations != null
? locations.entrySet().stream().collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()
.toApiLocation()))
? locations.entrySet().stream()
.collect(Collectors.toMap(
e -> e.getKey(), e -> e.getValue().toApiLocation()))
: null);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ public Optional<Path> getPath(@Nonnull Project project) {
@Override
public Collection<ProducedArtifact> getAttachedArtifacts(@Nonnull Project project) {
requireNonNull(project, "project" + " cannot be null");
Collection<ProducedArtifact> attached =
map(getMavenProject(project).getAttachedArtifacts(), a -> getSession(project)
.getArtifact(ProducedArtifact.class, RepositoryUtils.toArtifact(a)));
Collection<ProducedArtifact> attached = map(
getMavenProject(project).getAttachedArtifacts(),
a -> getSession(project).getArtifact(ProducedArtifact.class, RepositoryUtils.toArtifact(a)));
return Collections.unmodifiableCollection(attached);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,14 @@ public List<String> getPhases() {

static Map<String, LifecyclePhase> getDefaultPhases(org.apache.maven.api.Lifecycle lifecycle) {
Map<String, List<String>> goals = new HashMap<>();
lifecycle.allPhases().forEach(phase -> phase.plugins()
.forEach(plugin -> plugin.getExecutions().forEach(exec -> exec.getGoals()
.forEach(goal -> goals.computeIfAbsent(phase.name(), n -> new ArrayList<>())
.add(plugin.getGroupId() + ":" + plugin.getArtifactId() + ":" + plugin.getVersion()
+ ":" + goal)))));
lifecycle
.allPhases()
.forEach(phase -> phase.plugins()
.forEach(plugin -> plugin.getExecutions()
.forEach(exec -> exec.getGoals()
.forEach(goal -> goals.computeIfAbsent(phase.name(), n -> new ArrayList<>())
.add(plugin.getGroupId() + ":" + plugin.getArtifactId() + ":"
+ plugin.getVersion() + ":" + goal)))));
return goals.entrySet().stream()
.collect(Collectors.toMap(Map.Entry::getKey, e -> new LifecyclePhase(String.join(",", e.getValue()))));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -904,10 +904,12 @@ public BuildPlan calculateLifecycleMappings(
})
.collect(Collectors.toMap(n -> n.name, n -> n));
// for each phase, make sure children phases are executed between before and after steps
lifecycle.allPhases().forEach(phase -> phase.phases().forEach(child -> {
steps.get(BEFORE + child.name()).executeAfter(steps.get(BEFORE + phase.name()));
steps.get(AFTER + phase.name()).executeAfter(steps.get(AFTER + child.name()));
}));
lifecycle
.allPhases()
.forEach(phase -> phase.phases().forEach(child -> {
steps.get(BEFORE + child.name()).executeAfter(steps.get(BEFORE + phase.name()));
steps.get(AFTER + phase.name()).executeAfter(steps.get(AFTER + child.name()));
}));
// for each phase, create links between this project phases
lifecycle.allPhases().forEach(phase -> {
phase.links().stream()
Expand Down Expand Up @@ -972,15 +974,16 @@ public BuildPlan calculateLifecycleMappings(

// Go through all plugins
List<Runnable> toResolve = new ArrayList<>();
projects.keySet().forEach(project -> project.getBuild().getPlugins().forEach(plugin -> {
MavenProject pluginProject = reactorGavs.get(gav(plugin));
if (pluginProject != null) {
// In order to plan the project, we need all its plugins...
plan.requiredStep(project, PLAN).executeAfter(plan.requiredStep(pluginProject, READY));
} else {
toResolve.add(() -> resolvePlugin(session, project.getRemotePluginRepositories(), plugin));
}
}));
projects.keySet()
.forEach(project -> project.getBuild().getPlugins().forEach(plugin -> {
MavenProject pluginProject = reactorGavs.get(gav(plugin));
if (pluginProject != null) {
// In order to plan the project, we need all its plugins...
plan.requiredStep(project, PLAN).executeAfter(plan.requiredStep(pluginProject, READY));
} else {
toResolve.add(() -> resolvePlugin(session, project.getRemotePluginRepositories(), plugin));
}
}));

// Eagerly resolve all plugins in parallel
toResolve.parallelStream().forEach(Runnable::run);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ void testVersionlessManagedDependency() throws Exception {
ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
configuration.setRepositorySession(mavenSession.getRepositorySession());

ProjectBuildingException e = assertThrows(ProjectBuildingException.class, () -> getContainer()
.lookup(org.apache.maven.project.ProjectBuilder.class)
.build(pomFile, configuration));
ProjectBuildingException e = assertThrows(
ProjectBuildingException.class,
() -> getContainer()
.lookup(org.apache.maven.project.ProjectBuilder.class)
.build(pomFile, configuration));
assertEquals(1, e.getResults().size());
ProjectBuildingResultWithProblemMessageAssert.assertThat(e.getResults().get(0))
.hasProblemMessage(
Expand Down Expand Up @@ -643,10 +645,11 @@ void testNonModularResourcesOnlyWithImplicitJavaFallback() throws Exception {
List<SourceRoot> mainResources = project.getEnabledSourceRoots(ProjectScope.MAIN, Language.RESOURCES)
.toList();
assertTrue(
mainResources.stream().anyMatch(sr -> sr.directory()
.toString()
.replace(File.separatorChar, '/')
.contains("src/main/custom-resources")),
mainResources.stream()
.anyMatch(sr -> sr.directory()
.toString()
.replace(File.separatorChar, '/')
.contains("src/main/custom-resources")),
"Should have custom main resources from <sources>");

// Verify legacy Java directories are used as fallback
Expand Down Expand Up @@ -716,10 +719,11 @@ void testNonModularResourcesOnlyWithExplicitLegacyDirectoriesRejected() throws E
List<SourceRoot> mainResources = project.getEnabledSourceRoots(ProjectScope.MAIN, Language.RESOURCES)
.toList();
assertTrue(
mainResources.stream().anyMatch(sr -> sr.directory()
.toString()
.replace(File.separatorChar, '/')
.contains("src/main/custom-resources")),
mainResources.stream()
.anyMatch(sr -> sr.directory()
.toString()
.replace(File.separatorChar, '/')
.contains("src/main/custom-resources")),
"Should have custom main resources from <sources>");

// Verify NO Java source roots (legacy was rejected, none in <sources>)
Expand Down Expand Up @@ -890,14 +894,16 @@ void testMultipleDirectoriesSameModule() throws Exception {
assertEquals(2, moduleCount, "Both main sources should be for com.example.app module");

// One should be implicit directory, one should be generated-sources
boolean hasImplicitDir = mainJavaRoots.stream().anyMatch(sr -> sr.directory()
.toString()
.replace(File.separatorChar, '/')
.contains("src/com.example.app/main/java"));
boolean hasGeneratedDir = mainJavaRoots.stream().anyMatch(sr -> sr.directory()
.toString()
.replace(File.separatorChar, '/')
.contains("target/generated-sources/com.example.app/java"));
boolean hasImplicitDir = mainJavaRoots.stream()
.anyMatch(sr -> sr.directory()
.toString()
.replace(File.separatorChar, '/')
.contains("src/com.example.app/main/java"));
boolean hasGeneratedDir = mainJavaRoots.stream()
.anyMatch(sr -> sr.directory()
.toString()
.replace(File.separatorChar, '/')
.contains("target/generated-sources/com.example.app/java"));

assertTrue(hasImplicitDir, "Should have implicit source directory for module");
assertTrue(hasGeneratedDir, "Should have generated-sources directory for module");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,8 @@ private static class SingletonScope implements Scope {
@Override
public <T> java.util.function.Supplier<T> scope(
@Nonnull Key<T> key, @Nonnull java.util.function.Supplier<T> unscoped) {
return (java.util.function.Supplier<T>)
cache.computeIfAbsent(key, k -> new java.util.function.Supplier<T>() {
return (java.util.function.Supplier<T>) cache.computeIfAbsent(
key, k -> new java.util.function.Supplier<T>() {
volatile T instance;

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,9 +709,10 @@ public static XmlNode extractPluginConfiguration(String artifactId, Xpp3Dom pomD
* TODO find out where this is probably done elsewhere
*/
private static String resolveFromRootThenParent(Xpp3Dom pluginPomDom, String element) throws Exception {
return Optional.ofNullable(child(pluginPomDom, element).orElseGet(() -> child(pluginPomDom, "parent")
.flatMap(e -> child(e, element))
.orElse(null)))
return Optional.ofNullable(child(pluginPomDom, element)
.orElseGet(() -> child(pluginPomDom, "parent")
.flatMap(e -> child(e, element))
.orElse(null)))
.map(Xpp3Dom::getValue)
.orElseThrow(() -> new Exception("unable to determine " + element));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,9 @@ public XmlNode doMerge(XmlNode dominant, XmlNode recessive, Boolean childMergeOv

if (mergeChildren && childDom != null) {
String name = recessiveChild.name();
Iterator<XmlNode> it =
commonChildren.computeIfAbsent(name, n1 -> Stream.of(dominant.children().stream()
Iterator<XmlNode> it = commonChildren.computeIfAbsent(
name,
n1 -> Stream.of(dominant.children().stream()
.filter(n2 -> n2.name().equals(n1))
.collect(Collectors.toList()))
.filter(l -> !l.isEmpty())
Expand Down
5 changes: 1 addition & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven-parent</artifactId>
<version>47</version>
<version>48</version>
<relativePath />
</parent>

Expand Down Expand Up @@ -173,9 +173,6 @@ under the License.
<xmlunitVersion>2.11.0</xmlunitVersion>
<jacocoArgLine />

<version.spotless-maven-plugin>3.0.0</version.spotless-maven-plugin>
<version.palantirJavaFormat>2.80.0</version.palantirJavaFormat>

<!-- Set as system property in surefire/failsafe to propagate to tests and IT Verifier -->
<toolboxVersion>0.14.1</toolboxVersion>
</properties>
Expand Down
6 changes: 0 additions & 6 deletions src/site/site.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ under the License.
xsi:schemaLocation="http://maven.apache.org/SITE/2.0.0 https://maven.apache.org/xsd/site-2.0.0.xsd"
name="Apache Maven">

<bannerLeft href="https://maven.apache.org/">
<image src="https://maven.apache.org/images/apache-maven-project.png" alt="Apache Maven" />
</bannerLeft>

<edit>${project.scm.url}</edit>

<body>
<breadcrumbs>
<item name="Ref" href="../" />
Expand Down
Loading