aboutsummaryrefslogtreecommitdiff
path: root/build-logic/src/main/kotlin/org/jetbrains/conventions/base-java.gradle.kts
blob: 9270be47db5ca60112a1572c7400551d19996bd2 (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
/*
 * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

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)
    }
    withSourcesJar()
}

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

    maxParallelForks = if (System.getenv("GITHUB_ACTIONS") != null) {
        Runtime.getRuntime().availableProcessors()
    } else {
        (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
    }

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

dependencies {
    testImplementation(platform(libs.junit.bom))
}