-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
104 lines (84 loc) · 2.47 KB
/
build.gradle.kts
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
plugins {
java
application
}
/*
Warning: This Gradle build file only exists to ease the developer experience when opening this project in an IDE. See the
extensive note in the file `settings.gradle.kts` for more information. This Gradle file is not meant to be used as an
example.
This build file will define the subproject `single-file-source/` as a Gradle project so that Intellij will
automatically recognize the source code provide a working "click the green play button to execute the program" experience.
But, importantly, this subproject still works as a standalone project without Gradle.
A good test for validating that this Gradle configuration works is to actually execute the main methods. Try it with:
* `./gradlew single-file-source:run`
A better test is to open this project in Intellij, wait for Intellij to make sense of the project, and then click the
green play buttons in the editor gutter on the "public static void main" method. The program should run.
*/
project("single-file-source") {
apply(plugin = "java")
apply(plugin = "application")
repositories {
mavenCentral()
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
sourceSets {
main {
java {
setSrcDirs(listOf("src"))
}
}
}
application {
mainClass.set("Main")
}
}
/*
The same is true for the 'annotation-processor' subproject.
*/
project("annotation-processor") {
apply(plugin = "java")
apply(plugin = "application")
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
sourceSets {
main {
java {
setSrcDirs(listOf("src", "srcAnnotationProcessor"))
}
}
}
}
/*
The same is true for the 'compiler-plugin' subproject.
*/
project("compiler-plugin") {
apply(plugin = "java")
apply(plugin = "application")
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
sourceSets {
create("example-program") {
java {
setSrcDirs(listOf("example-program/src"))
}
}
create("compiler-plugin") {
java {
setSrcDirs(listOf("compiler-plugin/src"))
}
resources {
setSrcDirs(listOf("compiler-plugin/resources"))
}
}
}
}