Skip to content

Commit 252a426

Browse files
committed
Cleanup JarSelector and add additional API to add options.
- This Allows artifacts to specify dependencies that they do not bundle themselves. - Allows platforms such as Forge to ship default options that mods won't have to bundle. - Moves the Function arguments in JarSelector to abstract methods. See #11 and the tests for more information. Make GSON serialize accessible Restructure demo projects to show multiple scenarios.
1 parent 57ff093 commit 252a426

File tree

29 files changed

+810
-323
lines changed

29 files changed

+810
-323
lines changed

build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ subprojects {
4646
((TestingExtension) testing).tap {
4747
suites.named('test', JvmTestSuite) {
4848
useJUnitJupiter(libs.versions.junit)
49+
50+
dependencies {
51+
compileOnly libs.nulls
52+
}
4953

5054
targets.configureEach {
5155
testTask.configure {

jarjar-gradle-demo/build.gradle

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
plugins {
22
id 'java'
3+
id 'eclipse'
34
id 'net.minecraftforge.jarjar'
45
}
56

@@ -11,7 +12,7 @@ repositories {
1112
jarJar.register()
1213

1314
dependencies {
14-
implementation(jarJar(('org.apache.maven:maven-artifact:3.9.11'))) {
15+
implementation(jarJar('org.apache.maven:maven-artifact:3.9.11')) {
1516
transitive = false
1617
// this configures jarjar metadata.
1718
jarJar.configure(it) {
@@ -20,13 +21,36 @@ dependencies {
2021
}
2122
}
2223

23-
jarJar(project('example-project')) {
24+
jarJar(project(':jarjar-example-dep')) {
2425
jarJar.configure(it) {
2526
module {
2627
group = 'me.jonathing'
2728
name = 'example'
2829
}
29-
version = '1.0.0'
30+
version = '1'
3031
}
3132
}
33+
compileOnly project(':jarjar-example-nested-outer') // Force the sub-project to build when I run build, just convenience
34+
compileOnly project(':jarjar-example-mod-outer') // Force the sub-project to build when I run build, just convenience
3235
}
36+
37+
subprojects {
38+
afterEvaluate { child ->
39+
// Make all sub-projects put their jars in the root project folder, easier to locate
40+
tasks.withType(Jar) {
41+
destinationDirectory = rootProject.layout.buildDir.dir('libs')
42+
}
43+
if (tasks.findByName('jarJar')) {
44+
rootProject.tasks.named('jarJar') {
45+
dependsOn(child.tasks.named('jarJar'))
46+
}
47+
}
48+
// Allow for bulk cleaning
49+
tasks.named('clean') {
50+
dependsOn(tasks.named('cleanEclipse'))
51+
}
52+
parent.tasks.named('clean') {
53+
dependsOn(child.tasks.named('clean'))
54+
}
55+
}
56+
}
-1022 Bytes
Binary file not shown.

jarjar-gradle-demo/example-project/build.gradle

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
plugins {
2+
id 'java'
3+
id 'eclipse'
4+
}
5+
6+
group = 'net.minecraftforge'
7+
version = '2.0'
8+
9+
java.toolchain.languageVersion = JavaLanguageVersion.of(9) // 9 so I can make a module-info

jarjar-gradle-demo/example-project/src/main/java/com/example/Example.java renamed to jarjar-gradle-demo/jarjar-example-dep-2/src/main/java/com/example/Example.java

File renamed without changes.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module jarjar.dep {
2+
3+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
plugins {
2+
id 'java'
3+
id 'eclipse'
4+
}
5+
6+
group = 'net.minecraftforge'
7+
version = '1.0'
8+
9+
tasks.named('jar', Jar).configure {
10+
manifest {
11+
attributes('Automatic-Module-Name': 'jarjar.dep')
12+
}
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.example;
2+
3+
public class Example {
4+
public static void main(String[] args) {
5+
System.out.println("Hello World!");
6+
}
7+
}

jarjar-gradle-demo/example-project/src/main/resources/hello.txt renamed to jarjar-gradle-demo/jarjar-example-dep/src/main/resources/hello.txt

File renamed without changes.

0 commit comments

Comments
 (0)