Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSHADE-406] Support multi release jars #202

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/maven-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ jobs:
name: Verify
uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v3
with:
ff-jdk: "21"
ff-jdk: |
8
11
17
21
ff-jdk-distribution: "corretto"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
target/
**/target/
.project
.classpath
.settings/
Expand All @@ -7,6 +7,7 @@ bin/
# Intellij
*.ipr
*.iml
**/*.iml
.idea
out/
.DS_Store
Expand Down
13 changes: 11 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
<contributor>
<name>Torsten Curdt</name>
</contributor>
<contributor>
<name>Niels Basjes</name>
</contributor>
</contributors>

<prerequisites>
Expand Down Expand Up @@ -190,7 +193,7 @@
<dependency>
<groupId>org.vafer</groupId>
<artifactId>jdependency</artifactId>
<version>2.9.0</version>
<version>2.9.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
Expand Down Expand Up @@ -333,7 +336,13 @@
<goal>package</goal>
</goals>
<showErrors>true</showErrors>
<projectsDirectory>src/it/projects</projectsDirectory>
<setupIncludes>
<setupInclude>setup/*/pom.xml</setupInclude>
</setupIncludes>
<pomIncludes>
<pomInclude>projects/*/pom.xml</pomInclude>
</pomIncludes>
<projectsDirectory>src/it</projectsDirectory>
<settingsFile>src/it/mrm/settings.xml</settingsFile>
<extraArtifacts>
<extraArtifact>org.apache.maven.plugins:maven-shade-plugin:${project.version}:test-jar</extraArtifact>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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.

invoker.java.version = 17+
invoker.goals.1=clean package
invoker.goals.2=-PJava8Test validate
invoker.goals.3=-PJava11Test validate
invoker.goals.4=-PJava17Test validate
287 changes: 287 additions & 0 deletions src/it/projects/MultiReleaseJar-shade-minimize-relocate/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,287 @@
<?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>
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.its.shade.multirelease</groupId>
<artifactId>shade</artifactId>
<version>1.0</version>

<name>MSHADE-406 Shade</name>
<description>
Shading multi release jar
</description>

<dependencies>
<dependency>
<groupId>nl.basjes.maven</groupId>
<artifactId>multi-jdk</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>@project.version@</version>
<executions>
<execution>
<id>create-shaded-artifact</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>nl.example.Main</mainClass>
</transformer>
</transformers>
<minimizeJar>true</minimizeJar>
<relocations>
<relocation>
<pattern>nl.basjes.maven.multijdk</pattern>
<shadedPattern>nl.example.shaded.multijdk</shadedPattern>
</relocation>
</relocations>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>Java8Test</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>8</version>
</jdk>
</toolchains>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>

<executions>
<execution>
<id>run-unshaded</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-cp</argument>
<argument>target/original-shade-1.0.jar:../../setup/multiReleaseJar/target/multi-jdk-1.0.0.jar</argument>
<argument>nl.example.Main</argument>
</arguments>
<outputFile>Java8-unshaded.log</outputFile>
</configuration>
</execution>

<execution>
<id>run-shaded</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-jar</argument>
<argument>target/shade-1.0.jar</argument>
</arguments>
<outputFile>Java8-shaded.log</outputFile>
</configuration>
</execution>
</executions>

</plugin>
</plugins>
</build>
</profile>

<profile>
<id>Java11Test</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>11</version>
</jdk>
</toolchains>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>

<executions>
<execution>
<id>run-unshaded</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-cp</argument>
<argument>target/original-shade-1.0.jar:../../setup/multiReleaseJar/target/multi-jdk-1.0.0.jar</argument>
<argument>nl.example.Main</argument>
</arguments>
<outputFile>Java11-unshaded.log</outputFile>
</configuration>
</execution>

<execution>
<id>run-shaded</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-jar</argument>
<argument>target/shade-1.0.jar</argument>
</arguments>
<outputFile>Java11-shaded.log</outputFile>
</configuration>
</execution>
</executions>

</plugin>
</plugins>
</build>
</profile>

<profile>
<id>Java17Test</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>17</version>
</jdk>
</toolchains>
</configuration>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.1.1</version>

<executions>
<execution>
<id>run-unshaded</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-cp</argument>
<argument>target/original-shade-1.0.jar:../../setup/multiReleaseJar/target/multi-jdk-1.0.0.jar</argument>
<argument>nl.example.Main</argument>
</arguments>
<outputFile>Java17-unshaded.log</outputFile>
</configuration>
</execution>

<execution>
<id>run-shaded</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-jar</argument>
<argument>target/shade-1.0.jar</argument>
</arguments>
<outputFile>Java17-shaded.log</outputFile>
</configuration>
</execution>
</executions>

</plugin>
</plugins>
</build>
</profile>

</profiles>

</project>
Loading
Loading