|
1 | | -import org.gradle.api.tasks.testing.logging.TestExceptionFormat |
2 | | -import org.gradle.kotlin.dsl.support.kotlinCompilerOptions |
3 | | -import org.jetbrains.kotlin.gradle.plugin.KotlinPluginWrapper |
4 | | -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile |
5 | | -import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile |
6 | 1 | import org.jetbrains.kotlin.gradle.dsl.JvmTarget |
7 | 2 |
|
8 | | -plugins { |
9 | | - alias(libs.plugins.kotlinGradlePlugin) apply false |
10 | | - alias(libs.plugins.kotlinBinaryCompatibilityPlugin) apply false |
11 | | - alias(libs.plugins.mavenPublishGradlePlugin) apply false |
12 | | - alias(libs.plugins.versionsGradlePlugin) |
13 | | - alias(libs.plugins.versionCatalogUpdateGradlePlugin) |
14 | | - alias(libs.plugins.dokka) |
15 | | -} |
16 | | - |
17 | 3 | repositories { |
18 | 4 | mavenCentral() |
19 | | - gradlePluginPortal() |
20 | 5 | } |
21 | 6 |
|
22 | | -buildscript { |
23 | | - repositories { |
24 | | - mavenCentral() |
25 | | - } |
| 7 | +plugins { |
| 8 | + alias(libs.plugins.kotlinGradlePlugin) apply false |
| 9 | + alias(libs.plugins.dokka) |
| 10 | + alias(libs.plugins.versionsGradlePlugin) |
| 11 | + alias(libs.plugins.versionCatalogUpdateGradlePlugin) |
| 12 | + alias(libs.plugins.kotlinBinaryCompatibilityPlugin) apply false |
26 | 13 | } |
27 | 14 |
|
28 | 15 | subprojects { |
29 | | - buildscript { |
30 | | - repositories { |
31 | | - mavenCentral() |
32 | | - gradlePluginPortal() |
33 | | - } |
34 | | - } |
35 | | - |
36 | | - repositories { |
37 | | - mavenCentral() |
38 | | - } |
| 16 | + apply(plugin = "org.jetbrains.dokka") |
39 | 17 |
|
40 | | - apply(plugin = "java") |
41 | | - apply(plugin = "kotlin") |
42 | | - apply(plugin = rootProject.project.libs.plugins.kotlinBinaryCompatibilityPlugin.get().pluginId) |
43 | | - apply(plugin = rootProject.project.libs.plugins.mavenPublishGradlePlugin.get().pluginId) |
44 | | - |
45 | | - configure<JavaPluginExtension> { |
46 | | - withSourcesJar() |
47 | | - withJavadocJar() |
48 | | - } |
49 | | - |
50 | | - plugins.withId("com.vanniktech.maven.publish.base") { |
51 | | - val publishingExtension = extensions.getByType(PublishingExtension::class.java) |
52 | | - configure<com.vanniktech.maven.publish.MavenPublishBaseExtension> { |
53 | | - pomFromGradleProperties() |
54 | | - publishToMavenCentral(com.vanniktech.maven.publish.SonatypeHost.DEFAULT, true) |
55 | | - signAllPublications() |
56 | | - } |
57 | | - |
58 | | - publishingExtension.publications.create<MavenPublication>("maven") { |
59 | | - from(components["java"]) |
60 | | - } |
61 | | - } |
62 | | - |
63 | | - apply(plugin = "version-catalog") |
64 | | - |
65 | | - // Only apply if the project has the kotlin plugin added: |
66 | | - tasks.withType<KotlinJvmCompile>().configureEach { |
| 18 | + tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { |
67 | 19 | compilerOptions { |
68 | | - jvmTarget.set(JvmTarget.JVM_17) |
69 | | - allWarningsAsErrors.set(true) |
70 | | - } |
71 | | - } |
72 | | - |
73 | | - plugins.withType<KotlinPluginWrapper> { |
74 | | - tasks.withType<GenerateModuleMetadata> { |
75 | | - suppressedValidationErrors.add("enforced-platform") |
76 | | - } |
77 | | - |
78 | | - dependencies { |
79 | | - add("testImplementation", project.rootProject.libs.junitApi) |
80 | | - add("testRuntimeOnly", project.rootProject.libs.junitEngine) |
| 20 | + jvmTarget.set(JvmTarget.JVM_11) |
81 | 21 | } |
82 | 22 | } |
83 | 23 |
|
84 | 24 | tasks.withType<Test> { |
85 | | - dependsOn("apiCheck") |
86 | 25 | useJUnitPlatform() |
87 | | - testLogging { |
88 | | - events("started", "passed", "skipped", "failed") |
89 | | - exceptionFormat = TestExceptionFormat.FULL |
90 | | - showStandardStreams = false |
91 | | - } |
92 | 26 | } |
93 | 27 |
|
94 | | - apply(plugin = "com.github.ben-manes.versions") |
95 | | - |
96 | | - tasks.withType<com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask> { |
97 | | - revision = "release" |
98 | | - resolutionStrategy { |
99 | | - componentSelection { |
100 | | - all { |
101 | | - if (isNonStable(candidate.version) && !isNonStable(currentVersion)) { |
102 | | - reject("Release candidate") |
103 | | - } |
| 28 | + // Configure Dokka for each subproject |
| 29 | + tasks.withType<org.jetbrains.dokka.gradle.DokkaTask>().configureEach { |
| 30 | + dokkaSourceSets { |
| 31 | + named("main") { |
| 32 | + includes.from("module.md") |
| 33 | + moduleName.set(project.name) |
| 34 | + sourceLink { |
| 35 | + localDirectory.set(file("src/main/kotlin")) |
| 36 | + remoteUrl.set(uri("https://github.com/block/ln-invoice/tree/main/${project.name}/src/main/kotlin").toURL()) |
| 37 | + remoteLineSuffix.set("#L") |
104 | 38 | } |
105 | 39 | } |
106 | 40 | } |
107 | 41 | } |
108 | 42 | } |
109 | 43 |
|
110 | | -fun isNonStable(version: String): Boolean { |
111 | | - val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) } |
112 | | - val regex = "^[0-9,.v-]+(-r)?$".toRegex() |
113 | | - val isStable = stableKeyword || regex.matches(version) |
114 | | - return isStable.not() |
115 | | -} |
116 | | - |
117 | | -// this needs to be defined here for the versionCatalogUpdate |
118 | | -tasks.withType<com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask> { |
119 | | - revision = "release" |
120 | | - resolutionStrategy { |
121 | | - componentSelection { |
122 | | - all { |
123 | | - if (isNonStable(candidate.version) && !isNonStable(currentVersion)) { |
124 | | - reject("Release candidate") |
125 | | - } |
126 | | - } |
127 | | - } |
128 | | - } |
| 44 | +// Configure Dokka multi-module task |
| 45 | +tasks.dokkaHtmlMultiModule { |
| 46 | + outputDirectory.set(layout.buildDirectory.dir("dokka/html")) |
| 47 | + includes.from("dokka-docs/module.md") |
| 48 | + moduleName.set("ln-invoice") |
| 49 | + moduleVersion.set(project.version.toString()) |
129 | 50 | } |
130 | 51 |
|
131 | | -versionCatalogUpdate { |
132 | | - /** |
133 | | - * Use @pin and @keep in gradle/lib.versions.toml instead of defining here |
134 | | - */ |
135 | | - sortByKey.set(true) |
| 52 | +tasks.register("publishToMavenCentral") { |
| 53 | + group = "publishing" |
| 54 | + dependsOn( |
| 55 | + ":lib:publishToMavenCentral", |
| 56 | + ) |
136 | 57 | } |
0 commit comments