@@ -5,87 +5,45 @@ plugins {
55 id(" buildsrc.conventions.java-base" )
66 id(" org.gradle.kotlin.kotlin-dsl" )
77 id(" com.gradle.plugin-publish" )
8- `maven- publish`
98}
109
1110tasks.validatePlugins {
1211 enableStricterValidation = true
1312}
1413
15- sourceSets {
16- configureEach {
17- java.setSrcDirs(emptyList<File >())
14+ val createJavadocJarReadme by tasks.registering(Sync ::class ) {
15+ description = " generate a readme.txt for the Javadoc JAR"
16+ val projectCoords = provider { project.run { " $group :$name :$version " } }
17+ inputs.property(" projectGAV" , projectCoords)
18+ val projectCoordsToken = " %{projectGAV}"
19+ from(
20+ resources.text.fromString(
21+ """
22+ |This Javadoc JAR for $projectCoordsToken is intentionally empty.
23+ |
24+ |For documentation, see the sources JAR or https://github.com/adamko-dev/kotlin-binary-compatibility-validator-mu/
25+ |
26+ """ .trimMargin()
27+ )
28+ ) {
29+ rename { " readme.txt" }
30+ }
31+ into(temporaryDir)
32+ doLast {
33+ temporaryDir.walk()
34+ .filter { it.isFile }
35+ .forEach { file ->
36+ file.writeText(
37+ file.readText().replace(projectCoordsToken, projectCoords.get())
38+ )
39+ }
1840 }
1941}
2042
21- //
22- // /** These dependencies will be provided by Gradle, and we should prevent version conflict */
23- // fun Configuration.excludeGradleCommonDependencies() {
24- // dependencies
25- // .withType<ModuleDependency>()
26- // .configureEach {
27- // exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib")
28- // exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk7")
29- // exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8")
30- // exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-common")
31- // exclude(group = "org.jetbrains.kotlin", module = "kotlin-reflect")
32- // exclude(group = "org.jetbrains.kotlin", module = "kotlin-script-runtime")
33- // }
34- // }
35- //
36- // // Exclude Gradle runtime from given SourceSet configurations
37- // //configurations[sourceSet.implementationConfigurationName].excludeGradleCommonDependencies()
38- // //configurations[sourceSet.apiConfigurationName].excludeGradleCommonDependencies()
39- // //configurations[sourceSet.runtimeOnlyConfigurationName].excludeGradleCommonDependencies()
40- //
41- // dependencies {
42- // constraints {
43- //
44- // }
45- // }
46- //
47- // abstract class AsmCapability : ComponentMetadataRule {
48- // }
49- //
50- // @CacheableRule
51- // abstract class GradleKotlinLibsCapability () : ComponentMetadataRule {
52- //
53- // private val kotlinGroup = "org.jetbrains.kotlin"
54- // private val kotlinLibs = setOf(
55- // "kotlin-stdlib",
56- // "kotlin-stdlib-jdk7",
57- // "kotlin-stdlib-jdk8",
58- // "kotlin-stdlib-common",
59- // "kotlin-reflect",
60- // "kotlin-script-runtime",
61- // )
62- //
63- // override fun execute(context: ComponentMetadataContext) = context.details.run {
64- // if (id.group == kotlinGroup && id.name in kotlinLibs) {
65- // allVariants {
66- // withCapabilities {
67- // addCapability(kotlinGroup, "gradle-kotlin-embedded", id.version)
68- // }
69- // }
70- // }
71- // }
72- // override fun execute(context: ComponentMetadataContext) { context.details.withVariant("compile") {
73- // attributes {
74- // attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, jvmVersion)
75- // attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_API))
76- // }
77- // }
78- // }
79- // }
80- // dependencies {
81- // components {
82- // withModule<TargetJvmVersionRule>("commons-io:commons-io") {
83- // params(7)
84- // }
85- // withModule<TargetJvmVersionRule>("commons-collections:commons-collections") {
86- // params(8)
87- // }
88- // }
89- // implementation("commons-io:commons-io:2.6")
90- // implementation("commons-collections:commons-collections:3.2.2")
91- // }
43+
44+ // The Gradle Publish Plugin enables the Javadoc JAR in afterEvaluate, so find it lazily
45+ tasks.withType<Jar >()
46+ .matching { it.name == " javadocJar" }
47+ .configureEach {
48+ from(createJavadocJarReadme)
49+ }
0 commit comments