Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/build.gradle.kts
blob: c2b69ae8b30c33c60d5efaf82a031d3b39e2c605 (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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
 * SPDX-FileCopyrightText: 2026 Progmasoft <support@progmasoft.com>
 * SPDX-License-Identifier: MPL-2.0 WITH AdditionRef-Progmasoft-Exception-2.0
 */

import org.gradle.api.JavaVersion
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
  kotlin("jvm") version "2.4.0"
  id("com.diffplug.spotless") version "8.9.0"
  application
  jacoco
}

group = "com.progmasoft.tazel"
version = "0.1.0"

repositories {
  mavenCentral()
}

dependencies {
  implementation("com.github.ajalt.mordant:mordant:3.0.1")
  implementation("org.jetbrains.kotlin:kotlin-scripting-common:2.4.0")
  implementation("org.jetbrains.kotlin:kotlin-scripting-jvm:2.4.0")
  implementation("org.jetbrains.kotlin:kotlin-scripting-jvm-host:2.4.0")
  testImplementation(kotlin("test"))
}

kotlin {
  jvmToolchain(25)
  compilerOptions {
    jvmTarget = JvmTarget.JVM_25
    allWarningsAsErrors = true
  }
}

java {
  sourceCompatibility = JavaVersion.VERSION_25
  targetCompatibility = JavaVersion.VERSION_25
}

application {
  mainClass = "com.progmasoft.tazel.cli.MainKt"
  applicationName = "tazel"
  // The embedded Kotlin compiler reaches for sun.misc.Unsafe; without the second flag the JVM
  // prints a warning into the output of every command.
  applicationDefaultJvmArgs =
    listOf("--enable-native-access=ALL-UNNAMED", "--sun-misc-unsafe-memory-access=allow")
}

sourceSets {
  main {
    kotlin.srcDir("sources/main/kotlin")
    resources.srcDir("sources/main/resources")
  }
  test {
    kotlin.srcDir("sources/test/kotlin")
    resources.srcDir("sources/test/resources")
  }
}

spotless {
  kotlin {
    target("sources/**/*.kt", "api/sources/**/*.kt", "gradle-plugin/sources/**/*.kt")
    ktfmt().googleStyle()
    trimTrailingWhitespace()
    endWithNewline()
  }
  kotlinGradle {
    target("*.gradle.kts", "api/*.gradle.kts", "gradle-plugin/*.gradle.kts")
    ktlint()
    trimTrailingWhitespace()
    endWithNewline()
  }
}

// The distribution archives keep no file times and a fixed order, so the same commit packs into
// the same bytes.
tasks.withType<AbstractArchiveTask>().configureEach {
  isPreserveFileTimestamps = false
  isReproducibleFileOrder = true
}

tasks.jar {
  manifest {
    attributes("Implementation-Title" to "Tazel", "Implementation-Version" to project.version)
  }
}

tasks.test {
  useJUnitPlatform()
  maxHeapSize = "512m"
  jvmArgs("--enable-native-access=ALL-UNNAMED", "--sun-misc-unsafe-memory-access=allow")
}

jacoco {
  toolVersion = "0.8.15"
}

tasks.jacocoTestReport {
  dependsOn(tasks.test)
  reports {
    xml.required = true
    html.required = false
  }
}