1/* 2 * Copyright 2017-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. 3 */ 4 5apply plugin: 'kotlin' 6apply plugin: 'java-gradle-plugin' 7 8if (rootProject.ext.jvm_ir_enabled) { 9 kotlin.target.compilations.all { 10 kotlinOptions.useIR = true 11 } 12} 13 14// Gradle plugin must be compiled targeting the same Kotlin version as used by Gradle 15kotlin.sourceSets.all { 16 languageSettings { 17 apiVersion = "1.3" 18 languageVersion = "1.3" 19 } 20} 21 22dependencies { 23 compile gradleApi() 24 compile project(":atomicfu-transformer") 25 compile 'org.jetbrains.kotlin:kotlin-stdlib' 26 27 compileOnly "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 28 29 testCompile gradleTestKit() 30 testCompile 'org.jetbrains.kotlin:kotlin-test' 31 testCompile 'org.jetbrains.kotlin:kotlin-test-junit' 32 testCompile 'junit:junit:4.12' 33} 34 35configurations { 36 testPluginClasspath 37} 38 39dependencies { 40 testPluginClasspath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 41} 42 43evaluationDependsOn(':atomicfu') 44def atomicfu = project(':atomicfu') 45def atomicfuJvmJarTask = atomicfu.tasks.getByName(atomicfu.kotlin.targets.jvm.artifactsTaskName) 46 47def jsLegacy = atomicfu.kotlin.targets.hasProperty("jsLegacy") 48 ? atomicfu.kotlin.targets.jsLegacy 49 : atomicfu.kotlin.targets.js 50def atomicfuJsJarTask = atomicfu.tasks.getByName(jsLegacy.artifactsTaskName) 51 52def atomicfuMetadataOutput = atomicfu.kotlin.targets.metadata.compilations["main"].output.allOutputs 53 54// Write the plugin's classpath to a file to share with the tests 55task createClasspathManifest { 56 dependsOn(atomicfuJvmJarTask) 57 dependsOn(atomicfuJsJarTask) 58 dependsOn(atomicfuMetadataOutput) 59 60 def outputDir = file("$buildDir/$name") 61 outputs.dir outputDir 62 63 doLast { 64 outputDir.mkdirs() 65 file("$outputDir/plugin-classpath.txt").text = (sourceSets.main.runtimeClasspath + configurations.testPluginClasspath).join("\n") 66 file("$outputDir/atomicfu-jvm.txt").text = atomicfuJvmJarTask.archivePath 67 file("$outputDir/atomicfu-js.txt").text = atomicfuJsJarTask.archivePath 68 file("$outputDir/atomicfu-metadata.txt").text = atomicfuMetadataOutput.join("\n") 69 } 70} 71 72// Add the classpath file to the test runtime classpath 73dependencies { 74 testRuntime files(createClasspathManifest) 75} 76