Skip to content

Commit c0737be

Browse files
authored
Make the shaded artifact compile as a module (#1388)
* Make the shaded artifact compile as a module This update makes sure the shaded artifact is compiled as a module. This is needed for the features that depend on that, for instance the `sealed` types used across packages. In addition, the shaded `module-info.java` is kept as a source file so that it could be checked by the licensing plugin and also be added into the sources jar. * Update README
1 parent ae7fc64 commit c0737be

File tree

4 files changed

+77
-24
lines changed

4 files changed

+77
-24
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ All available versions of this driver can be found at
5050

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

53-
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.
53+
Starting from version 5.0 the `neo4j-java-driver` includes an explicit module declaration ([module-info.java](driver/src/main/java/module-info.java)).
54+
55+
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.
5456

5557
### Example
5658

bundle/pom.xml

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@
100100
<includes>
101101
<include>**\/*.java</include>
102102
</includes>
103-
<excludes>
104-
<exclude>module-info.java</exclude>
105-
</excludes>
106103
</resource>
107104
</resources>
108105
</configuration>
@@ -210,13 +207,39 @@
210207
<exclude>META-INF/native-image/**</exclude>
211208
</excludes>
212209
</filter>
210+
<filter>
211+
<artifact>${groupId}:${artifactId}</artifact>
212+
<excludes>
213+
<exclude>module-info.java</exclude>
214+
</excludes>
215+
</filter>
213216
</filters>
214217
<shadeTestJar>true</shadeTestJar>
215218
<createSourcesJar>true</createSourcesJar>
216219
</configuration>
217220
</execution>
218221
</executions>
219222
</plugin>
223+
<plugin>
224+
<groupId>org.apache.maven.plugins</groupId>
225+
<artifactId>maven-antrun-plugin</artifactId>
226+
<executions>
227+
<execution>
228+
<id>add-module-info-to-sources</id>
229+
<phase>package</phase>
230+
<goals>
231+
<goal>run</goal>
232+
</goals>
233+
<configuration>
234+
<target>
235+
<unzip src="${project.build.directory}/${artifactId}-${version}-sources.jar" dest="${project.build.directory}/sources-with-module"/>
236+
<copy file="${project.basedir}/src/main/jpms/module-info.java" tofile="${project.build.directory}/sources-with-module/module-info.java" />
237+
<zip basedir="${project.build.directory}/sources-with-module" destfile="${project.build.directory}/${artifactId}-${version}-sources.jar"/>
238+
</target>
239+
</configuration>
240+
</execution>
241+
</executions>
242+
</plugin>
220243
<plugin>
221244
<groupId>org.moditect</groupId>
222245
<artifactId>moditect-maven-plugin</artifactId>
@@ -230,26 +253,9 @@
230253
<configuration>
231254
<overwriteExistingFiles>true</overwriteExistingFiles>
232255
<module>
233-
<moduleInfoSource><![CDATA[
234-
module org.neo4j.driver {
235-
exports org.neo4j.driver;
236-
exports org.neo4j.driver.async;
237-
exports org.neo4j.driver.reactive;
238-
exports org.neo4j.driver.reactivestreams;
239-
exports org.neo4j.driver.types;
240-
exports org.neo4j.driver.summary;
241-
exports org.neo4j.driver.net;
242-
exports org.neo4j.driver.util;
243-
exports org.neo4j.driver.exceptions;
244-
245-
requires transitive java.logging;
246-
requires transitive org.reactivestreams;
247-
requires static micrometer.core;
248-
requires static org.graalvm.sdk;
249-
requires static org.slf4j;
250-
requires static java.management;
251-
}
252-
]]></moduleInfoSource>
256+
<moduleInfoFile>
257+
${basedir}/src/main/jpms/module-info.java
258+
</moduleInfoFile>
253259
</module>
254260
</configuration>
255261
</execution>

bundle/src/main/jpms/module-info.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
*/
19+
/**
20+
* The Neo4j Java Driver module.
21+
*/
22+
@SuppressWarnings({"requires-automatic", "requires-transitive-automatic"})
23+
module org.neo4j.driver {
24+
exports org.neo4j.driver;
25+
exports org.neo4j.driver.async;
26+
exports org.neo4j.driver.reactive;
27+
exports org.neo4j.driver.reactivestreams;
28+
exports org.neo4j.driver.types;
29+
exports org.neo4j.driver.summary;
30+
exports org.neo4j.driver.net;
31+
exports org.neo4j.driver.util;
32+
exports org.neo4j.driver.exceptions;
33+
34+
requires transitive java.logging;
35+
requires transitive org.reactivestreams;
36+
requires static micrometer.core;
37+
requires static org.graalvm.sdk;
38+
requires static org.slf4j;
39+
requires static java.management;
40+
}

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,11 @@
620620
<artifactId>moditect-maven-plugin</artifactId>
621621
<version>1.0.0.RC2</version>
622622
</plugin>
623+
<plugin>
624+
<groupId>org.apache.maven.plugins</groupId>
625+
<artifactId>maven-antrun-plugin</artifactId>
626+
<version>3.1.0</version>
627+
</plugin>
623628
</plugins>
624629
</pluginManagement>
625630

0 commit comments

Comments
 (0)