Skip to content

Commit d8dce60

Browse files
Create a dedicated bundle / UberJAR module. (#1029)
* Create a dedicated bundle / UberJAR module. This provides the driver UberJAR as it is known and used plus a slim deployment. It works by turning the previous main artifact into `neo4j-java-driver-slim` and the new bundle will be `neo4j-java-driver`. The bundle depends on the slim artifact, extracts it and attaches it during the build so that a valid JavaDoc artifact (and sources artifact) are created and than shades the rest into it as before. Care must be taken of the optional dependencies so that they are not included as well as the Reactive Streams API (so that it is a transitive dependency (the slim module is optional, otherwise the whole exercise would be in vain for downstream modules)). * Replace unpack-deps with simple copy of resources. Unpack dependencies works when executed after packaging, which is not the case when running `mvn test`.
1 parent fa51e5c commit d8dce60

File tree

15 files changed

+424
-199
lines changed

15 files changed

+424
-199
lines changed
File renamed without changes.

bundle/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Aggregator project for building the single JAR with shaded dependencies.
2+
3+
This module aggregates the slim version, unpacks it and repackages it.
4+
The sources are unpacked so that an individual JavaDoc artifact is produced, too.

bundle/osgi.bnd

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package-version=${version;===;${Bundle-Version}}
2+
3+
Export-Package: \
4+
*;version="${package-version}"
5+
6+
Import-Package: \
7+
!io.netty.*, \
8+
!reactor.core.*, \
9+
!com.oracle.svm.*, \
10+
javax.security.cert, \
11+
*

bundle/pom.xml

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
3+
http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>org.neo4j.driver</groupId>
8+
<artifactId>neo4j-java-driver-parent</artifactId>
9+
<version>4.4-SNAPSHOT</version>
10+
<relativePath>..</relativePath>
11+
</parent>
12+
13+
<artifactId>neo4j-java-driver</artifactId>
14+
15+
<packaging>jar</packaging>
16+
<name>Neo4j Java Driver</name>
17+
<description>Access to the Neo4j graph database through Java</description>
18+
19+
<properties>
20+
<moduleName>org.neo4j.driver</moduleName>
21+
<rootDir>${project.basedir}/..</rootDir>
22+
<maven.deploy.skip>false</maven.deploy.skip>
23+
</properties>
24+
25+
<dependencies>
26+
<!-- The original driver that will be repackaged. -->
27+
<dependency>
28+
<groupId>org.neo4j.driver</groupId>
29+
<artifactId>neo4j-java-driver-slim</artifactId>
30+
<version>${project.version}</version>
31+
<optional>true</optional>
32+
</dependency>
33+
34+
<!-- Optional and / or provided dependencies, as they are not transitive to the original driver they must be declared again. -->
35+
<dependency>
36+
<groupId>org.slf4j</groupId>
37+
<artifactId>slf4j-api</artifactId>
38+
<optional>true</optional>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.graalvm.nativeimage</groupId>
42+
<artifactId>svm</artifactId>
43+
</dependency>
44+
45+
<!-- As we pretend the driver being provided only, we need be explicit about the one dependency we actually didn't shade. -->
46+
<dependency>
47+
<groupId>org.reactivestreams</groupId>
48+
<artifactId>reactive-streams</artifactId>
49+
</dependency>
50+
</dependencies>
51+
52+
<build>
53+
<plugins>
54+
<!-- Extract the original sources again -->
55+
<plugin>
56+
<artifactId>maven-resources-plugin</artifactId>
57+
<executions>
58+
<execution>
59+
<id>copy-appCtx</id>
60+
<phase>generate-sources</phase>
61+
<goals>
62+
<goal>copy-resources</goal>
63+
</goals>
64+
<configuration>
65+
<outputDirectory>${project.build.directory}/generated-sources/slim</outputDirectory>
66+
<overwrite>true</overwrite>
67+
<resources>
68+
<resource>
69+
<directory>${rootDir}/driver/src/main/java</directory>
70+
<includes>**\/*.java</includes>
71+
</resource>
72+
</resources>
73+
</configuration>
74+
</execution>
75+
</executions>
76+
</plugin>
77+
<!-- Attach them -->
78+
<plugin>
79+
<groupId>org.codehaus.mojo</groupId>
80+
<artifactId>build-helper-maven-plugin</artifactId>
81+
<executions>
82+
<execution>
83+
<id>attach-original-sources</id>
84+
<phase>generate-sources</phase>
85+
<goals>
86+
<goal>add-source</goal>
87+
</goals>
88+
<configuration>
89+
<sources>
90+
<source>${project.build.directory}/generated-sources/slim</source>
91+
</sources>
92+
</configuration>
93+
</execution>
94+
<execution>
95+
<id>set-osgi-version</id>
96+
<phase>validate</phase>
97+
<goals>
98+
<goal>parse-version</goal>
99+
</goals>
100+
</execution>
101+
</executions>
102+
</plugin>
103+
<plugin>
104+
<groupId>org.apache.maven.plugins</groupId>
105+
<artifactId>maven-source-plugin</artifactId>
106+
</plugin>
107+
<plugin>
108+
<groupId>org.apache.maven.plugins</groupId>
109+
<artifactId>maven-javadoc-plugin</artifactId>
110+
</plugin>
111+
<plugin>
112+
<groupId>org.apache.maven.plugins</groupId>
113+
<artifactId>maven-jar-plugin</artifactId>
114+
<executions>
115+
<execution>
116+
<goals>
117+
<goal>test-jar</goal>
118+
</goals>
119+
</execution>
120+
</executions>
121+
<configuration>
122+
<archive>
123+
<index>true</index>
124+
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
125+
<manifest>
126+
<packageName>org/neo4j/driver</packageName>
127+
</manifest>
128+
<manifestEntries>
129+
<!-- This is used to programmatically determine the driver version -->
130+
<Implementation-Version>${project.version}-${build.revision}</Implementation-Version>
131+
<!-- Stable module name for JDK9 automatic modules -->
132+
<Automatic-Module-Name>${moduleName}</Automatic-Module-Name>
133+
</manifestEntries>
134+
</archive>
135+
</configuration>
136+
</plugin>
137+
<plugin>
138+
<groupId>org.apache.felix</groupId>
139+
<artifactId>maven-bundle-plugin</artifactId>
140+
<extensions>true</extensions>
141+
</plugin>
142+
<plugin>
143+
<groupId>org.apache.maven.plugins</groupId>
144+
<artifactId>maven-shade-plugin</artifactId>
145+
<executions>
146+
<execution>
147+
<phase>package</phase>
148+
<goals>
149+
<goal>shade</goal>
150+
</goals>
151+
<configuration>
152+
<artifactSet>
153+
<includes>
154+
<include>io.netty:*</include>
155+
<include>io.projectreactor:*</include>
156+
</includes>
157+
</artifactSet>
158+
<relocations>
159+
<relocation>
160+
<pattern>io.netty</pattern>
161+
<shadedPattern>org.neo4j.driver.internal.shaded.io.netty</shadedPattern>
162+
</relocation>
163+
<relocation>
164+
<pattern>reactor</pattern>
165+
<shadedPattern>org.neo4j.driver.internal.shaded.reactor</shadedPattern>
166+
</relocation>
167+
</relocations>
168+
<transformers>
169+
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
170+
</transformers>
171+
<filters>
172+
<filter>
173+
<artifact>io.netty:*</artifact>
174+
<excludes>
175+
<exclude>META-INF/native-image/**</exclude>
176+
</excludes>
177+
</filter>
178+
</filters>
179+
<shadeTestJar>true</shadeTestJar>
180+
<createSourcesJar>true</createSourcesJar>
181+
</configuration>
182+
</execution>
183+
</executions>
184+
</plugin>
185+
</plugins>
186+
</build>
187+
188+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Args = -H:ReflectionConfigurationResources=${.}/reflection-config.json \
2+
--initialize-at-run-time=org.neo4j.driver.internal.async.connection.BoltProtocolUtil \
3+
--initialize-at-run-time=org.neo4j.driver.internal.async.connection.ChannelAttributes \
4+
--initialize-at-run-time=org.neo4j.driver.internal.async.connection.ChannelConnectedListener \
5+
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.buffer.AbstractReferenceCountedByteBuf \
6+
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.buffer.ByteBufAllocator \
7+
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.buffer.ByteBufUtil \
8+
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.buffer.ByteBufUtil$HexUtil \
9+
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.buffer.PooledByteBufAllocator \
10+
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.buffer.UnpooledHeapByteBuf \
11+
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.buffer.UnreleasableByteBuf \
12+
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.handler.ssl.Conscrypt \
13+
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.handler.ssl.ConscryptAlpnSslEngine \
14+
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.handler.ssl.JdkNpnApplicationProtocolNegotiator \
15+
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.handler.ssl.ReferenceCountedOpenSslEngine \
16+
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.handler.ssl.util.ThreadLocalInsecureRandom \
17+
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.util.AbstractReferenceCounted \
18+
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.util.internal.logging.Log4JLogger \
19+
-Dio.netty.noUnsafe=true \
20+
-Dio.netty.leakDetection.level=DISABLED
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
[
2+
{
3+
"name": "org.neo4j.driver.internal.shaded.io.netty.channel.socket.nio.NioSocketChannel",
4+
"methods": [
5+
{ "name": "<init>", "parameterTypes": [] }
6+
]
7+
},
8+
{
9+
"name": "org.neo4j.driver.internal.shaded.io.netty.channel.socket.nio.NioServerSocketChannel",
10+
"methods": [
11+
{ "name": "<init>", "parameterTypes": [] }
12+
]
13+
},
14+
{
15+
"name" : "org.neo4j.driver.internal.shaded.io.netty.buffer.AbstractByteBufAllocator",
16+
"allDeclaredMethods" : true
17+
},
18+
{
19+
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.ReferenceCountUtil",
20+
"allDeclaredMethods" : true
21+
},
22+
{
23+
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueueProducerIndexField",
24+
"fields": [
25+
{"name": "producerIndex", "allowUnsafeAccess": true}
26+
]
27+
},
28+
{
29+
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueueProducerLimitField",
30+
"fields": [
31+
{"name": "producerLimit", "allowUnsafeAccess": true}
32+
]
33+
},
34+
{
35+
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueueConsumerIndexField",
36+
"fields": [
37+
{"name": "consumerIndex", "allowUnsafeAccess": true}
38+
]
39+
},
40+
{
41+
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueProducerFields",
42+
"fields": [
43+
{"name": "producerIndex", "allowUnsafeAccess": true}
44+
]
45+
},
46+
{
47+
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueColdProducerFields",
48+
"fields": [
49+
{"name": "producerLimit", "allowUnsafeAccess": true}
50+
]
51+
},
52+
{
53+
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueConsumerFields",
54+
"fields": [
55+
{"name": "consumerIndex", "allowUnsafeAccess": true}
56+
]
57+
}
58+
]

driver/osgi.bnd

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
package-version=${version;===;${Bundle-Version}}
22

33
Export-Package: \
4+
!*.internal.*, \
45
*;version="${package-version}"
56

67
Import-Package: \
7-
!io.netty.*, \
8-
!reactor.core.*, \
98
!com.oracle.svm.*, \
109
javax.security.cert, \
1110
*
12-

0 commit comments

Comments
 (0)