aboutsummaryrefslogtreecommitdiff
path: root/build-logic/src/main/kotlin/org/jetbrains/conventions/base-java.gradle.kts
blob: 0dbac364c6ccbeb1262a80128409dff6224b7a9c (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
package org.jetbrains.conventions

/**
 * Base configuration for Java projects.
 *
 * This convention plugin contains shared Java config for both the [KotlinJvmPlugin] convention plugin and
 * the Gradle Plugin subproject (which cannot have the `kotlin("jvm")` plugin applied).
 */

plugins {
    id("org.jetbrains.conventions.base")
    java
}

java {
    toolchain {
        languageVersion.set(dokkaBuild.mainJavaVersion)
    }
}

java {
    withSourcesJar()
}

tasks.withType<Test>().configureEach {
    useJUnitPlatform()

    javaLauncher.set(javaToolchains.launcherFor {
        languageVersion.set(dokkaBuild.testJavaLauncherVersion)
    })
}

dependencies {
    testImplementation(platform("org.junit:junit-bom:5.9.2"))
    // TODO Upgrade all subprojects to use JUnit Jupiter https://github.com/Kotlin/dokka/issues/2924
    //      Replace these dependencies with `testImplementation("org.junit.jupiter:junit-jupiter:5.9.2")`
    //      See https://junit.org/junit5/docs/current/user-guide/#running-tests-build-gradle-engines-configure
    // Ideally convention plugins should only provide sensible defaults that can be overridden by subprojects.
    // If a convention plugin defines dependencies, these cannot be easily overridden by subprojects, and so
    // this should be avoided. However, for now , both JUnit 4 and 5 must be supported, and since these are test
    // runtime-only dependencies they are not going to have a significant impact subprojects.
    // These dependencies should be revisited in #2924, and (for example) moved to each subproject (which is more
    // repetitive, but more declarative and clear), or some other solution.
    testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
    testRuntimeOnly("org.junit.vintage:junit-vintage-engine")
    // kotlin-test asserts for all projects
    testImplementation(kotlin("test-junit"))
}