Skip to content
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
35 changes: 16 additions & 19 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,23 @@ subprojects {
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
}

// We have to set the dokka configuration after evaluation since the com.vanniktech.maven.publish
// plugin overwrites our dokka configuration on projects where it's applied.
afterEvaluate {
tasks.withType<DokkaTask>().configureEach {
val dokkaTask = this
dokkaSourceSets.configureEach {
reportUndocumented.set(false)
skipDeprecated.set(true)
jdkVersion.set(11)

externalDocumentationLink {
url.set(URL("https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/"))
packageListUrl.set(
URL("https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/package-list")
)
}
tasks.withType<DokkaTask>().configureEach {
val dokkaTask = this

if (dokkaTask.name == "dokkaGfm") {
outputDirectory.set(project.file("$rootDir/docs/1.x"))
}
if (dokkaTask.name == "dokkaGfm") {
outputDirectory.set(project.file("$rootDir/docs/1.x/${project.name}"))
}

dokkaSourceSets.configureEach {
reportUndocumented.set(false)
skipDeprecated.set(true)
jdkVersion.set(11)

externalDocumentationLink {
url.set(URL("https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/"))
packageListUrl.set(
URL("https://docs.aws.amazon.com/AWSJavaSDK/latest/javadoc/package-list")
)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ kotlinxCoroutinesJdk8 = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-jdk
kotlinxCoroutinesReactive = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-reactive", version = "1.6.4" }
log4jCore = { module = "org.apache.logging.log4j:log4j-core", version = "2.17.1" }
loggingApi = { module = "io.github.microutils:kotlin-logging", version = "2.0.10" }
mavenPublishGradlePlugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version = "0.25.2" }
mavenPublishGradlePlugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version = "0.28.0" }
moshiCore = { module = "com.squareup.moshi:moshi", version = "1.15.2" }
moshiKotlin = { module = "com.squareup.moshi:moshi-kotlin", version = "1.15.2" }
nettyBom = { module = "io.netty:netty-bom", version = "4.1.79.Final" }
Expand Down
43 changes: 37 additions & 6 deletions tempest-dynamodb-local/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import com.vanniktech.maven.publish.JavaLibrary
import com.vanniktech.maven.publish.JavadocJar
import com.vanniktech.maven.publish.JavadocJar.Dokka
import com.vanniktech.maven.publish.KotlinJvm
import com.vanniktech.maven.publish.MavenPublishBaseExtension

plugins {
kotlin("jvm")
`java-library`
id("com.gradleup.shadow")
id("com.vanniktech.maven.publish.base")
Expand Down Expand Up @@ -32,6 +33,10 @@ dependencies {
shadow(libs.bundles.sqlite4java)
}

tasks.named<Jar>("jar") {
archiveClassifier.set("unshaded")
}

tasks.shadowJar {
// Dependencies to be shaded must be explicitly included as dependencies.
dependencies {
Expand Down Expand Up @@ -65,9 +70,35 @@ tasks.shadowJar {

configure<MavenPublishBaseExtension> {
configure(
JavaLibrary(
javadocJar = JavadocJar.Empty(),
sourcesJar = false,
)
KotlinJvm(javadocJar = Dokka("dokkaGfm"))
)

pom {
withXml {
val root = asNode()

// First collect all dependencies nodes.
val dependenciesNodes = root.children()
.filterIsInstance<groovy.util.Node>()
.filter { it.name().toString().contains("dependencies") }
.toList()

// Then remove them safely.
dependenciesNodes.forEach { node ->
root.remove(node)
}

// Add a new dependencies node with shadow configuration.
val dependenciesNode = root.appendNode("dependencies")

// Add all shadow dependencies to the POM.
project.configurations.named("shadow").get().allDependencies.forEach { dep ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The net effect here is to remove the dependencies that were shaded, right? Kinda surprised this needs to be done explicitly but I don't have much experience with the intersection of shadow and publication

Copy link
Collaborator Author

@ThePumpingLemma ThePumpingLemma Apr 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this surprised me as well. What's happening is that the publication is using the runtime classpath, which is not the same as the shadow classpath of the shadow jar. If you publish via the shadow plugin, it can handle this for you, but I didn't want to change the publication mechanism.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ThePumpingLemma can you elaborate on

but I didn't want to change the publication mechanism

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to switch which plugin was used to publish to maven, but if we're okay with doing this via the shadow plugin and it's easier then let's do it.

val dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", dep.group)
dependencyNode.appendNode("artifactId", dep.name)
dependencyNode.appendNode("version", dep.version)
dependencyNode.appendNode("scope", "compile")
}
}
}
}
Loading