1
1
@file:Suppress(" UnstableApiUsage" )
2
2
3
+ import org.gradle.api.plugins.JavaPlugin.API_ELEMENTS_CONFIGURATION_NAME
4
+ import org.gradle.api.plugins.JavaPlugin.JAVADOC_ELEMENTS_CONFIGURATION_NAME
5
+ import org.gradle.api.plugins.JavaPlugin.RUNTIME_ELEMENTS_CONFIGURATION_NAME
6
+ import org.gradle.api.plugins.JavaPlugin.SOURCES_ELEMENTS_CONFIGURATION_NAME
3
7
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
4
8
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
5
9
6
10
plugins {
7
11
alias(libs.plugins.kotlin.jvm)
8
12
alias(libs.plugins.android.lint)
9
13
alias(libs.plugins.jetbrains.bcv)
14
+ alias(libs.plugins.jetbrains.dokka)
15
+ alias(libs.plugins.mavenPublish)
16
+ alias(libs.plugins.pluginPublish)
10
17
alias(libs.plugins.spotless)
11
- id(" shadow.convention.publish" )
18
+ }
19
+
20
+ version = providers.gradleProperty(" VERSION_NAME" ).get()
21
+ group = providers.gradleProperty(" GROUP" ).get()
22
+ description = providers.gradleProperty(" POM_DESCRIPTION" ).get()
23
+
24
+ dokka {
25
+ dokkaPublications.html {
26
+ outputDirectory = rootDir.resolve(" docs/api" )
27
+ }
12
28
}
13
29
14
30
java {
@@ -40,15 +56,43 @@ spotless {
40
56
}
41
57
kotlinGradle {
42
58
ktlint(libs.ktlint.get().version)
43
- target(" **/*.kts" )
44
- targetExclude(" build-logic/build/**" )
45
59
}
46
60
}
47
61
48
62
val testPluginClasspath by configurations.registering {
49
63
isCanBeResolved = true
50
64
}
51
65
66
+ configurations.configureEach {
67
+ when (name) {
68
+ API_ELEMENTS_CONFIGURATION_NAME ,
69
+ RUNTIME_ELEMENTS_CONFIGURATION_NAME ,
70
+ JAVADOC_ELEMENTS_CONFIGURATION_NAME ,
71
+ SOURCES_ELEMENTS_CONFIGURATION_NAME ,
72
+ -> {
73
+ outgoing {
74
+ // Main/current capability.
75
+ capability(" com.gradleup.shadow:shadow-gradle-plugin:$version " )
76
+
77
+ // Historical capabilities.
78
+ capability(" io.github.goooler.shadow:shadow-gradle-plugin:$version " )
79
+ capability(" com.github.johnrengelman:shadow:$version " )
80
+ capability(" gradle.plugin.com.github.jengelman.gradle.plugins:shadow:$version " )
81
+ capability(" gradle.plugin.com.github.johnrengelman:shadow:$version " )
82
+ capability(" com.github.jengelman.gradle.plugins:shadow:$version " )
83
+ }
84
+ }
85
+ }
86
+ }
87
+
88
+ publishing.publications.withType<MavenPublication >().configureEach {
89
+ // We don't care about capabilities being unmappable to Maven.
90
+ suppressPomMetadataWarningsFor(API_ELEMENTS_CONFIGURATION_NAME )
91
+ suppressPomMetadataWarningsFor(RUNTIME_ELEMENTS_CONFIGURATION_NAME )
92
+ suppressPomMetadataWarningsFor(JAVADOC_ELEMENTS_CONFIGURATION_NAME )
93
+ suppressPomMetadataWarningsFor(SOURCES_ELEMENTS_CONFIGURATION_NAME )
94
+ }
95
+
52
96
dependencies {
53
97
compileOnly(libs.kotlin.kmp)
54
98
implementation(libs.apache.ant)
@@ -61,8 +105,8 @@ dependencies {
61
105
implementation(libs.plexus.xml)
62
106
63
107
testPluginClasspath(libs.foojayResolver)
64
- testPluginClasspath(libs.pluginPublish)
65
108
testPluginClasspath(libs.kotlin.kmp)
109
+ testPluginClasspath(libs.pluginPublish)
66
110
67
111
lintChecks(libs.androidx.gradlePluginLints)
68
112
}
@@ -124,6 +168,26 @@ testing.suites {
124
168
}
125
169
}
126
170
171
+ gradlePlugin {
172
+ website = providers.gradleProperty(" POM_URL" )
173
+ vcsUrl = providers.gradleProperty(" POM_URL" )
174
+
175
+ plugins {
176
+ create(" shadowPlugin" ) {
177
+ id = " com.gradleup.shadow"
178
+ implementationClass = " com.github.jengelman.gradle.plugins.shadow.ShadowPlugin"
179
+ displayName = providers.gradleProperty(" POM_NAME" ).get()
180
+ description = providers.gradleProperty(" POM_DESCRIPTION" ).get()
181
+ tags = listOf (" onejar" , " shade" , " fatjar" , " uberjar" )
182
+ }
183
+ }
184
+
185
+ testSourceSets(
186
+ sourceSets[" functionalTest" ],
187
+ sourceSets[" documentTest" ],
188
+ )
189
+ }
190
+
127
191
// This part should be placed after testing.suites to ensure the test sourceSets are created.
128
192
kotlin.target.compilations {
129
193
val main by getting
@@ -133,13 +197,6 @@ kotlin.target.compilations {
133
197
}
134
198
}
135
199
136
- gradlePlugin {
137
- testSourceSets(
138
- sourceSets[" functionalTest" ],
139
- sourceSets[" documentTest" ],
140
- )
141
- }
142
-
143
200
tasks.pluginUnderTestMetadata {
144
201
// Plugins used in tests could be resolved in classpath.
145
202
pluginClasspath.from(
@@ -174,13 +231,9 @@ tasks.register<Copy>("downloadStartScripts") {
174
231
}
175
232
176
233
tasks.clean {
177
- val includedBuilds = gradle.includedBuilds
178
- dependsOn(includedBuilds.map { it.task(path) })
179
-
180
- val rootDirs = includedBuilds.map { it.projectDir } + projectDir
181
234
delete + = listOf (
182
- rootDirs.map { it. resolve(" .gradle" ) } ,
183
- rootDirs.map { it. resolve(" .kotlin" ) } ,
235
+ projectDir. resolve(" .gradle" ),
236
+ projectDir. resolve(" .kotlin" ),
184
237
dokka.dokkaPublications.html.map { it.outputDirectory },
185
238
// Generated by MkDocs.
186
239
rootDir.resolve(" site" ),
0 commit comments