-
Notifications
You must be signed in to change notification settings - Fork 16
/
build.gradle
120 lines (98 loc) · 3.39 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
plugins {
id 'java'
id 'application'
id "de.undercouch.download" version "4.1.1"
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
archivesBaseName = project.archives_base_name
version = project.version
group = project.maven_group
repositories {
maven {
url "https://maven.fabricmc.net"
}
mavenCentral()
mavenLocal()
}
dependencies {
implementation "org.json:json:20210307"
implementation "com.formdev:flatlaf:1.6.1"
compileOnly "org.lwjgl:lwjgl-tinyfd:3.3.2"
implementation "net.fabricmc:fabric-installer:1.0.1"
}
application {
mainClass.set(project.main_class)
}
class FileOutput extends DefaultTask {
@OutputFile
File output
}
def bootstrapVersion = "0.5.2"
def bootstrapArch = "i686"
task downloadBootstrap(type: Download) {
src "https://maven.fabricmc.net/net/fabricmc/fabric-installer-native-bootstrap/windows-${bootstrapArch}/${bootstrapVersion}/windows-${bootstrapArch}-${bootstrapVersion}.exe"
dest project.buildDir
}
task nativeExe(dependsOn: [downloadBootstrap], type: FileOutput) {
output = file("${projectDir}/build/libs/${archivesBaseName}-${project.version}.exe")
outputs.upToDateWhen { false }
doFirst {
output.delete()
}
doLast {
output.createNewFile()
output.setBytes downloadBootstrap.outputFiles.first().readBytes()
output.append jar.archiveFile.get().getAsFile().readBytes()
}
}
build.dependsOn nativeExe
jar {
// into 'mods', {
// from 'mods'
// }
manifest {
attributes("Main-Class": application.mainClass)
}
duplicatesStrategy = DuplicatesStrategy.WARN
from "LICENSE"
from (configurations.compileClasspath.filter{ it.exists() }.collect { it.isDirectory() ? it : zipTree(it) }) {
exclude 'META-INF/*.SF'
exclude 'META-INF/*.DSA'
exclude 'META-INF/*.RSA'
}
}
sourceSets {
// "header" API stubs for implementing APIs from other mods
// These are not compiled into the resulting JAR file or loaded at runtime,
// they are for compilation purposes only.
//
// Proper implementations of these classes *might* be available at runtime,
// but that is not guaranteed. Generally, we must detect whether they are
// available through mod loading checks (or if a corresponding entrypoint is
// called by Fabric Loader / Quilt Loader / etc).
headers {
java {
compileClasspath += main.compileClasspath
}
}
main {
java {
// headers / API stubs are only available at compilation time.
compileClasspath += headers.output
}
}
}
tasks.withType(JavaCompile).configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
it.options.encoding = "UTF-8"
// JDK 9 introduced a new way of specifying the target java version that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
def targetVersion = 8
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = targetVersion
}
}