Add attachClasses to the maven-war-plugin in idp-parent

Description

Would you please consider this patch for the 4.2.2 release? Adding
attachClasses to the maven-war-plugin will attach a jar to the build
artifacts for all war modules. This will provide an easy mechanism for
downstream projects to use the <type>jar</type> or
<classifier>classes</classifier> so Maven dependencyManagement can be
used to override war dependencies if necessary. For example, if a
critical bug is found in a third-party dependency embedded in the IdP
war, and waiting for the next release is not feasible. Without this
option, downstream projects must use overlay excludes and manually add
dependencies to their projects, which can become cumbersome to manage.
Thanks for your consideration!

Environment

Maven

Attachments

2

Activity

Show:

Scott CantorAugust 19, 2022 at 4:01 PM

Applied to both branches.

Dan McLaughlinAugust 12, 2022 at 8:44 PM

The only problem with the pom approach is that Maven throws the following warning…

”'dependencies.dependency.scope' for net.shibboleth.idp:idp-war:pom must be one of [provided, compile, runtime, test, system] but is ‘import'. @ line 69, column 14
'dependencies.dependency.scope' for net.shibboleth.idp:idp-war-distribution:pom must be one of [provided, compile, runtime, test, system] but is ‘import'. @ line 82, column 14
It is highly recommended to fix these problems because they threaten the stability of your build.
For this reason, future Maven versions might no longer support building such malformed projects.”

But using a classified artifact just works. I’d still like to have a classified artifact just so I can let Maven handle the dependencies and avoid the Maven warning because I’m try to import a pom that states it’s a war.

Here is another link where someone explains the solution, possibly better than I am.

Scott CantorAugust 10, 2022 at 1:05 PM

I do think using the POM directly as a dependency makes more sense than creating a classified artifact.

I would definitely stick to the maint-4 branch or a release right now.

I don’t think we need to provide a Jakarta workaround at this point but thanks for highlighting it, we probably didn’t really consider conversion. It may actually be more likely we’d need it in reverse due to dependencies not updating in time.

Dan McLaughlinAugust 10, 2022 at 4:17 AM

We will use 4.2.1 for now if you think 5.0 will be too unstable. BTW, if you wanted to release a JakartaEE version of the idp-war in 4.x, all you need to do is add the following to your idp-war and idp-war-distribution modules. It will create a idp-war-jakarta.war that can run on Tomcat 10.x

<plugin> <groupId>org.eclipse.transformer</groupId> <artifactId>transformer-maven-plugin</artifactId> <version>0.5.0</version> <extensions>true</extensions> <configuration> <attach>true</attach> <classifier>jakarta</classifier> <transformDirectory>${project.build.directory}</transformDirectory> <outputDirectory>${project.build.directory}</outputDirectory> <baseName>${project.build.finalName}</baseName> <overwrite>true</overwrite> </configuration> <executions> <execution> <id>${project.artifactId}-transform</id> <goals> <goal>jar</goal> </goals> <configuration> <rules> <jakartaDefaults>true</jakartaDefaults> </rules> <artifact> <groupId>${project.groupId}</groupId> <artifactId>${project.artifactId}</artifactId> <version>${project.version}</version> </artifact> <buildDirectory>${project.build.directory}</buildDirectory> <packagingTypes>war</packagingTypes> <type>war</type> </configuration> </execution> </executions> </plugin>



Dan McLaughlinAugust 10, 2022 at 3:28 AM
Edited

I just figured out another way to get things working. By adding both the war and pom I was then able to get Maven dependency management to allow me to override dependencies in the war overlay. I do get a Maven warning about using the scope of import, but it seems to be working. Although this seems to work, I probably can’t depend on it since Maven is warning me that it could cause issues. So using attachClasses would still probably be the preferred approach.

Here is an example…

<dependency>
<groupId>net.shibboleth.idp</groupId>
<artifactId>idp-war</artifactId>
<version>4.2.1</version>
<type>war</type>
</dependency>

<dependency>
<groupId>net.shibboleth.idp</groupId>
<artifactId>idp-war</artifactId>
<version>4.2.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>

Then I was able to use the maven-war-plugin to create the idp war with our customizations, and use the dependency versions from our dependencyMangement.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <executions> <execution> <id>default-war</id> <goals> <goal>war</goal> </goals> <phase>package</phase> <configuration> <skip>true</skip> </configuration> </execution> <execution> <id>exploded-war</id> <goals> <goal>exploded</goal> </goals> <phase>prepare-package</phase> <configuration> <webappDirectory>${project.build.directory}/exploded-war</webappDirectory> <webResources> <resource> <directory>${project.build.directory}/common-webresources</directory> <exclude>**/log4j2.xml</exclude> </resource> <resource> <directory> ${project.basedir}/node_modules/@com.foo.bar/ui/dist/common-resources </directory> </resource> </webResources> <overlays> <overlay> <groupId>net.shibboleth.idp</groupId> <artifactId>idp-war</artifactId> <excludes> <exclude>WEB-INF/lib/*</exclude> </excludes> </overlay> </overlays> </configuration> </execution> <execution> <id>package-war</id> <goals> <goal>war</goal> </goals> <phase>package</phase> <configuration> <warSourceDirectory>${project.build.directory}/exploded-war</warSourceDirectory> <webXml>${project.build.directory}/exploded-war/WEB-INF/web.xml</webXml> <containerConfigXML>${project.build.directory}/exploded-war/META-INF/context.xml </containerConfigXML> <overlays> <overlay> <groupId>net.shibboleth.idp</groupId> <artifactId>idp-war</artifactId> <skip>true</skip> </overlay> </overlays> </configuration> </execution> </executions> </plugin>

Done

Details

Assignee

Reporter

Components

Fix versions

Created May 28, 2022 at 3:39 PM
Updated January 18, 2023 at 1:29 PM
Resolved August 19, 2022 at 4:01 PM