Skip to content
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

Create a dedicated bundle / UberJAR module. #1029

Merged
merged 2 commits into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
File renamed without changes.
4 changes: 4 additions & 0 deletions bundle/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Aggregator project for building the single JAR with shaded dependencies.

This module aggregates the slim version, unpacks it and repackages it.
The sources are unpacked so that an individual JavaDoc artifact is produced, too.
11 changes: 11 additions & 0 deletions bundle/osgi.bnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package-version=${version;===;${Bundle-Version}}

Export-Package: \
*;version="${package-version}"

Import-Package: \
!io.netty.*, \
!reactor.core.*, \
!com.oracle.svm.*, \
javax.security.cert, \
*
189 changes: 189 additions & 0 deletions bundle/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
<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">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver-parent</artifactId>
<version>4.4-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

<artifactId>neo4j-java-driver</artifactId>

<packaging>jar</packaging>
<name>Neo4j Java Driver</name>
<description>Access to the Neo4j graph database through Java</description>

<properties>
<moduleName>org.neo4j.driver</moduleName>
<rootDir>${project.basedir}/..</rootDir>
<maven.deploy.skip>false</maven.deploy.skip>
</properties>

<dependencies>
<!-- The original driver that will be repackaged. -->
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver-slim</artifactId>
<version>${project.version}</version>
<optional>true</optional>
</dependency>

<!-- Optional and / or provided dependencies, as they are not transitive to the original driver they must be declared again. -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.graalvm.nativeimage</groupId>
<artifactId>svm</artifactId>
</dependency>

<!-- As we pretend the driver being provided only, we need be explicit about the one dependency we actually didn't shade. -->
<dependency>
<groupId>org.reactivestreams</groupId>
<artifactId>reactive-streams</artifactId>
</dependency>



</dependencies>

<build>
<plugins>
<!-- Extract the original sources again -->
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>unpack-dependencies</goal>
injectives marked this conversation as resolved.
Show resolved Hide resolved
</goals>
</execution>
</executions>
<configuration>
<classifier>sources</classifier>
<type>jar</type>
<outputDirectory>${project.build.directory}/generated-sources/slim</outputDirectory>
<includeArtifactIds>neo4j-java-driver-slim</includeArtifactIds>
<includes>**\/*.java</includes>
<overWriteSnapshots>true</overWriteSnapshots>
</configuration>
</plugin>
<!-- Attach them -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>attach-original-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${project.build.directory}/generated-sources/slim</source>
</sources>
</configuration>
</execution>
<execution>
<id>set-osgi-version</id>
<phase>validate</phase>
<goals>
<goal>parse-version</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
<configuration>
<archive>
<index>true</index>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
<manifest>
<packageName>org/neo4j/driver</packageName>
</manifest>
<manifestEntries>
<!-- This is used to programmatically determine the driver version -->
<Implementation-Version>${project.version}-${build.revision}</Implementation-Version>
<!-- Stable module name for JDK9 automatic modules -->
<Automatic-Module-Name>${moduleName}</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>io.netty:*</include>
<include>io.projectreactor:*</include>
</includes>
</artifactSet>
<relocations>
<relocation>
<pattern>io.netty</pattern>
<shadedPattern>org.neo4j.driver.internal.shaded.io.netty</shadedPattern>
</relocation>
<relocation>
<pattern>reactor</pattern>
<shadedPattern>org.neo4j.driver.internal.shaded.reactor</shadedPattern>
</relocation>
</relocations>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
<filters>
<filter>
<artifact>io.netty:*</artifact>
<excludes>
<exclude>META-INF/native-image/**</exclude>
</excludes>
</filter>
</filters>
<shadeTestJar>true</shadeTestJar>
<createSourcesJar>true</createSourcesJar>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Args = -H:ReflectionConfigurationResources=${.}/reflection-config.json \
--initialize-at-run-time=org.neo4j.driver.internal.async.connection.BoltProtocolUtil \
--initialize-at-run-time=org.neo4j.driver.internal.async.connection.ChannelAttributes \
--initialize-at-run-time=org.neo4j.driver.internal.async.connection.ChannelConnectedListener \
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.buffer.AbstractReferenceCountedByteBuf \
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.buffer.ByteBufAllocator \
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.buffer.ByteBufUtil \
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.buffer.ByteBufUtil$HexUtil \
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.buffer.PooledByteBufAllocator \
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.buffer.UnpooledHeapByteBuf \
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.buffer.UnreleasableByteBuf \
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.handler.ssl.Conscrypt \
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.handler.ssl.ConscryptAlpnSslEngine \
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.handler.ssl.JdkNpnApplicationProtocolNegotiator \
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.handler.ssl.ReferenceCountedOpenSslEngine \
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.handler.ssl.util.ThreadLocalInsecureRandom \
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.util.AbstractReferenceCounted \
--initialize-at-run-time=org.neo4j.driver.internal.shaded.io.netty.util.internal.logging.Log4JLogger \
-Dio.netty.noUnsafe=true \
-Dio.netty.leakDetection.level=DISABLED
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
[
{
"name": "org.neo4j.driver.internal.shaded.io.netty.channel.socket.nio.NioSocketChannel",
"methods": [
{ "name": "<init>", "parameterTypes": [] }
]
},
{
"name": "org.neo4j.driver.internal.shaded.io.netty.channel.socket.nio.NioServerSocketChannel",
"methods": [
{ "name": "<init>", "parameterTypes": [] }
]
},
{
"name" : "org.neo4j.driver.internal.shaded.io.netty.buffer.AbstractByteBufAllocator",
"allDeclaredMethods" : true
},
{
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.ReferenceCountUtil",
"allDeclaredMethods" : true
},
{
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueueProducerIndexField",
"fields": [
{"name": "producerIndex", "allowUnsafeAccess": true}
]
},
{
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueueProducerLimitField",
"fields": [
{"name": "producerLimit", "allowUnsafeAccess": true}
]
},
{
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.internal.shaded.org.jctools.queues.MpscArrayQueueConsumerIndexField",
"fields": [
{"name": "consumerIndex", "allowUnsafeAccess": true}
]
},
{
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueProducerFields",
"fields": [
{"name": "producerIndex", "allowUnsafeAccess": true}
]
},
{
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueColdProducerFields",
"fields": [
{"name": "producerLimit", "allowUnsafeAccess": true}
]
},
{
"name" : "org.neo4j.driver.internal.shaded.io.netty.util.internal.shaded.org.jctools.queues.BaseMpscLinkedArrayQueueConsumerFields",
"fields": [
{"name": "consumerIndex", "allowUnsafeAccess": true}
]
}
]
4 changes: 1 addition & 3 deletions driver/osgi.bnd
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package-version=${version;===;${Bundle-Version}}

Export-Package: \
!*.internal.*, \
*;version="${package-version}"

Import-Package: \
!io.netty.*, \
!reactor.core.*, \
!com.oracle.svm.*, \
javax.security.cert, \
*

Loading