Skip to content

Commit d6e15e2

Browse files
committed
[MARTIFACT-80] Use per-module ignore configuration when generating aggregated buildinfo in compare
Use the per-module ignore configuration when generating buildinfo for comparison in the aggregator (usually the 'last' module). It's a bit of a bodge because it relies on the ignore config being stored when the `compare` goal runs in each module. If for some reason a module doesn't run the `compare` goal then it falls back to whatever config exists in the aggregator. There's probably a much more complex solution that involves parsing the config out of the project model that would be more consistent.
1 parent 7a82814 commit d6e15e2

10 files changed

Lines changed: 320 additions & 35 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
# initial reference build: install
19+
invoker.goals.1=clean install
20+
# second build: verify (could be package, but not install to avoid overriding reference)
21+
invoker.goals.2=clean verify artifact:compare

src/it/compare-ignore/modA/pom.xml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
26+
<parent>
27+
<groupId>org.apache.maven.plugins.it</groupId>
28+
<artifactId>ignore</artifactId>
29+
<version>1.0-SNAPSHOT</version>
30+
</parent>
31+
<artifactId>ignore-modA</artifactId>
32+
<packaging>jar</packaging>
33+
<name>ignore module A</name>
34+
35+
<build>
36+
<resources>
37+
<resource>
38+
<directory>src/main/resources</directory>
39+
<filtering>true</filtering>
40+
</resource>
41+
</resources>
42+
43+
<plugins>
44+
<plugin>
45+
<groupId>@project.groupId@</groupId>
46+
<artifactId>@project.artifactId@</artifactId>
47+
<version>@project.version@</version>
48+
<configuration>
49+
<ignore>*/ignore-modA-*.jar</ignore>
50+
</configuration>
51+
<executions>
52+
<execution>
53+
<goals>
54+
<goal>compare</goal>
55+
</goals>
56+
</execution>
57+
</executions>
58+
</plugin>
59+
</plugins>
60+
</build>
61+
</project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
project.build.outputTimestamp=${project.build.outputTimestamp}

src/it/compare-ignore/modB/pom.xml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
26+
<parent>
27+
<groupId>org.apache.maven.plugins.it</groupId>
28+
<artifactId>ignore</artifactId>
29+
<version>1.0-SNAPSHOT</version>
30+
</parent>
31+
<artifactId>ignore-modB</artifactId>
32+
<packaging>pom</packaging>
33+
<name>ignore module B</name>
34+
35+
<dependencies>
36+
<dependency>
37+
<groupId>org.apache.maven.plugins.it</groupId>
38+
<artifactId>ignore-modA</artifactId>
39+
<version>1.0-SNAPSHOT</version>
40+
</dependency>
41+
</dependencies>
42+
</project>

src/it/compare-ignore/pom.xml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?xml version='1.0' encoding='UTF-8'?>
2+
3+
<!--
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
-->
21+
22+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
23+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
24+
<modelVersion>4.0.0</modelVersion>
25+
26+
<groupId>org.apache.maven.plugins.it</groupId>
27+
<artifactId>ignore</artifactId>
28+
<version>1.0-SNAPSHOT</version>
29+
<packaging>pom</packaging>
30+
31+
<description>An IT verifying compare works when resuming a multi-module build.</description>
32+
33+
<properties>
34+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
35+
</properties>
36+
37+
<prerequisites>
38+
<maven>3.0.5</maven>
39+
</prerequisites>
40+
41+
<distributionManagement>
42+
<snapshotRepository>
43+
<id>local-snapshots</id>
44+
<url>file://${basedir}/target/remote-repo</url>
45+
<uniqueVersion>false</uniqueVersion>
46+
</snapshotRepository>
47+
</distributionManagement>
48+
49+
<modules>
50+
<module>modB</module>
51+
<module>modA</module>
52+
</modules>
53+
54+
<build>
55+
<plugins>
56+
<plugin>
57+
<groupId>@project.groupId@</groupId>
58+
<artifactId>@project.artifactId@</artifactId>
59+
<version>@project.version@</version>
60+
<executions>
61+
<execution>
62+
<goals>
63+
<goal>compare</goal>
64+
</goals>
65+
</execution>
66+
</executions>
67+
</plugin>
68+
</plugins>
69+
</build>
70+
</project>

src/it/settings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
<activation>
2727
<activeByDefault>true</activeByDefault>
2828
</activation>
29+
<properties>
30+
<reference.repo>nexus</reference.repo>
31+
</properties>
2932
<repositories>
3033
<repository>
3134
<id>local.central</id>

src/main/java/org/apache/maven/plugins/artifact/buildinfo/AbstractBuildinfoMojo.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import java.util.List;
3838
import java.util.Map;
3939
import java.util.stream.Collectors;
40-
4140
import org.apache.maven.archiver.MavenArchiver;
4241
import org.apache.maven.execution.MavenSession;
4342
import org.apache.maven.plugin.AbstractMojo;
@@ -76,14 +75,14 @@ public abstract class AbstractBuildinfoMojo extends AbstractMojo {
7675
* Ignore javadoc attached artifacts from buildinfo generation.
7776
*/
7877
@Parameter(property = "buildinfo.ignoreJavadoc", defaultValue = "true")
79-
private boolean ignoreJavadoc;
78+
boolean ignoreJavadoc;
8079

8180
/**
8281
* Artifacts to ignore, specified as a glob matching against <code>${groupId}/${filename}</code>, for example
8382
* <code>*</>/*.xml</code>.
8483
*/
8584
@Parameter(property = "buildinfo.ignore", defaultValue = "")
86-
private List<String> ignore;
85+
List<String> ignore;
8786

8887
/**
8988
* Detect projects/modules with install or deploy skipped: avoid taking fingerprints.
@@ -148,6 +147,8 @@ public void execute() throws MojoExecutionException {
148147

149148
hasBadOutputTimestamp(outputTimestamp, getLog(), project, session.getProjects(), diagnose);
150149

150+
initModuleBuildInfo();
151+
151152
if (!mono) {
152153
// if module skips install and/or deploy
153154
if (isSkip(project)) {
@@ -171,6 +172,10 @@ public void execute() throws MojoExecutionException {
171172
execute(artifacts);
172173
}
173174

175+
protected void initModuleBuildInfo() {
176+
BuildInfoWriter.addModuleBuildInfo(getPluginContext(), ignore, ignoreJavadoc);
177+
}
178+
174179
static boolean hasBadOutputTimestamp(
175180
String outputTimestamp,
176181
Log log,
@@ -303,9 +308,9 @@ protected void copyAggregateToRoot(File aggregate) throws MojoExecutionException
303308

304309
protected BuildInfoWriter newBuildInfoWriter(PrintWriter p, boolean mono) {
305310
BuildInfoWriter bi = new BuildInfoWriter(getLog(), p, mono, rtInformation);
306-
bi.setIgnoreJavadoc(ignoreJavadoc);
307-
bi.setIgnore(ignore);
308311
bi.setToolchain(getToolchain());
312+
bi.setSession(session);
313+
bi.setPluginContext(getPluginContext());
309314

310315
return bi;
311316
}
@@ -329,11 +334,11 @@ protected Map<Artifact, String> generateBuildinfo(boolean mono) throws MojoExecu
329334

330335
// artifact(s) fingerprints
331336
if (mono) {
332-
bi.printArtifacts(project);
337+
bi.printArtifacts(project, project);
333338
} else {
334-
for (MavenProject project : session.getProjects()) {
335-
if (!isSkip(project)) {
336-
bi.printArtifacts(project);
339+
for (MavenProject moduleProject : session.getProjects()) {
340+
if (!isSkip(moduleProject)) {
341+
bi.printArtifacts(moduleProject, project);
337342
}
338343
}
339344
}

0 commit comments

Comments
 (0)