-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
94 lines (80 loc) · 2.45 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
/*
* This file is part of TrollPlus.
* Copyright (C) 2024 Gaming12846
*/
// Apply plugins
plugins {
id 'java'
id 'com.gradleup.shadow' version '8.3.2'
}
// Define project group and version
group = 'de.gaming12846'
version = '1.4.8'
// Configure repositories for dependencies
repositories {
// Use Maven Central repository
mavenCentral()
// Add SpigotMC repository for Spigot API dependencies
maven {
name = 'spigotmc-repo'
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
// Add Sonatype repository for other dependencies
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
}
// Declare project dependencies
dependencies {
// Spigot API dependency
compileOnly 'org.spigotmc:spigot-api:1.21.1-R0.1-SNAPSHOT'
// BStats dependency
implementation 'org.bstats:bstats-bukkit:3.1.0'
// Apache Commons Lang dependency
compileOnly 'org.apache.commons:commons-lang3:3.15.0'
}
// Configure Java version compatibility
def targetJavaVersion = 17
java {
// Set source and target compatibility to the specified Java version
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}
// Configure Java compilation tasks
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}
// Configure the shadow JAR task
tasks.named('shadowJar') {
archiveClassifier.set('shadowJar')
// Relocate package to avoid conflicts, if needed
relocate('org.bstats', 'de.gaming12846.trollplus.metrics')
// Exclude unnecessary META-INF files from the final JAR
exclude 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.MF'
// Define the manifest attributes for the final JAR
manifest {
attributes(
'Implementation-Title': name,
'Implementation-Version': version,
'Main-Class': 'de.gaming12846.trollplus'
)
}
}
// Ensure the shadow JAR is built as part of the 'build' task
tasks.build {
dependsOn tasks.shadowJar
}
// Configure the processResources task
processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}