Maven flatten plugin in incrementals profile

29 views
Skip to first unread message

Ullrich Hafner

unread,
May 18, 2024, 2:43:55 PMMay 18
to Jenkins Developers
It seems that the Maven SpotBugs and the Maven Flatten plugin are not compatible when used together. I am using a SpotBugs exclusion filter from another jar file and SpotBugs seems to create a zero length copy of that file when the flatten plugin is active.

So before digging deeper into the sources or reporting a bug I wanted to ask why we need the maven flatten plugin for the incremental builds? Is this plugin optional? Or what happens if I set the property -Dflatten.flatten.skip in my Jenkinsfile? Are then incremental builds still created? Or is this relevant for CD only?

Jesse Glick

unread,
May 20, 2024, 4:24:03 PMMay 20
to jenkin...@googlegroups.com
On Sat, May 18, 2024 at 2:43 PM Ullrich Hafner <ullrich...@gmail.com> wrote:
It seems that the Maven SpotBugs and the Maven Flatten plugin are not compatible when used together.

They are in general.

I am using a SpotBugs exclusion filter from another jar file and SpotBugs seems to create a zero length copy of that file when the flatten plugin is active.

Not sure offhand why a zero-length file, but how specifically do you use a filter from another JAR file? SpotBugs filters should not be packed into production JAR files to begin with. I think you are better off simply copying the filter into a new destination in `src/spotbugs/excludesFilter.xml` (and then removing entries as the corresponding bug types are either fixed, or suppressed via annotation).

I wanted to ask why we need the maven flatten plugin for the incremental builds?

The answer is complicated but you can read JEP-305 if you really want to know.
 
Is this plugin optional?

No.
 
what happens if I set the property -Dflatten.flatten.skip in my Jenkinsfile? Are then incremental builds still created?

No, things will be broken.

Ullrich Hafner

unread,
May 21, 2024, 2:04:12 PMMay 21
to Jenkins Developers
Am 20.05.2024 um 22:23 schrieb 'Jesse Glick' via Jenkins Developers <jenkin...@googlegroups.com>:

On Sat, May 18, 2024 at 2:43 PM Ullrich Hafner <ullrich...@gmail.com> wrote:
It seems that the Maven SpotBugs and the Maven Flatten plugin are not compatible when used together.

They are in general.

I am using a SpotBugs exclusion filter from another jar file and SpotBugs seems to create a zero length copy of that file when the flatten plugin is active.

Not sure offhand why a zero-length file, but how specifically do you use a filter from another JAR file? SpotBugs filters should not be packed into production JAR files to begin with. I think you are better off simply copying the filter into a new destination in `src/spotbugs/excludesFilter.xml` (and then removing entries as the corresponding bug types are either fixed, or suppressed via annotation).


The filter and my CheckStyle and PMD configuration files are in an external artifact so I do not need to copy the file into all my projects (no duplication). So I can make changes to the coding style in one central project. Like a parent POM just for the coding style settings. Somehow CheckStyle and PMD do not care about the flattening but SpotBugs extracts the filter XML into an empty file. (Not every time but sometimes, so this might be a race condition somewhere).

I wanted to ask why we need the maven flatten plugin for the incremental builds?

The answer is complicated but you can read JEP-305 if you really want to know.
 
Is this plugin optional?

No.
 
what happens if I set the property -Dflatten.flatten.skip in my Jenkinsfile? Are then incremental builds still created?

No, things will be broken.

Ok, thanks. 

Jesse Glick

unread,
May 22, 2024, 10:22:23 PMMay 22
to jenkin...@googlegroups.com
On Tue, May 21, 2024 at 2:04 PM Ullrich Hafner <ullrich...@gmail.com> wrote:
SpotBugs extracts the filter XML into an empty file. (Not every time but sometimes, so this might be a race condition somewhere).

Weird. Running, say, `mvn clean verify` from a shell? No IDE, mvnd involved?
Reply all
Reply to author
Forward
0 new messages