-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbuild.gradle
163 lines (131 loc) · 4.32 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import java.util.jar.JarFile
plugins {
id 'maven-publish'
id 'java'
id 'idea'
id "com.gradleup.shadow" version "9.0.0-beta4"
}
group = 'net.itsthesky'
// Semantic Versioning
def major = '4'
def minor = '21'
def patch = '1'
def channel = ''
def channelVersion = ''
version = major + '.' + minor + '.' + patch + (channel ? '-' + channel + channelVersion : '')
repositories {
mavenCentral()
mavenLocal()
maven { url = 'https://repo.papermc.io/repository/maven-public/' }
maven { url = 'https://oss.sonatype.org/content/groups/public/' }
maven { url = 'https://jitpack.io' }
maven { url = 'https://maven.enginehub.org/repo/' }
maven { url = 'https://m2.dv8tion.net/releases' }
maven { url = 'https://repo.skriptlang.org/releases' }
}
dependencies {
shadow 'io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT'
shadow 'com.github.SkriptLang:Skript:2.10.0'
// Jetbrains Annotations
shadow 'org.jetbrains:annotations:23.0.0'
// Commits: com.github.dv8fromtheworld:jda
// Stable: net.dv8tion:JDA
implementation 'net.dv8tion:JDA:5.2.2'
// bStats
implementation 'org.bstats:bstats-bukkit:3.0.2'
// Class manipulation
implementation 'net.bytebuddy:byte-buddy:1.11.22'
}
shadowJar {
minimize()
setArchiveFileName('DiSky ' + version + '.jar')
// We currently cannot relocate JDA, as its default package is
// used over modules and more. However, as DiSky should be the only
// plugin using JDA, this should not be a problem.
// relocate('net.dv8tion.jda', 'net.itsthesky.disky.jda')
relocate('org.bstats', 'net.itsthesky.disky.bstats')
}
task removeClassPath {
doLast {
def jarFile = file("${buildDir}/libs/DiSky ${version}.jar")
// Créer un jar temporaire
def tempJar = new File(temporaryDir, "temp.jar")
def manifestFile = new File(temporaryDir, "MANIFEST.MF")
manifestFile.parentFile.mkdirs()
// Lire le manifest existant
def origManifest = new JarFile(jarFile).manifest
// Créer un nouveau manifest sans Class-Path
def newManifest = new StringBuilder()
origManifest.mainAttributes.entrySet().each { entry ->
if (entry.key.toString() != "Class-Path") {
newManifest.append("${entry.key}: ${entry.value}\n")
}
}
manifestFile.text = newManifest.toString()
// Créer le nouveau jar avec le manifest modifié
ant.jar(destfile: tempJar.path, manifest: manifestFile) {
zipfileset(src: jarFile) {
exclude(name: 'META-INF/MANIFEST.MF')
}
}
// Remplacer le jar original
jarFile.delete()
tempJar.renameTo(jarFile)
}
}
shadowJar.finalizedBy removeClassPath
def targetJavaVersion = 17
java {
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
if (JavaVersion.current() < javaVersion) {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
}
}
tasks.withType(JavaCompile).configureEach {
if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
options.release = targetJavaVersion
}
}
processResources {
def props = [version: version]
inputs.properties props
filteringCharset 'UTF-8'
filesMatching('plugin.yml') {
expand props
}
}
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
task sourceJar(type: Jar) {
archiveClassifier.set('sources')
from sourceSets.main.allSource
}
publishing {
publications {
maven(MavenPublication) {
from components.java
artifact(sourceJar)
groupId = 'net.itsthesky'
artifactId = 'DiSky'
version = project.version + '-SNAPSHOT'
}
}
repositories {
maven {
name = 'nexus'
url = "https://gradle.itsthesky.net/repository/DiSky/"
credentials {
username = project.findProperty("nexusUsername") ?: System.getenv("NEXUS_USERNAME")
password = project.findProperty("nexusPassword") ?: System.getenv("NEXUS_PASSWORD")
}
}
}
}
compileJava.options.encoding = 'UTF-8'