[gradle-plugin] Publish the plugin to plugin portal (#1789)
* [gradle-plugin] Publish the plugin to plugin portal * [gradle-plugin] Fix test classpath
This commit is contained in:
+17
-8
@@ -8,8 +8,17 @@ plugins than the old one. The plugin is at an early stage so some things may be
|
|||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
You may use the Gradle plugin to build _Kotlin/Native_ projects. To use it you need to include the following snippet in a build script
|
You may use the Gradle plugin to build _Kotlin/Native_ projects. Since version 0.8 release builds of the plugin are
|
||||||
(see projects in `samples` directory):
|
[available](https://plugins.gradle.org/plugin/org.jetbrains.kotlin.konan) at the Gradle plugin portal so you can apply it
|
||||||
|
using Gradle plugin DSL:
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id "org.jetbrains.kotlin.konan" version "0.8"
|
||||||
|
}
|
||||||
|
|
||||||
|
You also can get the plugin from a Bintray repository. In addition to releases this repo contains old and development
|
||||||
|
versions of the plugin which are not available at the plugin portal. To get the plugin from the Bintray repo, include
|
||||||
|
the following snippet in your build script:
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
@@ -18,22 +27,22 @@ You may use the Gradle plugin to build _Kotlin/Native_ projects. To use it you n
|
|||||||
url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
|
url "https://dl.bintray.com/jetbrains/kotlin-native-dependencies"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:*"
|
classpath "org.jetbrains.kotlin:kotlin-native-gradle-plugin:0.8-dev-*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'konan'
|
apply plugin: 'konan'
|
||||||
|
|
||||||
The Kotlin/Native plugin depends on `org.jetbrains.kotlin:kotlin-gradle-plugin`. So if a build contains both these
|
The Kotlin/Native plugin depends on `org.jetbrains.kotlin:kotlin-gradle-plugin`. So if a build contains both these
|
||||||
plugins as buildscript dependencies, it's recommended to **declare them in the same `build.gradle`** to avoid issues with
|
plugins as buildscript dependencies, it's recommended to **declare them in the same `build.gradle`** to avoid issues with
|
||||||
plugin classpath.
|
plugin classpath.
|
||||||
|
|
||||||
If you already downloaded the compiler manually you may specify the path to its root directory using `konan.home`
|
By default the plugin downloads the Kotlin/Native compiler during the first run. If you already downloaded the compiler
|
||||||
project property (e.g. in `gradle.properties`).
|
manually you may specify the path to its root directory using `konan.home` project property (e.g. in `gradle.properties`).
|
||||||
|
|
||||||
konan.home=/home/user/kotlin-native-0.5
|
konan.home=/home/user/kotlin-native-0.8
|
||||||
|
|
||||||
In this case the compiler will not be downloaded by the plugin.
|
In this case the compiler will not be downloaded by the plugin.
|
||||||
|
|
||||||
|
|||||||
@@ -173,6 +173,10 @@ task gradlePluginCheck() {
|
|||||||
|
|
||||||
task gradlePluginUpload {
|
task gradlePluginUpload {
|
||||||
dependsOn gradle.includedBuild('kotlin-native-gradle-plugin').task(':bintrayUpload')
|
dependsOn gradle.includedBuild('kotlin-native-gradle-plugin').task(':bintrayUpload')
|
||||||
|
// Don't publish dev builds to the plugin portal.
|
||||||
|
if (konanVersionFull.meta != MetaVersion.DEV) {
|
||||||
|
dependsOn gradle.includedBuild('kotlin-native-gradle-plugin').task(':publishPlugins')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task dist_compiler(dependsOn: "distCompiler")
|
task dist_compiler(dependsOn: "distCompiler")
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ buildscript {
|
|||||||
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
|
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id 'com.gradle.plugin-publish' version '0.9.10'
|
||||||
|
}
|
||||||
|
|
||||||
apply plugin: 'java-gradle-plugin'
|
apply plugin: 'java-gradle-plugin'
|
||||||
apply plugin: 'kotlin'
|
apply plugin: 'kotlin'
|
||||||
apply plugin: 'groovy'
|
apply plugin: 'groovy'
|
||||||
@@ -60,20 +65,23 @@ configurations {
|
|||||||
bundleDependencies {
|
bundleDependencies {
|
||||||
transitive = false
|
transitive = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
implementation.extendsFrom shadow
|
||||||
|
compileOnly.extendsFrom bundleDependencies
|
||||||
|
testImplementation.extendsFrom bundleDependencies
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
|
shadow "org.jetbrains.kotlin:kotlin-stdlib:$buildKotlinVersion"
|
||||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$buildKotlinVersion"
|
shadow "org.jetbrains.kotlin:kotlin-gradle-plugin:$buildKotlinVersion"
|
||||||
compile "org.jetbrains.kotlin:kotlin-gradle-plugin:$buildKotlinVersion"
|
|
||||||
|
|
||||||
bundleDependencies "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
|
bundleDependencies "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
|
||||||
|
|
||||||
testCompile 'junit:junit:4.12'
|
testImplementation 'junit:junit:4.12'
|
||||||
testCompile "org.jetbrains.kotlin:kotlin-test:$buildKotlinVersion"
|
testImplementation "org.jetbrains.kotlin:kotlin-test:$buildKotlinVersion"
|
||||||
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$buildKotlinVersion"
|
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$buildKotlinVersion"
|
||||||
testCompile "org.tools4j:tools4j-spockito:1.6"
|
testImplementation "org.tools4j:tools4j-spockito:1.6"
|
||||||
testCompile('org.spockframework:spock-core:1.1-groovy-2.4') {
|
testImplementation('org.spockframework:spock-core:1.1-groovy-2.4') {
|
||||||
exclude module: 'groovy-all'
|
exclude module: 'groovy-all'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -89,6 +97,11 @@ shadowJar {
|
|||||||
|
|
||||||
assemble.dependsOn shadowJar
|
assemble.dependsOn shadowJar
|
||||||
|
|
||||||
|
pluginUnderTestMetadata {
|
||||||
|
dependsOn shadowJar
|
||||||
|
pluginClasspath = files(shadowJar.archivePath) + configurations.shadow
|
||||||
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
systemProperty("kotlin.version", buildKotlinVersion)
|
systemProperty("kotlin.version", buildKotlinVersion)
|
||||||
if (project.hasProperty("konan.home")) {
|
if (project.hasProperty("konan.home")) {
|
||||||
@@ -108,12 +121,9 @@ test {
|
|||||||
if (project.hasProperty("filter")) {
|
if (project.hasProperty("filter")) {
|
||||||
filter.includeTestsMatching project.property("filter")
|
filter.includeTestsMatching project.property("filter")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
// We add konanVersion as a task input to avoid considering this task up-to-date when
|
|
||||||
// konanVersion is actually changed and should be updated in the plugin jar.
|
|
||||||
from(file("$rootBuildDirectory/utilities/env_blacklist"))
|
from(file("$rootBuildDirectory/utilities/env_blacklist"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,24 +131,10 @@ compileTestGroovy.dependsOn.remove('compileTestJava')
|
|||||||
compileTestKotlin.dependsOn compileTestGroovy
|
compileTestKotlin.dependsOn compileTestGroovy
|
||||||
compileTestKotlin.classpath += files(compileTestGroovy.destinationDir)
|
compileTestKotlin.classpath += files(compileTestGroovy.destinationDir)
|
||||||
|
|
||||||
// TODO: Get rid of manual pom generation.
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
gradlePlugin(MavenPublication) {
|
gradlePlugin(MavenPublication) { publication ->
|
||||||
artifact shadowJar
|
project.shadow.component(publication)
|
||||||
pom.withXml { XmlProvider xml ->
|
|
||||||
def deps = xml.asNode().appendNode("dependencies")
|
|
||||||
|
|
||||||
def stdlibDep = deps.appendNode("dependency")
|
|
||||||
stdlibDep.appendNode("groupId", "org.jetbrains.kotlin")
|
|
||||||
stdlibDep.appendNode("artifactId", "kotlin-stdlib")
|
|
||||||
stdlibDep.appendNode("version", "$buildKotlinVersion")
|
|
||||||
|
|
||||||
def kotlinPluginDep = deps.appendNode("dependency")
|
|
||||||
kotlinPluginDep.appendNode("groupId", "org.jetbrains.kotlin")
|
|
||||||
kotlinPluginDep.appendNode("artifactId", "kotlin-gradle-plugin")
|
|
||||||
kotlinPluginDep.appendNode("version", "$buildKotlinVersion")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -164,25 +160,76 @@ bintray {
|
|||||||
|
|
||||||
gradlePlugin {
|
gradlePlugin {
|
||||||
plugins {
|
plugins {
|
||||||
create("konan") {
|
create('konan') {
|
||||||
id = 'konan'
|
id = 'konan'
|
||||||
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.KonanPlugin'
|
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.KonanPlugin'
|
||||||
}
|
}
|
||||||
create("kotlin-native") {
|
create('kotlin-native') {
|
||||||
id = 'kotlin-native'
|
id = 'kotlin-native'
|
||||||
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.experimental.plugins.KotlinNativePlugin'
|
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.experimental.plugins.KotlinNativePlugin'
|
||||||
}
|
}
|
||||||
create("kotlin-platform-native") {
|
create('kotlin-platform-native') {
|
||||||
id = 'kotlin-platform-native'
|
id = 'kotlin-platform-native'
|
||||||
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.experimental.plugins.KotlinPlatformNativePlugin'
|
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.experimental.plugins.KotlinPlatformNativePlugin'
|
||||||
}
|
}
|
||||||
create("org.jetbrains.kotlin.native"){
|
|
||||||
|
create('org.jetbrains.kotlin.konan') {
|
||||||
|
id = 'org.jetbrains.kotlin.konan'
|
||||||
|
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.KonanPlugin'
|
||||||
|
}
|
||||||
|
create('org.jetbrains.kotlin.native') {
|
||||||
id = 'org.jetbrains.kotlin.native'
|
id = 'org.jetbrains.kotlin.native'
|
||||||
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.experimental.plugins.KotlinNativePlugin'
|
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.experimental.plugins.KotlinNativePlugin'
|
||||||
}
|
}
|
||||||
create("org.jetbrains.kotlin.platform.native") {
|
create('org.jetbrains.kotlin.platform.native') {
|
||||||
id = 'org.jetbrains.kotlin.platform.native'
|
id = 'org.jetbrains.kotlin.platform.native'
|
||||||
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.experimental.plugins.KotlinPlatformNativePlugin'
|
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.experimental.plugins.KotlinPlatformNativePlugin'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replace the default output jars with the fat-jar created by the shadowJar task.
|
||||||
|
configurations.archives.artifacts.clear()
|
||||||
|
|
||||||
|
artifacts {
|
||||||
|
archives shadowJar
|
||||||
|
}
|
||||||
|
|
||||||
|
pluginBundle {
|
||||||
|
website = 'https://kotlinlang.org/'
|
||||||
|
vcsUrl = 'https://github.com/JetBrains/kotlin-native'
|
||||||
|
description = 'Kotlin/Native plugins for Gradle'
|
||||||
|
tags = ['kotlin']
|
||||||
|
|
||||||
|
mavenCoordinates {
|
||||||
|
groupId = "org.jetbrains.kotlin"
|
||||||
|
}
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
konan {
|
||||||
|
id = 'org.jetbrains.kotlin.konan'
|
||||||
|
description = displayName = 'Kotlin/Native plugin'
|
||||||
|
}
|
||||||
|
kotlinNative {
|
||||||
|
id = 'org.jetbrains.kotlin.native'
|
||||||
|
displayName = 'Experimental Kotlin/Native plugin'
|
||||||
|
description = """\
|
||||||
|
An experimental Kotlin/Native plugin integrated with Gradle support for native languages and
|
||||||
|
providing a new DSL which is much closer to the DSL of Kotlin/JVM and Kotlin/JS plugins.
|
||||||
|
|
||||||
|
The plugin is intended for projects containing only Kotlin/Native code (without common modules).
|
||||||
|
For multiplatform development see https://plugins.gradle.org/plugin/org.jetbrains.kotlin.platform.native.
|
||||||
|
""".stripIndent()
|
||||||
|
}
|
||||||
|
kotlinPlatformNative {
|
||||||
|
id = 'org.jetbrains.kotlin.platform.native'
|
||||||
|
displayName = 'Experimental Kotlin/Native plugin for multiplatform development'
|
||||||
|
description = """\
|
||||||
|
An experimental Kotlin/Native plugin integrated with Gradle support for native languages and
|
||||||
|
providing a new DSL which is much closer to the DSL of Kotlin/JVM and Kotlin/JS plugins.
|
||||||
|
|
||||||
|
The plugin is intended for native parts of multiplatform projects.
|
||||||
|
""".stripIndent()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user