forked from blert-io/plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
96 lines (79 loc) · 2.58 KB
/
build.gradle
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
plugins {
id 'java'
id "com.google.protobuf" version "0.9.4"
}
repositories {
mavenLocal()
maven {
url = 'https://repo.runelite.net'
}
mavenCentral()
}
def runeLiteVersion = 'latest.release'
dependencies {
compileOnly group: 'net.runelite', name: 'client', version: runeLiteVersion
compileOnly 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.30'
implementation 'com.google.protobuf:protobuf-javalite:3.21.12'
implementation 'com.google.code.gson:gson:2.10.1'
testImplementation 'junit:junit:4.12'
testImplementation group: 'net.runelite', name: 'client', version: runeLiteVersion
testImplementation group: 'net.runelite', name: 'jshell', version: runeLiteVersion
}
protobuf {
protoc {
artifact = 'com.google.protobuf:protoc:3.21.12'
}
generateProtoTasks {
all().configureEach { task ->
task.builtins {
java {
option "lite"
}
}
}
}
}
group = 'io.blert'
version = '0.2.1'
def getGitHash = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
}
tasks.register('checkForLocalChanges', Exec) {
commandLine 'git', 'status', '--porcelain'
standardOutput = new ByteArrayOutputStream()
ignoreExitValue = true
doLast {
ext.isClean = standardOutput.toString().trim().isEmpty()
}
}
tasks.register('generateBuildProperties') {
dependsOn checkForLocalChanges
ext.outputDir = "$buildDir/generated/java"
inputs.property('version', version)
outputs.dir outputDir
doLast {
def customHeaders =
System.getenv('BLERT_CUSTOM_HEADERS')?.split(';')?.collect { "\"${it.trim()}\"" }?.join(', ') ?: ""
def rev2 = checkForLocalChanges.isClean ? 0 : 1
mkdir "$outputDir/io/blert"
file("$outputDir/io/blert/BuildProperties.java").text =
"""|package io.blert;
|public class BuildProperties {
| public static final String VERSION = "${version}";
| public static final String REVISION = "${getGitHash()}:${rev2}";
| public static final String[] CUSTOM_HEADERS = new String[]{${customHeaders}};
|}""".stripMargin()
}
}
compileJava.dependsOn generateBuildProperties
sourceSets.main.java.srcDir generateBuildProperties.outputDir
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.release.set(11)
}