aboutsummaryrefslogtreecommitdiff
path: root/atomicfu-gradle-plugin/build.gradle
blob: 531255174b9a69a3dad399813120ff7070795139 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
 * 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)
}