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.4" 18 languageVersion = "1.4" 19 } 20} 21 22dependencies { 23 implementation(project(":atomicfu-transformer")) { 24 exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib' 25 } 26 27 compileOnly gradleApi() 28 compileOnly 'org.jetbrains.kotlin:kotlin-stdlib' 29 compileOnly "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 30 // atomicfu compiler plugin dependency will be loaded to kotlinCompilerPluginClasspath 31 implementation "org.jetbrains.kotlin:atomicfu:$kotlin_version" 32 33 testImplementation gradleTestKit() 34 testImplementation 'org.jetbrains.kotlin:kotlin-test' 35 testImplementation 'org.jetbrains.kotlin:kotlin-test-junit' 36 testImplementation 'junit:junit:4.12' 37} 38 39configurations { 40 testPluginClasspath { 41 attributes { 42 attribute( 43 Usage.USAGE_ATTRIBUTE, 44 project.objects.named(Usage.class, Usage.JAVA_RUNTIME) 45 ) 46 attribute( 47 Category.CATEGORY_ATTRIBUTE, 48 project.objects.named(Category.class, Category.LIBRARY) 49 ) 50 } 51 } 52} 53 54dependencies { 55 testPluginClasspath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 56} 57 58evaluationDependsOn(':atomicfu') 59def atomicfu = project(':atomicfu') 60def atomicfuJvmJarTask = atomicfu.tasks.getByName(atomicfu.kotlin.targets.jvm.artifactsTaskName) 61 62def jsLegacy = atomicfu.kotlin.targets.hasProperty("jsLegacy") 63 ? atomicfu.kotlin.targets.jsLegacy 64 : atomicfu.kotlin.targets.js 65def atomicfuJsJarTask = atomicfu.tasks.getByName(jsLegacy.artifactsTaskName) 66 67def atomicfuMetadataOutput = atomicfu.kotlin.targets.metadata.compilations["main"].output.allOutputs 68 69// Write the plugin's classpath to a file to share with the tests 70task createClasspathManifest { 71 dependsOn(atomicfuJvmJarTask) 72 dependsOn(atomicfuJsJarTask) 73 dependsOn(atomicfuMetadataOutput) 74 75 def outputDir = file("$buildDir/$name") 76 outputs.dir outputDir 77 78 doLast { 79 outputDir.mkdirs() 80 file("$outputDir/plugin-classpath.txt").text = (sourceSets.main.runtimeClasspath + configurations.testPluginClasspath).join("\n") 81 file("$outputDir/atomicfu-jvm.txt").text = atomicfuJvmJarTask.archivePath 82 file("$outputDir/atomicfu-js.txt").text = atomicfuJsJarTask.archivePath 83 file("$outputDir/atomicfu-metadata.txt").text = atomicfuMetadataOutput.join("\n") 84 } 85} 86 87// Add the classpath file to the test runtime classpath 88dependencies { 89 testRuntime files(createClasspathManifest) 90} 91