200 lines
7.3 KiB
Groovy
200 lines
7.3 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.
|
|
*/
|
|
|
|
import org.jetbrains.kotlin.konan.*
|
|
|
|
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'
|
|
}
|
|
jcenter()
|
|
maven {
|
|
url "https://cache-redirector.jetbrains.com/plugins.gradle.org/m2/"
|
|
}
|
|
gradlePluginPortal()
|
|
}
|
|
|
|
dependencies {
|
|
classpath 'com.github.jengelman.gradle.plugins:shadow:4.0.4'
|
|
classpath "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
|
|
}
|
|
}
|
|
|
|
apply plugin: 'java-gradle-plugin'
|
|
apply plugin: 'kotlin'
|
|
apply plugin: 'groovy'
|
|
apply plugin: 'com.github.johnrengelman.shadow'
|
|
|
|
group = 'org.jetbrains.kotlin'
|
|
version = CompilerVersionGeneratedKt.getCurrentCompilerVersion()
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
configurations {
|
|
bundleDependencies {
|
|
transitive = false
|
|
}
|
|
|
|
implementation.extendsFrom shadow
|
|
compileOnly.extendsFrom bundleDependencies
|
|
testImplementation.extendsFrom bundleDependencies
|
|
}
|
|
|
|
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach {
|
|
kotlinOptions.freeCompilerArgs = ["-Xskip-prerelease-check"]
|
|
}
|
|
|
|
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-utils:$kotlinVersion"
|
|
bundleDependencies "org.jetbrains.kotlin:kotlin-native-shared:$konanVersion"
|
|
bundleDependencies "org.jetbrains.kotlin:kotlin-util-io:$kotlinVersion"
|
|
bundleDependencies "org.jetbrains.kotlin:kotlin-util-klib:$kotlinVersion"
|
|
|
|
testImplementation DependenciesKt.commonDependency(project, "junit")
|
|
testImplementation "org.jetbrains.kotlin:kotlin-test:${project.bootstrapKotlinVersion}"
|
|
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:${project.bootstrapKotlinVersion}"
|
|
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]
|
|
archiveClassifier.set(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", project.bootstrapKotlinRepo)
|
|
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"))
|
|
}
|
|
|
|
tasks.named('compileTestGroovy') {
|
|
classpath = sourceSets.test.compileClasspath
|
|
}
|
|
|
|
tasks.named('compileTestKotlin') {
|
|
classpath += files(sourceSets.test.groovy.classesDirectory)
|
|
}
|
|
|
|
gradlePlugin {
|
|
plugins {
|
|
create('konan') {
|
|
id = 'konan'
|
|
implementationClass = 'org.jetbrains.kotlin.gradle.plugin.konan.KonanPlugin'
|
|
}
|
|
// 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'
|
|
}
|
|
}
|
|
}
|