Skip to content
Open
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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.1.0/),

## [Unreleased]

**Changed**

- The shaded jar is published as a separate package `io.dgraph:dgraph4j-shaded`, with a pom that
does not declare the bundled dependencies. It used to be published as a `shaded`-classified
artifact of `io.dgraph:dgraph4j`, which shares the pom of the main jar and therefore wrongly
declared all dependencies that the shaded jar already bundles.

## [25.0.0] - 2026-04-01

**Added**
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,24 @@ or Gradle:
compile 'io.dgraph:dgraph4j:25.0.0'
```

There is also a shaded variant, which bundles all dependencies relocated into the
`io.dgraph.dgraph4j.shaded` package, so that they cannot conflict with the versions used by your
application. Its public API is identical, only the coordinates differ:

```xml
<dependency>
<groupId>io.dgraph</groupId>
<artifactId>dgraph4j-shaded</artifactId>
<version>25.0.0</version>
</dependency>
```

or Gradle:

```groovy
implementation 'io.dgraph:dgraph4j-shaded:25.0.0'
```

## Supported Versions

Depending on the version of Dgraph that you are connecting to, you will have to use a different
Expand Down
99 changes: 54 additions & 45 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ apply plugin: 'signing'
group = 'io.dgraph'
version = '25.0.0'

def mainArtifactId = 'dgraph4j'
def shadedArtifactId = 'dgraph4j-shaded'

base {
archivesName = 'dgraph4j'
archivesName = mainArtifactId
}

// Upgrade to Java SE 11 to match updated protobuf-protoc version.
Expand Down Expand Up @@ -144,35 +147,30 @@ test {
systemProperties['org.slf4j.simpleLogger.log.io.dgraph.DgraphIntegrationTest'] = 'DEBUG'
}

//create a single Jar with all dependencies
task fatJar(type: Jar) {
tasks.named('jar', Jar) {
manifest {
attributes 'Implementation-Title': 'Dgraph Client for Java',
'Implementation-Version': version
}
base { archivesName = project.name + '-all' }
from { configurations.compile.collect { it.directory() ? it : zipTree(it) } }
with jar
}

// The shaded jar bundles all dependencies (relocated), so it cannot share the pom
// of the main jar - that pom declares those very dependencies. It is therefore
// published as its own package ('dgraph4j-shaded') with a dependency-free pom,
// instead of as a classified artifact of the main package.
tasks.named('shadowJar', ShadowJar) {
enableRelocation = true
relocationPrefix = 'io.dgraph.dgraph4j.shaded'
relocate('google', 'io.dgraph.dgraph4j.shaded.google')
archiveClassifier.set('shaded')
archiveBaseName = shadedArtifactId
archiveClassifier = ''
mergeServiceFiles()
}

task buildJar(type: Jar)

task javadocJar(type: Jar) {
archiveClassifier = 'javadoc'
from javadoc
}

task sourceJar(type: Jar) {
archiveClassifier = 'sources'
from sourceSets.main.allJava
// Keep the shaded jar out of the main package: the shadow plugin adds it to the
// java component, which would publish it under the main coordinates.
components.java.withVariantsFromConfiguration(configurations.shadowRuntimeElements) {
skip()
}

task updateProto(type: Exec) {
Expand All @@ -191,11 +189,9 @@ task integrationTest(type: Test) {
classpath = sourceSets.integrationTest.runtimeClasspath
}

artifacts {
archives jar
archives shadowJar
archives sourceJar
archives javadocJar
// build both jars, as well as the sources and javadoc jars, on 'assemble'
tasks.named('assemble') {
dependsOn tasks.named('shadowJar'), tasks.named('sourcesJar'), tasks.named('javadocJar')
}

jacocoTestReport {
Expand All @@ -209,34 +205,47 @@ java {
withJavadocJar()
}

def configurePom = { pom, String pomName, String pomDescription ->
pom.name = pomName
pom.description = pomDescription
pom.url = 'https://github.com/dgraph-io/dgraph4j'

pom.licenses { licenses ->
licenses.license { license ->
license.name = 'Apache License 2.0'
license.url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
pom.developers { developers ->
developers.developer { developer ->
developer.name = 'Istari Digital, Inc.'
developer.email = 'dgraph-admin@istaridigital.com'
}
}
pom.scm { scm ->
scm.connection = 'https://github.com/dgraph-io/dgraph4j.git'
scm.url = 'https://github.com/dgraph-io/dgraph4j'
}
}

publishing {
publications {
mavenJava(MavenPublication) {
artifactId = 'dgraph4j'
artifactId = mainArtifactId
from components.java

pom {
name = 'dgraph4j'
description = 'Dgraph Java Client'
url = 'https://github.com/dgraph-io/dgraph4j'
configurePom(pom, mainArtifactId, 'Dgraph Java Client')
}

licenses {
license {
name = 'Apache License 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
name = 'Istari Digital, Inc.'
email = 'dgraph-admin@istaridigital.com'
}
}
scm {
connection = 'https://github.com/dgraph-io/dgraph4j.git'
url = 'https://github.com/dgraph-io/dgraph4j'
}
}
// The shaded jar carries its dependencies, hence this package has no
// dependencies declared in its pom.
mavenJavaShaded(MavenPublication) {
artifactId = shadedArtifactId
artifact tasks.named('shadowJar')
artifact tasks.named('sourcesJar')
artifact tasks.named('javadocJar')

configurePom(pom, shadedArtifactId, 'Dgraph Java Client with shaded dependencies')
}
}
}
Expand All @@ -258,7 +267,7 @@ signing {
if (signingKey) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
sign publishing.publications.mavenJava
sign publishing.publications.mavenJava, publishing.publications.mavenJavaShaded
}

task version {
Expand Down
Loading