1
- buildscript {
2
- dependencies {
3
- classpath ' org.jdom:jdom2:2.0.6'
4
- classpath ' org.ow2.asm:asm:5.1'
5
- classpath ' org.ow2.asm:asm-commons:5.1'
6
- classpath ' commons-io:commons-io:2.5'
7
- classpath ' org.apache.ant:ant:1.9.7'
8
- classpath ' org.codehaus.plexus:plexus-utils:3.0.24'
9
- classpath ' org.vafer:jdependency:1.1'
10
- classpath files(' gradle/plugins/shadowPlugin.jar' )
11
- }
12
- repositories {
13
- mavenCentral()
14
- }
15
- }
16
-
17
1
plugins {
2
+ id ' com.github.johnrengelman.shadow' version ' 5.0.0'
18
3
id ' java'
19
4
}
20
5
21
6
apply from : ' helper.gradle'
22
- apply plugin : com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
23
7
24
- tasks. withType(AbstractCompile ) {
25
- classpath + = configurations. shadow
26
- }
27
8
28
- tasks. withType(JavaCompile ) {
29
- options. encoding = ' UTF-8'
30
- }
9
+ defaultTasks ' build'
10
+
31
11
32
12
group ' protocolsupport'
33
13
version ' 1.4.dev'
34
-
35
14
sourceCompatibility = JavaVersion . VERSION_1_8
36
15
37
16
File librariesRuntimeDirectory = new File (" libraries_runtime" )
@@ -76,18 +55,18 @@ repositories {
76
55
dependencies {
77
56
shadow fileTree(dir : librariesRuntimeDirectory, include : ' *.jar' )
78
57
compile fileTree(dir : librariesShadeDirectory, include : ' *.jar' )
79
- compile group : ' org.apache.commons' , name : ' commons-lang3' , version : ' 3.0'
80
- compile group : ' com.nimbusds' , name : ' nimbus-jose-jwt' , version : ' 5.2'
81
- compile group : ' it.unimi.dsi' , name : ' fastutil' , version : ' 8.1.1'
58
+ compile group : ' org.apache.commons' , name : ' commons-lang3' , version : ' 3.8.1'
59
+ compile group : ' it.unimi.dsi' , name : ' fastutil' , version : ' 8.2.2'
82
60
}
83
61
84
- task copyFinalJarToTarget (type : Copy ) {
85
- // JitPack searches for the output jar at the standard Gradle output directory (jar.archivePath)
86
- // By copying it from there to our target destination JitPack can archive it in a Maven repository
87
- from jar. archivePath. getPath()
88
- into ' target'
89
- // remove version suffix
90
- rename (jar. archiveName, jar. baseName + ' .jar' )
62
+ compileJava {
63
+ doFirst {
64
+ classpath - = configurations. shadow
65
+ classpath + = configurations. shadow
66
+ }
67
+
68
+ options. encoding = ' UTF-8'
69
+ options. incremental = false
91
70
}
92
71
93
72
shadowJar {
@@ -98,27 +77,40 @@ shadowJar {
98
77
from sourceSets. main. java. srcDirs
99
78
from ' LICENSE'
100
79
101
-
102
- // remove the -all suffix
103
80
archiveName = jar. archiveName
104
- minimizeJar = true
105
81
106
82
exclude ' META-INF/**'
107
83
relocate ' org.apache' , ' protocolsupport.libs.org.apache'
108
- relocate ' com.nimbusds' , ' protocolsupport.libs.com.nimbusds'
109
- relocate ' org.objectweb' , ' protocolsupport.libs.org.objectweb'
110
- relocate ' net.minidev' , ' protocolsupport.libs.net.minidev'
111
- relocate ' net.jcip' , ' protocolsupport.libs.net.jcip'
112
- relocate ' raknetserver' , ' protocolsupport.libs.raknetserver'
113
- relocate ' udpserversocketchannel' , ' protocolsupport.libs.udpserversocketchannel'
114
84
relocate ' it.unimi.dsi.fastutil' , ' protocolsupport.libs.it.unimi.dsi.fastutil'
85
+
86
+ minimize()
115
87
}
116
88
117
89
90
+ task postprocessFatJar (type : Zip ) {
91
+ File originalJar = new File (shadowJar. destinationDir, shadowJar. archiveName)
92
+
93
+ archiveName = shadowJar. archiveName
94
+
95
+ from(zipTree(originalJar)) {
96
+ exclude ' META-INF/**'
97
+ }
98
+ }
99
+
100
+ task copyFinalJarToTarget (type : DefaultTask ) {doLast{
101
+ java.nio.file.Files . copy(
102
+ postprocessFatJar. archivePath. getAbsoluteFile(). toPath(),
103
+ new File (targetJarDirectory, jar. baseName + ' .jar' ). getAbsoluteFile(). toPath(),
104
+ java.nio.file.StandardCopyOption . REPLACE_EXISTING
105
+ )
106
+ }}
107
+
108
+
118
109
compileJava. dependsOn(clean)
119
110
compileJava. dependsOn(setupFolders)
120
111
compileJava. dependsOn(updateRuntimeLibraries)
121
112
compileJava. dependsOn(updateShadeLibraries)
122
113
jar. enabled = false
123
114
jar. finalizedBy(shadowJar)
124
- shadowJar. finalizedBy(copyFinalJarToTarget)
115
+ shadowJar. finalizedBy(postprocessFatJar)
116
+ postprocessFatJar. finalizedBy(copyFinalJarToTarget)
0 commit comments