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")
|
||||
|
||||
Reference in New Issue
Block a user