Skip to content

Commit dfef7c7

Browse files
committed
🔧 chore(deps): update gradle and library versions
- update gradle wrapper to version 9.7.1 - update exposed library version from 1.4.0 to 1.5.0 - update version in gradle.properties from 2.3.3 to 2.3.4
1 parent 78efc1d commit dfef7c7

4 files changed

Lines changed: 166 additions & 10 deletions

File tree

‎build.gradle.kts‎

Lines changed: 163 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar.Companion.shadowJar
22
import dev.slne.surf.api.gradle.util.slneReleases
3+
import org.gradle.api.artifacts.MinimalExternalModuleDependency
4+
import org.jetbrains.dokka.gradle.tasks.DokkaGenerateTask
35

46
plugins {
57
id("dev.slne.surf.api.gradle.core") version "+"
8+
id("org.jetbrains.dokka-javadoc") version "2.2.0"
69
}
710

811
surfCoreApi {
@@ -34,6 +37,155 @@ shadow {
3437
addShadowVariantIntoJavaComponent = false
3538
}
3639

40+
val relocationPrefix = "dev.slne.surf.database.libs"
41+
val relocationPrefixPath = relocationPrefix.replace('.', '/')
42+
43+
val relocationExtraDepth = relocationPrefixPath.split('/').size
44+
45+
val shadedRoots = listOf(
46+
"org.jetbrains.exposed",
47+
"io.r2dbc",
48+
"io.netty",
49+
"org.mariadb",
50+
"com.ongres",
51+
"org.jspecify",
52+
"kotlinx.datetime",
53+
"reactor.netty",
54+
"reactor.pool",
55+
)
56+
57+
val relocationRewrites = shadedRoots.flatMap { root ->
58+
listOf(
59+
root to "$relocationPrefix.$root",
60+
root.replace('.', '/') to "$relocationPrefixPath/${root.replace('.', '/')}",
61+
)
62+
}
63+
64+
fun String.applyRelocations(): String {
65+
var rewritten = this
66+
for ((from, to) in relocationRewrites) {
67+
if (rewritten.contains(from)) rewritten = rewritten.replace(from, to)
68+
}
69+
return rewritten
70+
}
71+
72+
fun docsConfiguration(
73+
configurationName: String,
74+
classifier: String,
75+
modules: List<Provider<MinimalExternalModuleDependency>>,
76+
): Configuration {
77+
val configuration = configurations.create(configurationName) {
78+
isCanBeConsumed = false
79+
isCanBeResolved = true
80+
isTransitive = false
81+
}
82+
83+
dependencies {
84+
modules.forEach { module ->
85+
add(configurationName, variantOf(module) { classifier(classifier) })
86+
}
87+
}
88+
89+
return configuration
90+
}
91+
92+
fun registerDocsRelocation(
93+
taskName: String,
94+
source: Configuration,
95+
outputDirectory: String,
96+
includes: List<String>,
97+
textFileSuffixes: List<String>,
98+
rewriteLinkDepth: Boolean,
99+
) = tasks.register<Sync>(taskName) {
100+
description = "Rewrites bundled dependency documentation onto the shaded package names."
101+
group = JavaBasePlugin.DOCUMENTATION_GROUP
102+
103+
into(layout.buildDirectory.dir(outputDirectory))
104+
includeEmptyDirs = false
105+
filteringCharset = Charsets.UTF_8.name()
106+
107+
inputs.property("relocationRewrites", relocationRewrites.toString())
108+
inputs.property("rewriteLinkDepth", rewriteLinkDepth)
109+
110+
from(source.elements.map { jars -> jars.map(::zipTree) }) {
111+
includes.forEach { include(it) }
112+
113+
eachFile {
114+
val depth = relativePath.segments.size - 1
115+
116+
if (textFileSuffixes.any { name.endsWith(it) }) {
117+
filter { line ->
118+
val relinked = if (rewriteLinkDepth) {
119+
line.replace(
120+
"../".repeat(depth),
121+
"../".repeat(depth + relocationExtraDepth),
122+
)
123+
} else {
124+
line
125+
}
126+
127+
relinked.applyRelocations()
128+
}
129+
}
130+
131+
path = "$relocationPrefixPath/$path"
132+
}
133+
}
134+
}
135+
136+
val sourceDocModules = listOf(
137+
libs.exposed.core,
138+
libs.exposed.r2dbc,
139+
libs.exposed.java.time,
140+
libs.exposed.json,
141+
libs.exposed.migration.r2dbc,
142+
libs.r2dbc.pool,
143+
libs.r2dbc.mariadb,
144+
libs.r2dbc.postgresql,
145+
)
146+
147+
val javadocDocModules = listOf(
148+
libs.r2dbc.pool,
149+
libs.r2dbc.mariadb,
150+
libs.r2dbc.postgresql,
151+
)
152+
153+
val relocateDependencySources = registerDocsRelocation(
154+
taskName = "relocateDependencySources",
155+
source = docsConfiguration("dependencyDocsSources", "sources", sourceDocModules),
156+
outputDirectory = "docs/relocated-sources",
157+
includes = listOf("org/jetbrains/exposed/**", "io/r2dbc/**", "org/mariadb/**"),
158+
textFileSuffixes = listOf(".kt", ".java"),
159+
rewriteLinkDepth = false,
160+
)
161+
162+
val relocateDependencyJavadoc = registerDocsRelocation(
163+
taskName = "relocateDependencyJavadoc",
164+
source = docsConfiguration("dependencyDocsJavadoc", "javadoc", javadocDocModules),
165+
outputDirectory = "docs/relocated-javadoc",
166+
includes = listOf("io/r2dbc/**", "org/mariadb/**"),
167+
textFileSuffixes = listOf(".html"),
168+
rewriteLinkDepth = true,
169+
)
170+
171+
tasks.javadoc {
172+
setSource(files())
173+
setDestinationDir(layout.buildDirectory.dir("docs/javadoc-unused").get().asFile)
174+
}
175+
176+
tasks.named<Jar>("javadocJar") {
177+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
178+
179+
from(tasks.named<DokkaGenerateTask>("dokkaGeneratePublicationJavadoc").flatMap { it.outputDirectory })
180+
from(relocateDependencyJavadoc)
181+
}
182+
183+
tasks.named<Jar>("sourcesJar") {
184+
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
185+
186+
from(relocateDependencySources)
187+
}
188+
37189
java {
38190
withSourcesJar()
39191
withJavadocJar()
@@ -50,6 +202,10 @@ tasks {
50202
}
51203
}
52204

205+
val shadowComponent = components["shadow"] as AdhocComponentWithVariants
206+
shadowComponent.addVariantsFromConfiguration(configurations["sourcesElements"]) {}
207+
shadowComponent.addVariantsFromConfiguration(configurations["javadocElements"]) {}
208+
53209
publishing {
54210
publications {
55211
create<MavenPublication>("shadow") {
@@ -64,13 +220,13 @@ publishing {
64220

65221

66222
/**
67-
* Only publish shadow variant
223+
* Only publish the shadow variant; the auto-created pluginMaven publication would claim the same
224+
* coordinates.
68225
*/
69226
afterEvaluate {
70-
tasks.named("publishPluginMavenPublicationToSlne-repository-releasesRepository") {
71-
enabled = false
72-
}
73-
tasks.named("publishPluginMavenPublicationToMavenLocal") {
74-
enabled = false
227+
tasks.withType<AbstractPublishToMaven>().configureEach {
228+
onlyIf("only the shadow publication owns these coordinates") {
229+
publication.name != "pluginMaven"
230+
}
75231
}
76-
}
232+
}

‎gradle.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ kotlin.stdlib.default.dependency=false
33
org.gradle.parallel=true
44
#org.gradle.caching=true
55
#org.gradle.configureondemand=true
6-
version=2.3.3
6+
version=2.3.4

‎gradle/libs.versions.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
exposed = "1.4.0"
2+
exposed = "1.5.0"
33
r2dbc-mariadb = "1.4.1"
44
r2dbc-postgresql = "1.1.2.RELEASE"
55
r2dbc-pool = "1.0.2.RELEASE"

‎gradle/wrapper/gradle-wrapper.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.1-bin.zip
44
networkTimeout=10000
55
retries=0
66
retryBackOffMs=500

0 commit comments

Comments
 (0)