Skip to content

Make the shaded artifact compile as a module #1388

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

Merged
merged 2 commits into from
Mar 6, 2023
Merged
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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ All available versions of this driver can be found at

Both `neo4j-java-driver` and `neo4j-java-driver-all` artifacts have `org.neo4j.driver` module name.

Starting from version 5.0 the `neo4j-java-driver` includes an explicit module declaration ([module-info.java](driver/src/main/java/module-info.java)). The `neo4j-java-driver-all` stays unchanged and is shipped as an automatic module.
Starting from version 5.0 the `neo4j-java-driver` includes an explicit module declaration ([module-info.java](driver/src/main/java/module-info.java)).

The `neo4j-java-driver-all` includes an explicit module declaration ([module-info.java](bundle/src/main/jpms/module-info.java)) starting from version 5.7.

### Example

Expand Down
52 changes: 29 additions & 23 deletions bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@
<includes>
<include>**\/*.java</include>
</includes>
<excludes>
<exclude>module-info.java</exclude>
</excludes>
</resource>
</resources>
</configuration>
Expand Down Expand Up @@ -210,13 +207,39 @@
<exclude>META-INF/native-image/**</exclude>
</excludes>
</filter>
<filter>
<artifact>${groupId}:${artifactId}</artifact>
<excludes>
<exclude>module-info.java</exclude>
</excludes>
</filter>
</filters>
<shadeTestJar>true</shadeTestJar>
<createSourcesJar>true</createSourcesJar>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>add-module-info-to-sources</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<unzip src="${project.build.directory}/${artifactId}-${version}-sources.jar" dest="${project.build.directory}/sources-with-module"/>
<copy file="${project.basedir}/src/main/jpms/module-info.java" tofile="${project.build.directory}/sources-with-module/module-info.java" />
<zip basedir="${project.build.directory}/sources-with-module" destfile="${project.build.directory}/${artifactId}-${version}-sources.jar"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.moditect</groupId>
<artifactId>moditect-maven-plugin</artifactId>
Expand All @@ -230,26 +253,9 @@
<configuration>
<overwriteExistingFiles>true</overwriteExistingFiles>
<module>
<moduleInfoSource><![CDATA[
module org.neo4j.driver {
exports org.neo4j.driver;
exports org.neo4j.driver.async;
exports org.neo4j.driver.reactive;
exports org.neo4j.driver.reactivestreams;
exports org.neo4j.driver.types;
exports org.neo4j.driver.summary;
exports org.neo4j.driver.net;
exports org.neo4j.driver.util;
exports org.neo4j.driver.exceptions;

requires transitive java.logging;
requires transitive org.reactivestreams;
requires static micrometer.core;
requires static org.graalvm.sdk;
requires static org.slf4j;
requires static java.management;
}
]]></moduleInfoSource>
<moduleInfoFile>
${basedir}/src/main/jpms/module-info.java
</moduleInfoFile>
</module>
</configuration>
</execution>
Expand Down
40 changes: 40 additions & 0 deletions bundle/src/main/jpms/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Licensed 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.
*/
/**
* The Neo4j Java Driver module.
*/
@SuppressWarnings({"requires-automatic", "requires-transitive-automatic"})
module org.neo4j.driver {
exports org.neo4j.driver;
exports org.neo4j.driver.async;
exports org.neo4j.driver.reactive;
exports org.neo4j.driver.reactivestreams;
exports org.neo4j.driver.types;
exports org.neo4j.driver.summary;
exports org.neo4j.driver.net;
exports org.neo4j.driver.util;
exports org.neo4j.driver.exceptions;

requires transitive java.logging;
requires transitive org.reactivestreams;
requires static micrometer.core;
requires static org.graalvm.sdk;
requires static org.slf4j;
requires static java.management;
}
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,11 @@
<artifactId>moditect-maven-plugin</artifactId>
<version>1.0.0.RC2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
</plugin>
</plugins>
</pluginManagement>

Expand Down