Skip to content

Commit

Permalink
[MARTIFACT-79] Check session.allProjects for executionRoot, not j…
Browse files Browse the repository at this point in the history
…ust `session.projects` (#70)

When resuming a multi-module build, the `executionRoot` may not be included in `session.projects`. `session.allProjects` contains all projects in the reactor build.
  • Loading branch information
facboy authored Dec 13, 2024
1 parent 09808ac commit ed91a5f
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/it/compare-resume/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# initial reference build: install
invoker.goals.1=clean install
# second build: verify (could be package, but not install to avoid overriding reference)
invoker.goals.2=clean verify artifact:compare
# third build: verify resuming from second module
invoker.goals.3=clean verify artifact:compare -rf :resume-modA
34 changes: 34 additions & 0 deletions src/it/compare-resume/modA/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version='1.0' encoding='UTF-8'?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.maven.plugins.it</groupId>
<artifactId>resume</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>resume-modA</artifactId>
<packaging>pom</packaging>
<name>resume module A</name>
</project>
42 changes: 42 additions & 0 deletions src/it/compare-resume/modB/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version='1.0' encoding='UTF-8'?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.maven.plugins.it</groupId>
<artifactId>resume</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>resume-modB</artifactId>
<packaging>pom</packaging>
<name>resume module B</name>

<dependencies>
<dependency>
<groupId>org.apache.maven.plugins.it</groupId>
<artifactId>resume-modA</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
70 changes: 70 additions & 0 deletions src/it/compare-resume/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version='1.0' encoding='UTF-8'?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.plugins.it</groupId>
<artifactId>resume</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<description>An IT verifying compare works when resuming a multi-module build.</description>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<prerequisites>
<maven>3.0.5</maven>
</prerequisites>

<distributionManagement>
<snapshotRepository>
<id>local-snapshots</id>
<url>file://${basedir}/target/remote-repo</url>
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
</distributionManagement>

<modules>
<module>modB</module>
<module>modA</module>
</modules>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<goals>
<goal>compare</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ protected Map<Artifact, String> generateBuildinfo(boolean mono) throws MojoExecu
}

protected MavenProject getExecutionRoot() {
for (MavenProject p : session.getProjects()) {
for (MavenProject p : session.getAllProjects()) {
if (p.isExecutionRoot()) {
return p;
}
Expand Down

0 comments on commit ed91a5f

Please # to comment.