-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathbuild.gradle
More file actions
182 lines (148 loc) · 4.62 KB
/
build.gradle
File metadata and controls
182 lines (148 loc) · 4.62 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
plugins {
id 'com.gradleup.shadow' version '9.4.1'
id 'edu.sc.seis.launch4j' version '4.0.0'
id 'maven-publish'
id 'application'
id 'java'
}
group = 'net.foulest'
version = '1.4.0'
description = 'RepairKit'
// Set the language level to Java 17
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
repositories {
// Maven central repository
mavenCentral()
mavenLocal()
// Local libraries
flatDir {
dirs 'libs'
}
}
dependencies {
// JNA platform - for registry access
// https://mvnrepository.com/artifact/net.java.dev.jna/jna-platform
implementation 'net.java.dev.jna:jna-platform:5.18.1'
// Google Gson - for JSON serialization and deserialization
// https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation 'com.google.code.gson:gson:2.14.0'
// two-slices - for sending toasts
// https://github.com/sshtools/two-slices
implementation 'com.sshtools:two-slices:0.9.6'
// JetBrains Annotations - for code inspection and documentation
// https://mvnrepository.com/artifact/org.jetbrains/annotations
compileOnly 'org.jetbrains:annotations:26.1.0'
// Lombok - for reducing boilerplate code
// https://projectlombok.org
compileOnly 'org.projectlombok:lombok:1.18.46'
annotationProcessor 'org.projectlombok:lombok:1.18.46'
}
launch4j {
// Executable file information
outfile = "${project.name}-${project.version}.exe"
mainClassName = "${project.group}.repairkit.RepairKit"
icon = "${projectDir}/src/main/resources/icons/RepairKit.ico"
// Java runtime information
// Uses Java 8 as the minimum version; bundled JRE (17) is in the 'jre' directory
jreMinVersion = '1.8.0'
bundledJrePath = 'jre'
initialHeapSize = 128
maxHeapSize = 1024
// Application version information
version = "${project.version}"
textVersion = "${project.version}"
fileDescription = 'RepairKit by Foulest'
copyright = '2026'
productName = "${project.name}"
internalName = "${project.name}"
// Custom manifest file for Windows
manifest = "${projectDir}/RepairKit.manifest"
}
tasks {
shadowJar {
archiveFileName.set("${project.name}-${project.version}.jar")
}
jar {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
archiveFileName.set("${project.name}-${project.version}.jar")
// Set the 'Main-Class' attribute in the JAR manifest
manifest {
attributes 'Main-Class': 'net.foulest.repairkit.RepairKit'
}
}
// Zip the launch4j directory for distribution
tasks.register('zipLaunch4jDir', Zip) {
dependsOn(createExe)
from "${projectDir}/build/launch4j"
archiveFileName = "${project.name}-${project.version}.zip"
destinationDirectory = file("${projectDir}/build")
}
// Create a properties file with the version number
tasks.register('createProperties') {
dependsOn processResources
doLast {
new File("${projectDir}/build/resources/main/version.properties").withWriter { final writer ->
final Properties properties = new Properties()
properties['version'] = project.version.toString()
properties.store writer, null
}
}
}
createExe {
dependsOn(shadowJar)
doLast {
// Copy the JRE to the launch4j directory
copy {
from "${projectDir}/jre"
into "${projectDir}/build/launch4j/jre"
}
// Copy the config folder to the launch4j directory
copy {
from "${projectDir}/src/main/resources/config"
into "${projectDir}/build/launch4j/config"
}
// Delete the lib folder in the launch4j directory
delete "${projectDir}/build/launch4j/lib"
}
finalizedBy(zipLaunch4jDir)
}
compileJava {
dependsOn(clean)
options.encoding = 'UTF-8'
}
classes {
dependsOn createProperties
}
build {
dependsOn(shadowJar)
}
distZip {
dependsOn(shadowJar)
}
distTar {
dependsOn(shadowJar)
}
startScripts {
dependsOn(shadowJar)
}
startShadowScripts {
dependsOn(jar)
}
tasks.register('sourceJar', Jar) {
from sourceSets.main.allJava
}
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId = 'net.foulest.repairkit'
artifactId = project.name
version = project.version
from components.java
}
}
}