Build: Add sources and javadocs to Kotlin Plugin publication
This commit is contained in:
@@ -10,10 +10,7 @@ import org.gradle.api.plugins.JavaPluginConvention
|
||||
import org.gradle.api.tasks.SourceSet
|
||||
import org.gradle.api.tasks.SourceSetContainer
|
||||
import org.gradle.api.tasks.SourceSetOutput
|
||||
import org.gradle.kotlin.dsl.creating
|
||||
import org.gradle.kotlin.dsl.extra
|
||||
import org.gradle.kotlin.dsl.registering
|
||||
import org.gradle.kotlin.dsl.the
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import java.io.File
|
||||
import java.util.concurrent.Callable
|
||||
|
||||
@@ -70,3 +67,5 @@ fun Project.getBooleanProperty(name: String): Boolean? = this.findProperty(name)
|
||||
inline fun CopySourceSpec.from(crossinline filesProvider: () -> Any?): CopySourceSpec = from(Callable { filesProvider() })
|
||||
|
||||
fun Project.javaPluginConvention(): JavaPluginConvention = the()
|
||||
|
||||
fun Project.findJavaPluginConvention(): JavaPluginConvention? = convention.findByType() ?: convention.findPlugin()
|
||||
|
||||
@@ -98,7 +98,12 @@ fun Project.sourcesJar(body: Jar.() -> Unit = {}): TaskProvider<Jar> {
|
||||
.resolvedArtifacts
|
||||
.map { it.id.componentIdentifier }
|
||||
.filterIsInstance<ProjectComponentIdentifier>()
|
||||
.map { project(it.projectPath).mainSourceSet.allSource }
|
||||
.mapNotNull {
|
||||
project(it.projectPath)
|
||||
.findJavaPluginConvention()
|
||||
?.mainSourceSet
|
||||
?.allSource
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.plugins.JavaPluginConvention
|
||||
import org.gradle.api.tasks.SourceSet
|
||||
import org.gradle.api.tasks.SourceSetContainer
|
||||
|
||||
@@ -37,7 +38,13 @@ val Project.sourceSets: SourceSetContainer
|
||||
get() = javaPluginConvention().sourceSets
|
||||
|
||||
val Project.mainSourceSet: SourceSet
|
||||
get() = sourceSets.getByName("main")
|
||||
get() = javaPluginConvention().mainSourceSet
|
||||
|
||||
val Project.testSourceSet: SourceSet
|
||||
get() = javaPluginConvention().testSourceSet
|
||||
|
||||
val JavaPluginConvention.mainSourceSet: SourceSet
|
||||
get() = sourceSets.getByName("main")
|
||||
|
||||
val JavaPluginConvention.testSourceSet: SourceSet
|
||||
get() = sourceSets.getByName("test")
|
||||
|
||||
@@ -6,6 +6,8 @@ configure<PublishingExtension> {
|
||||
val artifactName = if (project.name == "idea-plugin") "kotlin-plugin" else project.name
|
||||
artifactId = "$artifactName-${IdeVersionConfigurator.currentIde.name.toLowerCase()}"
|
||||
from(components["java"])
|
||||
artifact(tasks["sourcesJar"])
|
||||
artifact(tasks["javadocJar"])
|
||||
|
||||
pom {
|
||||
name.set("${project.group}:$artifactId")
|
||||
|
||||
@@ -18,4 +18,8 @@ sourceSets {
|
||||
"test" {}
|
||||
}
|
||||
|
||||
sourcesJar()
|
||||
|
||||
javadocJar()
|
||||
|
||||
apply(from = "$rootDir/gradle/kotlinPluginPublication.gradle.kts")
|
||||
|
||||
@@ -20,4 +20,8 @@ sourceSets {
|
||||
|
||||
runtimeJar()
|
||||
|
||||
sourcesJar()
|
||||
|
||||
javadocJar()
|
||||
|
||||
apply(from = "$rootDir/gradle/kotlinPluginPublication.gradle.kts")
|
||||
|
||||
@@ -35,6 +35,10 @@ sourceSets {
|
||||
|
||||
runtimeJar()
|
||||
|
||||
sourcesJar()
|
||||
|
||||
javadocJar()
|
||||
|
||||
testsJar()
|
||||
|
||||
projectTest(parallel = true) {
|
||||
|
||||
@@ -58,6 +58,10 @@ sourceSets {
|
||||
|
||||
runtimeJar()
|
||||
|
||||
sourcesJar()
|
||||
|
||||
javadocJar()
|
||||
|
||||
projectTest(parallel = true)
|
||||
|
||||
apply(from = "$rootDir/gradle/kotlinPluginPublication.gradle.kts")
|
||||
|
||||
@@ -47,6 +47,10 @@ sourceSets {
|
||||
|
||||
runtimeJar()
|
||||
|
||||
sourcesJar()
|
||||
|
||||
javadocJar()
|
||||
|
||||
testsJar()
|
||||
|
||||
projectTest {
|
||||
|
||||
@@ -88,4 +88,8 @@ projectTest(parallel = true) {
|
||||
|
||||
runtimeJar()
|
||||
|
||||
sourcesJar()
|
||||
|
||||
javadocJar()
|
||||
|
||||
apply(from = "$rootDir/gradle/kotlinPluginPublication.gradle.kts")
|
||||
|
||||
@@ -27,4 +27,8 @@ sourceSets {
|
||||
|
||||
runtimeJar()
|
||||
|
||||
sourcesJar()
|
||||
|
||||
javadocJar()
|
||||
|
||||
apply(from = "$rootDir/gradle/kotlinPluginPublication.gradle.kts")
|
||||
|
||||
@@ -37,6 +37,10 @@ sourceSets {
|
||||
|
||||
runtimeJar()
|
||||
|
||||
sourcesJar()
|
||||
|
||||
javadocJar()
|
||||
|
||||
testsJar()
|
||||
|
||||
projectTest(parallel = true) {
|
||||
|
||||
@@ -59,6 +59,10 @@ sourceSets {
|
||||
|
||||
runtimeJar()
|
||||
|
||||
sourcesJar()
|
||||
|
||||
javadocJar()
|
||||
|
||||
projectTest(parallel = true)
|
||||
|
||||
apply(from = "$rootDir/gradle/kotlinPluginPublication.gradle.kts")
|
||||
|
||||
@@ -33,4 +33,8 @@ sourceSets {
|
||||
|
||||
runtimeJar()
|
||||
|
||||
sourcesJar()
|
||||
|
||||
javadocJar()
|
||||
|
||||
apply(from = "$rootDir/gradle/kotlinPluginPublication.gradle.kts")
|
||||
|
||||
@@ -165,6 +165,10 @@ val jar = runtimeJar {
|
||||
archiveFileName.set("kotlin-plugin.jar")
|
||||
}.get() // make it eager to avoid corresponding refactorings in the kotlin-ultimate part for now
|
||||
|
||||
sourcesJar()
|
||||
|
||||
javadocJar()
|
||||
|
||||
val ideaPluginDir: File by rootProject.extra
|
||||
tasks.register<Sync>("ideaPlugin") {
|
||||
dependsOn(":dist")
|
||||
|
||||
Reference in New Issue
Block a user