Add Gradle plugin marker artifacts for the Gradle plugins.

This allows for the Gradle plugins DSL to resolve the plugins from
a custom repository.
https://docs.gradle.org/current/userguide/plugins.html#sec:plugin_markers
This commit is contained in:
Sergey Igushkin
2017-07-21 15:35:03 +03:00
parent 64eeb479aa
commit 8fd508566a
5 changed files with 69 additions and 2 deletions
@@ -0,0 +1,47 @@
ext.pluginMarkerProject = { String pluginProjectId ->
evaluationDependsOn(":$pluginProjectId")
def pluginProject = findProject(":$pluginProjectId")
repositories.addAll(pluginProject.repositories.toList())
apply plugin: 'java'
dependencies {
compile pluginProject
}
configurations.archives.artifacts.clear()
configurePublishing(project)
task emptyJar(type: Jar)
version = project.version + (findProperty('marker_version_suffix') ?: "")
for (pluginId in pluginProject.pluginBundle.plugins*.id) {
def artifactName = "${pluginId}.gradle.plugin"
artifacts {
['', 'javadoc', 'sources'].forEach { theClassifier ->
archives(emptyJar) {
group = pluginId
name = artifactName
classifier theClassifier
}
}
}
def setUpSeparateArtifact = {
addFilter(pluginId) { artifact, file -> artifact.name == artifactName }
def pom = pom(pluginId)
pom.groupId = pluginId
pom.artifactId = "${pluginId}.gradle.plugin"
}
configure(uploadArchives.repositories.mavenDeployer, setUpSeparateArtifact)
configure(install.repositories.mavenInstaller, setUpSeparateArtifact)
}
publish.dependsOn uploadArchives
}
+13 -2
View File
@@ -4,7 +4,12 @@ include ':kotlin-gradle-plugin-api',
':kotlin-allopen',
':kotlin-noarg',
':kotlin-sam-with-receiver',
':kotlin-gradle-subplugin-example'
':kotlin-gradle-subplugin-example',
// plugin markers:
':kotlin-gradle-plugin:plugin-marker',
':kotlin-allopen:plugin-marker',
':kotlin-noarg:plugin-marker'
project(':kotlin-gradle-plugin-api').projectDir = file("../kotlin-gradle-plugin-api")
project(':kotlin-gradle-plugin').projectDir = file("../kotlin-gradle-plugin")
@@ -12,4 +17,10 @@ project(':kotlin-gradle-plugin-integration-tests').projectDir = file("../kotlin-
project(':kotlin-allopen').projectDir = file("../kotlin-allopen")
project(':kotlin-noarg').projectDir = file("../kotlin-noarg")
project(':kotlin-sam-with-receiver').projectDir = file("../kotlin-sam-with-receiver")
project(':kotlin-gradle-subplugin-example').projectDir = file("../../examples/kotlin-gradle-subplugin-example")
project(':kotlin-gradle-subplugin-example').projectDir = file("../../examples/kotlin-gradle-subplugin-example")
// plugin markers:
project(':kotlin-gradle-plugin:plugin-marker').projectDir = file("../kotlin-gradle-plugin/plugin-marker")
project(':kotlin-allopen:plugin-marker').projectDir = file("../kotlin-allopen/plugin-marker")
project(':kotlin-noarg:plugin-marker').projectDir = file("../kotlin-noarg/plugin-marker")
@@ -0,0 +1,3 @@
apply from: "$rootDir/pluginMarkers.gradle"
pluginMarkerProject('kotlin-allopen')
@@ -0,0 +1,3 @@
apply from: "$rootDir/pluginMarkers.gradle"
pluginMarkerProject('kotlin-gradle-plugin')
@@ -0,0 +1,3 @@
apply from: "$rootDir/pluginMarkers.gradle"
pluginMarkerProject('kotlin-noarg')