-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
140 lines (117 loc) · 3.96 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
140 lines (117 loc) · 3.96 KB
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
import net.ltgt.gradle.errorprone.errorprone
plugins {
alias(libs.plugins.spotless) apply false
alias(libs.plugins.errorprone) apply false
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath(libs.coveralls.plugin)
}
}
val projectVersion = libs.versions.project.get()
val gradleWrapperVersion = "9.1.0"
val catalog = libs
description = "JIP is a code profiling tool much like the hprof tool that ships with the JDK"
subprojects {
apply(plugin = "java")
apply(plugin = "com.diffplug.spotless")
apply(plugin = "net.ltgt.errorprone")
version = projectVersion
repositories {
mavenCentral()
}
dependencies {
"errorprone"(catalog.errorprone.core)
"testRuntimeOnly"(catalog.junit.platform.launcher)
}
configure<com.diffplug.gradle.spotless.SpotlessExtension> {
java {
eclipse()
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
}
}
tasks.withType<Test>().configureEach {
useJUnitPlatform()
onlyIf {
!java.lang.Boolean.getBoolean("skip.tests")
}
}
tasks.withType<JavaCompile>().configureEach {
options.release.set(17)
options.errorprone.disableWarningsInGeneratedCode.set(true)
options.compilerArgs.add("-XDshould-stop.ifError=FLOW")
}
}
tasks.wrapper {
gradleVersion = gradleWrapperVersion
}
project(":example") {
tasks.named<JavaCompile>("compileJava") {
options.errorprone.isEnabled.set(false)
}
val profileRun by tasks.registering(JavaExec::class) {
group = "application"
description = "Runs the demo app with the JIP profiler agent attached."
dependsOn(":jip:jar")
val java = project.extensions.getByType<JavaPluginExtension>()
classpath = java.sourceSets["main"].runtimeClasspath
mainClass.set("demo.DemoApp")
workingDir = projectDir
val agentJar = project(":jip").tasks.named<Jar>("jar").flatMap { it.archiveFile }
val propFile = file("src/main/resources/profile.properties")
doFirst {
file("build/profile-output").mkdirs()
}
jvmArgumentProviders.add(CommandLineArgumentProvider {
listOf(
"-javaagent:${agentJar.get().asFile.absolutePath}",
"-Dprofile.properties=${propFile.absolutePath}"
)
})
}
}
project(":jip") {
val buildViewer by tasks.registering(Exec::class) {
description = "Builds the Preact-based profile viewer into a single HTML file."
workingDir = file("${rootDir}/viewer")
commandLine("npm", "run", "build")
inputs.dir("${rootDir}/viewer/src")
inputs.file("${rootDir}/viewer/package.json")
inputs.file("${rootDir}/viewer/tsconfig.json")
inputs.file("${rootDir}/viewer/vite.config.ts")
outputs.file("${rootDir}/viewer/dist/index.html")
}
val copyViewer by tasks.registering(Copy::class) {
description = "Copies the built viewer to the JIP resources directory."
dependsOn(buildViewer)
from("${rootDir}/viewer/dist/index.html")
into("src/main/resources/su/kidoz/jip/output")
rename("index.html", "profile-viewer.html")
}
tasks.named("processResources") {
dependsOn(copyViewer)
}
tasks.named<Jar>("jar") {
archiveBaseName.set("profile")
manifest {
attributes(
"Premain-Class" to "com.mentorgen.tools.profile.Main",
"Agent-Class" to "com.mentorgen.tools.profile.Main",
"Can-Retransform-Classes" to "true"
)
}
from(java.util.concurrent.Callable {
configurations["runtimeClasspath"].map { if (it.isDirectory) it else zipTree(it) }
})
archiveVersion.set("")
}
dependencies {
"implementation"(catalog.asm)
"testImplementation"(catalog.junit.jupiter)
}
}