Skip to content

Commit 2b71741

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 2b71741

File tree

10 files changed

+347
-29
lines changed

10 files changed

+347
-29
lines changed
+21
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

+61
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>
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

+42
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

+70
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

+3
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

+14-8
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ public abstract class AbstractBuildinfoMojo extends AbstractMojo {
7676
* Ignore javadoc attached artifacts from buildinfo generation.
7777
*/
7878
@Parameter(property = "buildinfo.ignoreJavadoc", defaultValue = "true")
79-
private boolean ignoreJavadoc;
79+
boolean ignoreJavadoc;
8080

8181
/**
8282
* Artifacts to ignore, specified as a glob matching against <code>${groupId}/${filename}</code>, for example
8383
* <code>*</>/*.xml</code>.
8484
*/
8585
@Parameter(property = "buildinfo.ignore", defaultValue = "")
86-
private List<String> ignore;
86+
List<String> ignore;
8787

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

149149
hasBadOutputTimestamp(outputTimestamp, getLog(), project, session.getProjects(), diagnose);
150150

151+
initModuleBuildInfo();
152+
151153
if (!mono) {
152154
// if module skips install and/or deploy
153155
if (isSkip(project)) {
@@ -171,6 +173,10 @@ public void execute() throws MojoExecutionException {
171173
execute(artifacts);
172174
}
173175

176+
protected void initModuleBuildInfo() {
177+
BuildInfoWriter.addModuleBuildInfo(getPluginContext(), ignore, ignoreJavadoc);
178+
}
179+
174180
static boolean hasBadOutputTimestamp(
175181
String outputTimestamp,
176182
Log log,
@@ -303,9 +309,9 @@ protected void copyAggregateToRoot(File aggregate) throws MojoExecutionException
303309

304310
protected BuildInfoWriter newBuildInfoWriter(PrintWriter p, boolean mono) {
305311
BuildInfoWriter bi = new BuildInfoWriter(getLog(), p, mono, rtInformation);
306-
bi.setIgnoreJavadoc(ignoreJavadoc);
307-
bi.setIgnore(ignore);
308312
bi.setToolchain(getToolchain());
313+
bi.setSession(session);
314+
bi.setPluginContext(getPluginContext());
309315

310316
return bi;
311317
}
@@ -329,11 +335,11 @@ protected Map<Artifact, String> generateBuildinfo(boolean mono) throws MojoExecu
329335

330336
// artifact(s) fingerprints
331337
if (mono) {
332-
bi.printArtifacts(project);
338+
bi.printArtifacts(project, project);
333339
} else {
334-
for (MavenProject project : session.getProjects()) {
335-
if (!isSkip(project)) {
336-
bi.printArtifacts(project);
340+
for (MavenProject moduleProject : session.getProjects()) {
341+
if (!isSkip(moduleProject)) {
342+
bi.printArtifacts(moduleProject, project);
337343
}
338344
}
339345
}

0 commit comments

Comments
 (0)