Skip to content

Commit

Permalink
Declarative JPMS descriptors (#879)
Browse files Browse the repository at this point in the history
Motivation:
tcnative should provide declarative modules for the set of its
artifacts. This is a preliminary contribution that will enable the support of
declarative JPMS descriptors for Netty 4.2 branch.

Modifications:
Generated artifacts are multi release jar to remain compatible with Java
8.

Result:
This has been tested with `netty-tcnative-openssl-static` on my arm64
mac with a jlink generated image.
  • Loading branch information
vietj authored Aug 22, 2024
1 parent fcda2f7 commit 9256e3e
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 13 deletions.
12 changes: 6 additions & 6 deletions boringssl-static/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<ldflags>-L${boringsslHome}/ssl -L${boringsslHome}/crypto -lssl -lcrypto</ldflags>
<skipJapicmp>true</skipJapicmp>
<!-- We need to use the same module name for all our "native" impls as only one should be loaded -->
<javaModuleName>${javaModuleNameNative}</javaModuleName>
<javaModuleName>${javaDefaultModuleName}</javaModuleName>
</properties>

<dependencies>
Expand Down Expand Up @@ -277,7 +277,7 @@
</if>

<copy todir="${nativeJarWorkdir}">
<zipfileset src="${defaultJarFile}" />
<zipfileset src="${defaultJarFile}" excludes="META-INF/versions/**/module-info.class" />
</copy>
<copy todir="${nativeJarWorkdir}" includeEmptyDirs="false">
<zipfileset dir="${nativeLibOnlyDir}/META-INF/native" />
Expand Down Expand Up @@ -555,7 +555,7 @@
</if>

<copy todir="${nativeJarWorkdir}">
<zipfileset src="${defaultJarFile}" />
<zipfileset src="${defaultJarFile}" excludes="META-INF/versions/**/module-info.class" />
</copy>
<copy todir="${nativeJarWorkdir}" includeEmptyDirs="false">
<zipfileset dir="${nativeLibOnlyDir}/META-INF/native" />
Expand Down Expand Up @@ -890,7 +890,7 @@
</if>

<copy todir="${nativeJarWorkdir}">
<zipfileset src="${defaultJarFile}" />
<zipfileset src="${defaultJarFile}" excludes="META-INF/versions/**/module-info.class" />
</copy>
<copy todir="${nativeJarWorkdir}" includeEmptyDirs="false">
<zipfileset dir="${nativeLibOnlyDir}/META-INF/native" />
Expand Down Expand Up @@ -1309,7 +1309,7 @@
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />

<copy todir="${nativeJarWorkdir}">
<zipfileset src="${defaultJarFile}" />
<zipfileset src="${defaultJarFile}" excludes="META-INF/versions/**/module-info.class" />
</copy>
<copy todir="${nativeJarWorkdir}" includeEmptyDirs="false">
<zipfileset dir="${nativeLibOnlyDir}/META-INF/native" />
Expand Down Expand Up @@ -1556,7 +1556,7 @@
<taskdef resource="net/sf/antcontrib/antcontrib.properties" />

<copy todir="${nativeJarWorkdir}">
<zipfileset src="${defaultJarFile}" />
<zipfileset src="${defaultJarFile}" excludes="META-INF/versions/**/module-info.class" />
</copy>
<copy todir="${nativeJarWorkdir}" includeEmptyDirs="false">
<zipfileset dir="${nativeLibOnlyDir}/META-INF/native" />
Expand Down
4 changes: 2 additions & 2 deletions libressl-static/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<maven.deploy.skip>true</maven.deploy.skip>
<skipJapicmp>true</skipJapicmp>
<!-- We need to use the same module name for all our "native" impls as only one should be loaded -->
<javaModuleName>${javaModuleNameNative}</javaModuleName>
<javaModuleName>${javaDefaultModuleName}</javaModuleName>
</properties>

<build>
Expand Down Expand Up @@ -112,7 +112,7 @@
<configuration>
<target>
<copy todir="${nativeJarWorkdir}">
<zipfileset src="${defaultJarFile}" />
<zipfileset src="${defaultJarFile}" excludes="META-INF/versions/**/module-info.class" />
</copy>
<copy todir="${nativeJarWorkdir}" includeEmptyDirs="false">
<zipfileset dir="${nativeLibOnlyDir}/META-INF/native" />
Expand Down
2 changes: 2 additions & 0 deletions openssl-classes/src/main/java/module-info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
exports:
- package: io.netty.internal.tcnative
4 changes: 2 additions & 2 deletions openssl-dynamic/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<nativeSourceDirectory />
<skipJapicmp>true</skipJapicmp>
<!-- We need to use the same module name for all our "native" impls as only one should be loaded -->
<javaModuleName>${javaModuleNameNative}</javaModuleName>
<javaModuleName>${javaDefaultModuleName}</javaModuleName>
</properties>

<build>
Expand Down Expand Up @@ -77,7 +77,7 @@
<configuration>
<target>
<copy todir="${nativeJarWorkdir}">
<zipfileset src="${defaultJarFile}" />
<zipfileset src="${defaultJarFile}" excludes="META-INF/versions/**/module-info.class" />
</copy>
<copy todir="${nativeJarWorkdir}" includeEmptyDirs="false">
<zipfileset dir="${nativeLibOnlyDir}/META-INF/native" />
Expand Down
4 changes: 2 additions & 2 deletions openssl-static/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<maven.deploy.skip>true</maven.deploy.skip>
<skipJapicmp>true</skipJapicmp>
<!-- We need to use the same module name for all our "native" impls as only one should be loaded -->
<javaModuleName>${javaModuleNameNative}</javaModuleName>
<javaModuleName>${javaDefaultModuleName}</javaModuleName>
</properties>

<build>
Expand Down Expand Up @@ -109,7 +109,7 @@
<configuration>
<target>
<copy todir="${nativeJarWorkdir}">
<zipfileset src="${defaultJarFile}" />
<zipfileset src="${defaultJarFile}" excludes="META-INF/versions/**/module-info.class" />
</copy>
<copy todir="${nativeJarWorkdir}" includeEmptyDirs="false">
<zipfileset dir="${nativeLibOnlyDir}/META-INF/native" />
Expand Down
32 changes: 31 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,36 @@
</configuration>
</plugin>

<plugin>
<groupId>io.github.dmlloyd.module-info</groupId>
<artifactId>module-info</artifactId>
<version>2.1</version>
<executions>
<execution>
<id>default-jar-module-info</id>
<phase>process-classes</phase>
<configuration>
<moduleName>${javaModuleName}</moduleName>
<outputDirectory>${project.build.outputDirectory}/META-INF/versions/11/</outputDirectory>
</configuration>
<goals>
<goal>generate</goal>
</goals>
</execution>
<execution>
<id>native-jar-module-info</id>
<phase>process-classes</phase>
<configuration>
<moduleName>${javaModuleNameNative}</moduleName>
<outputDirectory>${nativeJarWorkdir}//META-INF/versions/11/</outputDirectory>
</configuration>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
Expand Down Expand Up @@ -439,7 +469,7 @@
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
<manifestEntries>
<Automatic-Module-Name>${javaModuleName}</Automatic-Module-Name>
<Multi-Release>true</Multi-Release>
</manifestEntries>
<index>true</index>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
Expand Down

0 comments on commit 9256e3e

Please sign in to comment.