| /* |
| * Copyright 2017-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
| */ |
| |
| apply plugin: 'kotlin' |
| apply plugin: 'java-gradle-plugin' |
| |
| if (rootProject.ext.jvm_ir_enabled) { |
| kotlin.target.compilations.all { |
| kotlinOptions.useIR = true |
| } |
| } |
| |
| // Gradle plugin must be compiled targeting the same Kotlin version as used by Gradle |
| kotlin.sourceSets.all { |
| languageSettings { |
| apiVersion = "1.4" |
| languageVersion = "1.4" |
| } |
| } |
| |
| dependencies { |
| implementation(project(":atomicfu-transformer")) { |
| exclude group: 'org.jetbrains.kotlin', module: 'kotlin-stdlib' |
| } |
| |
| compileOnly gradleApi() |
| compileOnly 'org.jetbrains.kotlin:kotlin-stdlib' |
| compileOnly "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" |
| // atomicfu compiler plugin dependency will be loaded to kotlinCompilerPluginClasspath |
| implementation "org.jetbrains.kotlin:atomicfu:$kotlin_version" |
| |
| testImplementation gradleTestKit() |
| testImplementation 'org.jetbrains.kotlin:kotlin-test' |
| testImplementation 'org.jetbrains.kotlin:kotlin-test-junit' |
| testImplementation 'junit:junit:4.12' |
| } |
| |
| configurations { |
| testPluginClasspath { |
| attributes { |
| attribute( |
| Usage.USAGE_ATTRIBUTE, |
| project.objects.named(Usage.class, Usage.JAVA_RUNTIME) |
| ) |
| attribute( |
| Category.CATEGORY_ATTRIBUTE, |
| project.objects.named(Category.class, Category.LIBRARY) |
| ) |
| } |
| } |
| } |
| |
| dependencies { |
| testPluginClasspath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" |
| } |
| |
| evaluationDependsOn(':atomicfu') |
| def atomicfu = project(':atomicfu') |
| def atomicfuJvmJarTask = atomicfu.tasks.getByName(atomicfu.kotlin.targets.jvm.artifactsTaskName) |
| |
| def jsLegacy = atomicfu.kotlin.targets.hasProperty("jsLegacy") |
| ? atomicfu.kotlin.targets.jsLegacy |
| : atomicfu.kotlin.targets.js |
| def atomicfuJsJarTask = atomicfu.tasks.getByName(jsLegacy.artifactsTaskName) |
| |
| def atomicfuMetadataOutput = atomicfu.kotlin.targets.metadata.compilations["main"].output.allOutputs |
| |
| // Write the plugin's classpath to a file to share with the tests |
| task createClasspathManifest { |
| dependsOn(atomicfuJvmJarTask) |
| dependsOn(atomicfuJsJarTask) |
| dependsOn(atomicfuMetadataOutput) |
| |
| def outputDir = file("$buildDir/$name") |
| outputs.dir outputDir |
| |
| doLast { |
| outputDir.mkdirs() |
| file("$outputDir/plugin-classpath.txt").text = (sourceSets.main.runtimeClasspath + configurations.testPluginClasspath).join("\n") |
| file("$outputDir/atomicfu-jvm.txt").text = atomicfuJvmJarTask.archivePath |
| file("$outputDir/atomicfu-js.txt").text = atomicfuJsJarTask.archivePath |
| file("$outputDir/atomicfu-metadata.txt").text = atomicfuMetadataOutput.join("\n") |
| } |
| } |
| |
| // Add the classpath file to the test runtime classpath |
| dependencies { |
| testRuntime files(createClasspathManifest) |
| } |