-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathbuildsc.building.gradle
62 lines (54 loc) · 1.69 KB
/
buildsc.building.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
/*
* Here we can define the "base" name of the exported/built mod jar archive.
* By default, the exported jar file name will have the mod's ID and version.
*/
base
{
archivesName = "${project.mod_id}-${project.mod_version}";
}
/*
* Minecraft 1.20.5 and upwards uses Java 21.
*/
tasks.withType(JavaCompile).configureEach
{
it.options.release = 21;
options.compilerArgs += ['-Xlint:deprecation'];
}
/*
* The 'java' task is responsible for compiling the java code.
*/
java
{
// Loom will automatically attach sourcesJar to a RemapSourcesJar
// task and to the "build" task if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar();
// Generate Java docs.
javadoc.options.addStringOption('Xdoclint:none', '-quiet');
javadoc.options.encoding = 'UTF-8';
withJavadocJar();
sourceCompatibility = JavaVersion.VERSION_21;
targetCompatibility = JavaVersion.VERSION_21;
}
/*
* This function helps the `jar` tasks with file exclusion.
*/
def processJarFile(fileCopyDetails)
{
//obtain the relative file path string
def fileCopyDetails_relPath = fileCopyDetails.relativePath.pathString.replace('\\', '/');
//exclude all `jarjar-excluded` jar files
if(fileCopyDetails_relPath.startsWith("META-INF/jarjar-excluded"))
fileCopyDetails.exclude();
}
/*
* The 'jar' task is responsible for creating the exported/built mod jar archive file.
* It packages your compiled Java code, along with any other resources, into a single JAR file.
*/
jar
{
//iterate all files included in the jar file, and process them
eachFile { fileCopyDetails -> processJarFile(fileCopyDetails) }
//include the license file
from("LICENSE") { rename { fileName -> "LICENSE-${project.mod_id}" } }
}