a2370920db
Kotlin-native-shared was copied in a separate repository. This patch removes this subproject from the K/N repo and adds a dependency on an artifact built from this separate repo.
315 lines
12 KiB
Groovy
315 lines
12 KiB
Groovy
/*
|
|
* Copyright 2010-2017 JetBrains s.r.o.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
/**
|
|
* One may use bintrayUser/bintrayKey project properties or BINTRAY_USER/BINTRAY_KEY environment variables to upload
|
|
* built plugin to bintray repository.
|
|
*/
|
|
|
|
buildscript {
|
|
ext.rootBuildDirectory = file('../../')
|
|
|
|
apply from: "$rootBuildDirectory/gradle/loadRootProperties.gradle"
|
|
apply from: "$rootBuildDirectory/gradle/kotlinGradlePlugin.gradle"
|
|
|
|
repositories {
|
|
maven {
|
|
url = 'https://cache-redirector.jetbrains.com/jcenter'
|
|
}
|
|
maven {
|
|
url "https://cache-redirector.jetbrains.com/plugins.gradle.org/m2/"
|
|
}
|
|
jcenter()
|
|
}
|
|
|
|
dependencies {
|
|
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
|
|
classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4'
|
|
classpath "com.gradle.publish:plugin-publish-plugin:0.9.10"
|
|
}
|
|
}
|
|
|
|
apply plugin: 'java-gradle-plugin'
|
|
apply plugin: 'kotlin'
|
|
apply plugin: 'groovy'
|
|
apply plugin: 'maven-publish'
|
|
apply plugin: 'com.jfrog.bintray'
|
|
apply plugin: 'com.github.johnrengelman.shadow'
|
|
apply plugin: "com.gradle.plugin-publish"
|
|
|
|
String determineVersion() {
|
|
// With Gradle 5.1 adding a dependency on the 'shared' build
|
|
// in this buildscript causes an IDE import error.
|
|
// So we are not able to use the KonanVersion API and
|
|
// have to manually construct the version.
|
|
// TODO: Remove this code when 'shared' is built separately (from a separate repo).
|
|
def meta = findProperty('konanMetaVersion') ?: 'dev'
|
|
def overriddenVersion = findProperty('pluginVersionOverride') as String
|
|
|
|
if (overriddenVersion != null && !overriddenVersion.empty) {
|
|
return overriddenVersion
|
|
}
|
|
|
|
def buildNumber = findProperty("build.number")?.tokenize('-')?.get(2)
|
|
def result = "$kotlinVersion-native-$konanVersion-$meta"
|
|
if (buildNumber != null) {
|
|
result += "-$buildNumber"
|
|
}
|
|
return result
|
|
}
|
|
|
|
group = 'org.jetbrains.kotlin'
|
|
version = determineVersion()
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
maven {
|
|
url buildKotlinCompilerRepo
|
|
}
|
|
maven {
|
|
url kotlinCompilerRepo
|
|
}
|
|
maven {
|
|
url sharedRepo
|
|
}
|
|
}
|
|
|
|
configurations {
|
|
bundleDependencies {
|
|
transitive = false
|
|
}
|
|
|
|
implementation.extendsFrom shadow
|
|
compileOnly.extendsFrom bundleDependencies
|
|
testImplementation.extendsFrom bundleDependencies
|
|
}
|
|
|
|
dependencies {
|
|
shadow "org.jetbrains.kotlin:kotlin-stdlib:1.3.0"
|
|
|
|
// Bundle the serialization plugin into the final jar because we shade classes of the kotlin plugin
|
|
// while the serialization one extends them.
|
|
bundleDependencies "org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion"
|
|
bundleDependencies "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
|
|
bundleDependencies "org.jetbrains.kotlin:kotlin-gradle-plugin-api:$kotlinVersion"
|
|
bundleDependencies "org.jetbrains.kotlin:kotlin-native-shared:$sharedVersion"
|
|
bundleDependencies "org.jetbrains.kotlin:kotlin-native-version"
|
|
|
|
testImplementation 'junit:junit:4.12'
|
|
testImplementation "org.jetbrains.kotlin:kotlin-test:$buildKotlinVersion"
|
|
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:$buildKotlinVersion"
|
|
testImplementation "org.tools4j:tools4j-spockito:1.6"
|
|
testImplementation('org.spockframework:spock-core:1.1-groovy-2.4') {
|
|
exclude module: 'groovy-all'
|
|
}
|
|
}
|
|
|
|
shadowJar {
|
|
from sourceSets.main.output
|
|
configurations = [project.configurations.bundleDependencies]
|
|
classifier = null
|
|
relocate('org.jetbrains.kotlinx', 'shadow.org.jetbrains.kotlinx')
|
|
relocate('org.jetbrains.kotlin.compilerRunner', 'shadow.org.jetbrains.kotlin.compilerRunner')
|
|
relocate('org.jetbrains.kotlin.konan', 'shadow.org.jetbrains.kotlin.konan')
|
|
relocate('org.jetbrains.kotlin.gradle', 'shadow.org.jetbrains.kotlin.gradle') {
|
|
exclude('org.jetbrains.kotlin.gradle.plugin.experimental.**')
|
|
exclude('org.jetbrains.kotlin.gradle.plugin.konan.**')
|
|
exclude('org.jetbrains.kotlin.gradle.plugin.model.**')
|
|
}
|
|
|
|
exclude {
|
|
def path = it.relativePath.pathString
|
|
if (path.startsWith("META-INF/gradle-plugins") && path.endsWith(".properties")) {
|
|
def fileName = it.name
|
|
def id = fileName.take(fileName.lastIndexOf('.'))
|
|
return project.gradlePlugin.plugins.findByName(id) == null
|
|
}
|
|
return false
|
|
}
|
|
exclude('META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar')
|
|
exclude('META-INF/services/org.jetbrains.kotlin.gradle.plugin.KotlinGradleSubplugin')
|
|
}
|
|
|
|
jar {
|
|
dependsOn shadowJar
|
|
enabled = false
|
|
}
|
|
|
|
pluginUnderTestMetadata {
|
|
dependsOn shadowJar
|
|
doLast {
|
|
// Since Gradle 4.10 it isn't possible to edit the pluginUnderTest classpath.
|
|
// So we have to manually set the implementation-classpath to get the output fat-jar.
|
|
def pluginMetadata = outputDirectory.get().file(PluginUnderTestMetadata.METADATA_FILE_NAME).getAsFile()
|
|
def classpath = files(shadowJar.archivePath) + configurations.shadow
|
|
new Properties().with { properties ->
|
|
pluginMetadata.withInputStream {
|
|
properties.load(it)
|
|
}
|
|
properties.setProperty(PluginUnderTestMetadata.IMPLEMENTATION_CLASSPATH_PROP_KEY , classpath.asPath)
|
|
pluginMetadata.withOutputStream {
|
|
properties.store(it, null)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
test {
|
|
dependsOn shadowJar
|
|
systemProperty("kotlin.version", kotlinVersion)
|
|
systemProperty("kotlin.repo", kotlinCompilerRepo)
|
|
if (project.hasProperty("konan.home")) {
|
|
systemProperty("konan.home", project.property("konan.home"))
|
|
systemProperty("org.jetbrains.kotlin.native.home", project.property("konan.home"))
|
|
} else if (project.hasProperty("org.jetbrains.kotlin.native.home")) {
|
|
systemProperty("org.jetbrains.kotlin.native.home", project.property("org.jetbrains.kotlin.native.home"))
|
|
} else {
|
|
// The Koltin/Native compiler must be built before test execution.
|
|
systemProperty("konan.home", distDir.absolutePath)
|
|
systemProperty("org.jetbrains.kotlin.native.home", distDir.absolutePath)
|
|
}
|
|
if (project.hasProperty("konan.jvmArgs")) {
|
|
systemProperty("konan.jvmArgs", project.property("konan.jvmArgs"))
|
|
}
|
|
// Uncomment for debugging.
|
|
//testLogging.showStandardStreams = true
|
|
if (project.hasProperty("maxParallelForks")) {
|
|
maxParallelForks=project.property("maxParallelForks")
|
|
}
|
|
if (project.hasProperty("filter")) {
|
|
filter.includeTestsMatching project.property("filter")
|
|
}
|
|
if (project.hasProperty("gradleVersion")) {
|
|
systemProperty("gradleVersion", project.property("gradleVersion"))
|
|
}
|
|
}
|
|
|
|
processResources {
|
|
from(file("$rootBuildDirectory/utilities/env_blacklist"))
|
|
}
|
|
|
|
compileTestGroovy.dependsOn.remove('compileTestJava')
|
|
compileTestKotlin.dependsOn compileTestGroovy
|
|
compileTestKotlin.classpath += files(compileTestGroovy.destinationDir)
|
|
|
|
publishing {
|
|
publications {
|
|
gradlePlugin(MavenPublication) { publication ->
|
|
project.shadow.component(publication)
|
|
}
|
|
}
|
|
}
|
|
|
|
bintray {
|
|
user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER')
|
|
key = project.hasProperty('bintrayKey') ? project.property('bintrayKey') : System.getenv('BINTRAY_KEY')
|
|
pkg {
|
|
repo = 'kotlin-native-dependencies'
|
|
name = 'kotlin-native-gradle-plugin'
|
|
userOrg = 'jetbrains'
|
|
licenses = ['Apache-2.0']
|
|
vcsUrl = 'https://github.com/JetBrains/kotlin-native'
|
|
version {
|
|
name = project.version
|
|
desc = "Kotlin Native Gradle plugin $konanVersion"
|
|
}
|
|
publish = project.findProperty("bintrayPublish").toString().toBoolean()
|
|
override = project.findProperty("bintrayOverride").toString().toBoolean()
|
|
}
|
|
publications = ['gradlePlugin']
|
|
}
|
|
|
|
gradlePlugin {
|
|
plugins {
|
|
create('konan') {
|
|
id = 'konan'
|
|
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.konan.KonanPlugin'
|
|
}
|
|
create('kotlin-native') {
|
|
id = 'kotlin-native'
|
|
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.experimental.plugins.KotlinNativePlugin'
|
|
}
|
|
create('kotlin-platform-native') {
|
|
id = 'kotlin-platform-native'
|
|
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.experimental.plugins.KotlinPlatformNativePlugin'
|
|
}
|
|
// We bundle a shaded version of kotlinx-serialization plugin
|
|
create('kotlinx-serialization-native') {
|
|
id = 'kotlinx-serialization-native'
|
|
implementationClass = 'shadow.org.jetbrains.kotlinx.serialization.gradle.SerializationGradleSubplugin'
|
|
}
|
|
|
|
create('org.jetbrains.kotlin.konan') {
|
|
id = 'org.jetbrains.kotlin.konan'
|
|
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.konan.KonanPlugin'
|
|
}
|
|
create('org.jetbrains.kotlin.native') {
|
|
id = 'org.jetbrains.kotlin.native'
|
|
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.experimental.plugins.KotlinNativePlugin'
|
|
}
|
|
create('org.jetbrains.kotlin.platform.native') {
|
|
id = 'org.jetbrains.kotlin.platform.native'
|
|
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()
|
|
}
|
|
}
|
|
}
|