Skip to content

Commit

Permalink
feat(java): Specify JPMS module names (#1343)
Browse files Browse the repository at this point in the history
This PR adds support for JPMS modules by adding the
`Automatic-Module-Name` entry to the `MANIFEST.MF` files of the
constructed `.jar` files.

Closes #1341.
  • Loading branch information
mtf90 authored Jan 14, 2024
1 parent caef577 commit 54faae1
Show file tree
Hide file tree
Showing 10 changed files with 211 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ci/run_ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ integration_tests() {
export JAVA_HOME="$ROOT/zulu21.28.85-ca-jdk21.0.0-linux_x64"
export PATH=$JAVA_HOME/bin:$PATH
mvn -T10 -B --no-transfer-progress clean test
echo "Start JPMS tests"
cd "$ROOT"/integration_tests/jpms_tests
mvn -T10 -B --no-transfer-progress clean compile
echo "Start jdk compatibility tests"
cd "$ROOT"/integration_tests/jdk_compatibility_tests
mvn -T10 -B --no-transfer-progress clean test
Expand Down
1 change: 1 addition & 0 deletions integration_tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ Integration tests for fury:
- [jdk_compatibility_tests](jdk_compatibility_tests): test fury compatibility across multiple jdk versions.
- [latest_jdk_tests](latest_jdk_tests): test latest jdk.
- [graalvm_tests](graalvm_tests): test graalvm native image support.
- [jpms_tests](jpms_tests): test JPMS module names.

> Note that this integration_tests is not designed as a maven multi-module project on purpose, so we can introduce features of higher jdk version without breaking compilation for lower jdk, and add integration tests for other languages.
79 changes: 79 additions & 0 deletions integration_tests/jpms_tests/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?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 xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.fury</groupId>
<artifactId>fury-parent</artifactId>
<version>0.5.0-SNAPSHOT</version>
<relativePath>../../java</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jpms_tests</artifactId>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.release>11</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.fury</groupId>
<artifactId>benchmark</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.fury</groupId>
<artifactId>fury-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.fury</groupId>
<artifactId>fury-format</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.fury</groupId>
<artifactId>fury-test-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.fury</groupId>
<artifactId>fury-testsuite</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

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

</project>
29 changes: 29 additions & 0 deletions integration_tests/jpms_tests/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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.
*/

module org.apache.fury.integration_tests {

requires org.apache.fury.benchmark;
requires org.apache.fury.core;
requires org.apache.fury.format;
requires org.apache.fury.test.core;

// we can't really test any classes from this module because it only contains test-classes
requires org.apache.fury.test.suite;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* 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.
*/

package org.apache.fury.integration_tests;

import org.apache.fury.Fury;
import org.apache.fury.benchmark.Benchmark;
import org.apache.fury.format.encoder.Encoders;
import org.apache.fury.test.bean.Foo;

/**
* A test class that simply references classes from the various Fury artifacts to check whether
* they specify the module names referenced in the module-info descriptor.
*/
public class Test {

public static void main(String[] args) {
final Fury fury = Fury.builder().build();
fury.serialize(Foo.create());

Encoders.bean(Benchmark.class, fury);
}
}
11 changes: 11 additions & 0 deletions java/benchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,17 @@
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.apache.fury.benchmark</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand Down
11 changes: 11 additions & 0 deletions java/fury-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.apache.fury.core</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand Down
16 changes: 16 additions & 0 deletions java/fury-format/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,22 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.apache.fury.format</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>releaseShade</id>
Expand Down
11 changes: 11 additions & 0 deletions java/fury-test-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.apache.fury.test.core</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
Expand Down
11 changes: 11 additions & 0 deletions java/fury-testsuite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>org.apache.fury.test.suite</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
Expand Down

0 comments on commit 54faae1

Please sign in to comment.