-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
123 lines (108 loc) · 3.54 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
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
import proguard.gradle.ProGuardTask
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.guardsquare:proguard-gradle:7.3.0'
}
}
plugins {
id("java")
id("application")
id 'edu.sc.seis.launch4j' version '3.0.4'
}
application {
mainClassName = 'ru.spike.util.Launcher'
}
project.ext.lwjglVersion = "3.3.2"
version = "1.0" //Product version
dependencies {
["", "-glfw", "-assimp", "-bgfx", "-openal", "-opengl", "-stb", "-vulkan"].each {
implementation "org.lwjgl:lwjgl$it:$lwjglVersion"
if(it != "-vulkan")
implementation "org.lwjgl:lwjgl$it:$lwjglVersion:natives-linux"
if(it != "-vulkan")
implementation "org.lwjgl:lwjgl$it:$lwjglVersion:natives-macos"
if(it != "-vulkan")
implementation "org.lwjgl:lwjgl$it:$lwjglVersion:natives-windows"
}
}
jar {
archiveFileName = project.name + "-" + project.version + "-extLib.jar"
manifest {
attributes(
'Main-Class': project.mainClassName,
'Class-Path': configurations.runtimeClasspath.collect { 'lib/' + it.getName() }.join(' ')
)
}
}
clean {
delete "proguard/mapping.txt", "proguard/dictionary.txt"
}
tasks.register('buildExtLib', Copy) {
dependsOn jar
from configurations.runtimeClasspath
into "${buildDir}/libs/lib/"
}
tasks.register('fatjar', Jar) {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
archiveFileName = project.name + "-" + project.version + "-fat.jar"
manifest {
attributes 'Main-Class': project.mainClassName
}
archiveClassifier = "all"
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
with jar
}
tasks.register('genDict') {
delete "proguard/dictionary.txt"
outputs.file('proguard/dictionary.txt')
doLast {
def r = new Random()
def begin = r.nextInt(1000) + 0x010
def end = begin + 0x40
def chars = (begin..end)
.findAll { Character.isValidCodePoint(it) && Character.isJavaIdentifierPart(it) }
.collect { String.valueOf(Character.toChars(it)) }
int max = chars.size()
def start = []
for (int i = 0; i < max; i++) {
char c = chars.get(i).charAt(0)
if (Character.isJavaIdentifierStart(c)) {
start << String.valueOf(c)
}
}
def f = outputs.files.getSingleFile()
f.getParentFile().mkdirs()
f.withWriter("UTF-8") {
it.write(start.join(System.lineSeparator()))
it.write()
}
}
}
tasks.register('buildObr', ProGuardTask) {
dependsOn buildExtLib, genDict
configuration file('proguard/proguard.pro')
injars(tasks.named('fatjar', Jar))
libraryjars "${System.getProperty('java.home')}/lib/rt.jar"
configurations.runtimeClasspath.files.each {
libraryjars it
}
verbose
outjars(layout.buildDirectory.file("${buildDir}/libs/" + project.name + "-" + project.version + "-" + "obf.jar"))
}
launch4j {
outfile = project.name + "-" + project.version + ".exe"
outputDir = "${buildDir}/libs/"
mainClassName = project.mainClassName
copyConfigurable = []
icon = "${projectDir}/src/main/java/res/app.ico"
version = project.version
textVersion = project.version
copyright = "© SpikeDevelopment"
jreMinVersion = "8"
jarTask = project.tasks.buildObr
}