Skip to content

Commit 8ecc63e

Browse files
committed
Use shadow plugin to make shaded JARs
1 parent 39450cd commit 8ecc63e

4 files changed

Lines changed: 29 additions & 25 deletions

File tree

vscode-wpilib/resources/gradle/java/build.gradle

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id "java"
33
id "org.wpilib.GradleRIO" version "###GRADLERIOREPLACE###"
4+
id "com.gradleup.shadow" version "9.3.0"
45
}
56

67
java {
@@ -84,11 +85,11 @@ test {
8485
wpi.sim.addGui().defaultEnabled = true
8586
wpi.sim.addDriverstation()
8687

87-
// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
88-
// in order to make them all available at runtime. Also adding the manifest so WPILib
89-
// knows where to look for our Robot Class.
90-
jar {
91-
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
88+
// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat/shaded jar')
89+
// in order to make them all available at runtime and merging service files to make JSON work.
90+
// Also adding the manifest so WPILib knows where to look for our Robot Class.
91+
shadowJar {
92+
mergeServiceFiles()
9293
from('src') { into 'backup/src' }
9394
from('vendordeps') { into 'backup/vendordeps' }
9495
from('build.gradle') { into 'backup' }
@@ -97,8 +98,8 @@ jar {
9798
}
9899

99100
// Configure jar and deploy tasks
100-
deployArtifact.jarTask = jar
101-
wpi.java.configureExecutableTasks(jar)
101+
deployArtifact.jarTask = shadowJar
102+
wpi.java.configureExecutableTasks(shadowJar)
102103
wpi.java.configureTestTasks(test)
103104

104105
// Configure string concat to always inline compile

vscode-wpilib/resources/gradle/javadt/build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,17 @@ test {
3232
}
3333

3434

35-
// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
36-
// in order to make them all available at runtime. Also adding the manifest so WPILib
37-
// knows where to look for our Robot Class.
38-
jar {
39-
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
35+
// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat/shaded jar')
36+
// in order to make them all available at runtime and merging service files to make JSON work.
37+
// Also adding the manifest so WPILib knows where to look for our Robot Class.
38+
shadowJar {
39+
mergeServiceFiles()
40+
from sourceSets.main.allSource
4041
manifest org.wpilib.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
4142
duplicatesStrategy = DuplicatesStrategy.INCLUDE
4243
}
4344

44-
wpi.java.configureExecutableTasks(jar)
45+
wpi.java.configureExecutableTasks(shadowJar)
4546
wpi.java.configureTestTasks(test)
4647

4748
// Configure string concat to always inline compile

vscode-wpilib/resources/gradle/javaromi/build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,17 @@ wpi.sim.envVar("HALSIMWS_HOST", "10.0.0.2")
4646
wpi.sim.addWebsocketsServer().defaultEnabled = true
4747
wpi.sim.addWebsocketsClient().defaultEnabled = true
4848

49-
// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
50-
// in order to make them all available at runtime. Also adding the manifest so WPILib
51-
// knows where to look for our Robot Class.
52-
jar {
53-
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
49+
// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat/shaded jar')
50+
// in order to make them all available at runtime and merging service files to make JSON work.
51+
// Also adding the manifest so WPILib knows where to look for our Robot Class.
52+
shadowJar {
53+
mergeServiceFiles()
54+
from sourceSets.main.allSource
5455
manifest org.wpilib.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
5556
duplicatesStrategy = DuplicatesStrategy.INCLUDE
5657
}
5758

58-
wpi.java.configureExecutableTasks(jar)
59+
wpi.java.configureExecutableTasks(shadowJar)
5960
wpi.java.configureTestTasks(test)
6061

6162
// Configure string concat to always inline compile

vscode-wpilib/resources/gradle/javaxrp/build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,17 @@ wpi.sim.addDriverstation()
4545
wpi.sim.envVar("HALSIMXRP_HOST", "192.168.42.1")
4646
wpi.sim.addXRPClient().defaultEnabled = true
4747

48-
// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat jar')
49-
// in order to make them all available at runtime. Also adding the manifest so WPILib
50-
// knows where to look for our Robot Class.
51-
jar {
52-
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
48+
// Setting up my Jar File. In this case, adding all libraries into the main jar ('fat/shaded jar')
49+
// in order to make them all available at runtime and merging service files to make JSON work.
50+
// Also adding the manifest so WPILib knows where to look for our Robot Class.
51+
shadowJar {
52+
mergeServiceFiles()
53+
from sourceSets.main.allSource
5354
manifest org.wpilib.gradlerio.GradleRIOPlugin.javaManifest(ROBOT_MAIN_CLASS)
5455
duplicatesStrategy = DuplicatesStrategy.INCLUDE
5556
}
5657

57-
wpi.java.configureExecutableTasks(jar)
58+
wpi.java.configureExecutableTasks(shadowJar)
5859
wpi.java.configureTestTasks(test)
5960

6061
// Configure string concat to always inline compile

0 commit comments

Comments
 (0)