-
Notifications
You must be signed in to change notification settings - Fork 94
/
build.gradle.kts
137 lines (100 loc) · 3.84 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
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
import configurations.Languages.attachLocalRepositories
import configurations.ProjectVersions.TNOODLE_SYMLINK
import configurations.ProjectVersions.setTNoodleRelease
import crypto.BuildVerification.SIGNATURE_PACKAGE
import crypto.BuildVerification.SIGNATURE_SUFFIX
import crypto.BuildVerification.createBuildSignature
import proguard.gradle.ProGuardTask
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath(libs.proguard.gradle)
classpath(libs.google.appengine.gradle)
classpath(libs.kotlinx.atomicfu.gradle)
}
}
allprojects {
group = "org.worldcubeassociation.tnoodle"
version = "1.2.2"
attachLocalRepositories()
tasks.withType<Jar> {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
}
plugins {
kotlin("jvm") version libs.versions.kotlin apply false
alias(libs.plugins.dependency.versions)
}
val releasePrefix = "TNoodle-WCA"
val releaseProject = "deployable-jar"
tasks.create("registerReleaseTag") {
val signatureProject = project(":server")
val filenameToSign = "rsa/tnoodle_public.pem"
val signatureStorage = signatureProject.file("src/main/resources/$SIGNATURE_PACKAGE/$filenameToSign.$SIGNATURE_SUFFIX")
outputs.file(signatureStorage)
// prevent caching this task, so that it always runs no matter what
outputs.upToDateWhen { false }
doFirst {
val privateKeyPath = project.findProperty("wca.wst.signature-private-key")?.toString()
?: error("You have to provide a path to a PKCS8 private key for official releases!")
val fileToSign = signatureProject.file("src/main/resources/$filenameToSign")
val signature = createBuildSignature(privateKeyPath, fileToSign)
signatureStorage.writeBytes(signature)
setTNoodleRelease(project.ext, releasePrefix)
}
}
tasks.create("registerCloudReleaseTag") {
doFirst {
setTNoodleRelease(project.ext, "TNoodle-CLOUD")
}
}
tasks.create<ProGuardTask>("minifyRelease") {
dependsOn("registerReleaseTag", "buildOfficial")
configuration("proguard-rules.pro")
injars(TNOODLE_SYMLINK)
outjars("$releasePrefix-$version.jar")
if (JavaVersion.current().isJava9Compatible) {
libraryjars("${System.getProperty("java.home")}/jmods")
} else {
libraryjars("${System.getProperty("java.home")}/lib/rt.jar")
libraryjars("${System.getProperty("java.home")}/lib/jce.jar")
}
val targetConfigurations = project(":$releaseProject").configurations
libraryjars(targetConfigurations.findByName("runtimeClasspath")?.files)
printmapping(layout.buildDirectory.file("proguard.map"))
}
tasks.create("buildOfficial") {
description = "Generate an official WCA release artifact."
group = "WCA"
dependsOn("registerReleaseTag", ":$releaseProject:shadowJar")
}
tasks.create<JavaExec>("runOfficial") {
description = "Starts the TNoodle server from an official release artifact. Builds one if necessary."
group = "WCA"
dependsOn("buildOfficial", "minifyRelease")
mainClass.set("-jar")
args = listOf("$releasePrefix-$version.jar")
}
tasks.create("buildDebug") {
description = "Generate an unofficial JAR for testing purposes"
group = "Development"
dependsOn(":$releaseProject:shadowJar")
}
tasks.create("runDebug") {
description = "Run an unofficial JAR for testing purposes"
group = "Development"
dependsOn(":$releaseProject:runShadow")
}
tasks.create("runBackend") {
description = "Run an unofficial JAR that only holds the backend and nothing else. Visiting the localhost website WILL NOT WORK"
group = "Development"
dependsOn(":server:run")
}
tasks.create("installCloud") {
dependsOn("registerCloudReleaseTag", ":cloudscrambles:appengineDeploy")
}
tasks.create("emulateCloud") {
dependsOn("registerCloudReleaseTag", ":cloudscrambles:appengineRun")
}