Skip to content

Commit 03c1b93

Browse files
authored
Add two non-publishable dependency types, update docs (#91)
1 parent 94286b7 commit 03c1b93

File tree

2 files changed

+45
-13
lines changed

2 files changed

+45
-13
lines changed

build.gradle

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,22 @@ configurations {
477477
config.extendsFrom(shadowCompile)
478478
}
479479
}
480+
481+
create("runtimeOnlyNonPublishable") {
482+
description = "Runtime only dependencies that are not published alongside the jar"
483+
canBeConsumed = false
484+
canBeResolved = false
485+
}
486+
create("devOnlyNonPublishable") {
487+
description = "Runtime and compiletime dependencies that are not published alongside the jar (compileOnly + runtimeOnlyNonPublishable)"
488+
canBeConsumed = false
489+
canBeResolved = false
490+
}
491+
492+
compileOnly.extendsFrom(devOnlyNonPublishable)
493+
runtimeOnlyNonPublishable.extendsFrom(devOnlyNonPublishable)
494+
runtimeClasspath.extendsFrom(runtimeOnlyNonPublishable)
495+
testRuntimeClasspath.extendsFrom(runtimeOnlyNonPublishable)
480496
}
481497

482498
String mixinProviderSpec = 'zone.rong:mixinbooter:8.9'
@@ -497,7 +513,7 @@ dependencies {
497513
transitive = false
498514
}
499515
} else if (forceEnableMixins.toBoolean()) {
500-
runtimeOnly(mixinProviderSpec)
516+
runtimeOnlyNonPublishable(mixinProviderSpec)
501517
}
502518

503519
if (enableJUnit.toBoolean()) {

dependencies.gradle

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,41 @@
11
//file:noinspection DependencyNotationArgument
22
// TODO remove when fixed in RFG ^
33
/*
4-
* Add your dependencies here. Common configurations:
5-
* - implementation("group:name:version:classifier"): if you need this for internal implementation details of the mod.
6-
* Available at compiletime and runtime for your environment.
7-
*
8-
* - compileOnlyApi("g:n:v:c"): if you need this for internal implementation details of the mod.
9-
* Available at compiletime but not runtime for your environment.
10-
*
4+
* Add your dependencies here. Supported configurations:
5+
* - api("group:name:version:classifier"): if you use the types from this dependency in the public API of this mod
6+
* Available at runtime and compiletime for mods depending on this mod
7+
* - implementation("g:n:v:c"): if you need this for internal implementation details of the mod, but none of it is visible via the public API
8+
* Available at runtime but not compiletime for mods depending on this mod
9+
* - compileOnly("g:n:v:c"): if the mod you're building doesn't need this dependency during runtime at all, e.g. for optional mods
10+
* Not available at all for mods depending on this mod, only visible at compiletime for this mod
11+
* - compileOnlyApi("g:n:v:c"): like compileOnly, but also visible at compiletime for mods depending on this mod
12+
* Available at compiletime but not runtime for mods depending on this mod
13+
* - runtimeOnlyNonPublishable("g:n:v:c"): if you want to include a mod in this mod's runClient/runServer runs, but not publish it as a dependency
14+
* Not available at all for mods depending on this mod, only visible at runtime for this mod
15+
* - devOnlyNonPublishable("g:n:v:c"): a combination of runtimeOnlyNonPublishable and compileOnly for dependencies present at both compiletime and runtime,
16+
* but not published as Maven dependencies - useful for RFG-deobfuscated dependencies or local testing
17+
* - runtimeOnly("g:n:v:c"): if you don't need this at compile time, but want it to be present at runtime
18+
* Available at runtime for mods depending on this mod
1119
* - annotationProcessor("g:n:v:c"): mostly for java compiler plugins, if you know you need this, use it, otherwise don't worry
20+
* - testCONFIG("g:n:v:c") - replace CONFIG by one of the above (except api), same as above but for the test sources instead of main
21+
*
22+
* - shadowImplementation("g:n:v:c"): effectively the same as API, but the dependency is included in your jar under a renamed package name
23+
* Requires you to enable usesShadowedDependencies in gradle.properties
24+
* For more info, see https://github.com/GregTechCEu/Buildscripts/blob/master/docs/shadow.md
1225
*
13-
* - testCONFIG("g:n:v:c"): replace CONFIG by one of the above, same as above but for the test sources instead of main
26+
* You can exclude transitive dependencies (dependencies of the chosen dependency) by appending { transitive = false } if needed,
27+
* but use this sparingly as it can break using your mod as another mod's dependency if you're not careful.
1428
*
15-
* You can exclude transitive dependencies (dependencies of the chosen dependency) by appending { transitive = false } if needed.
29+
* To depend on obfuscated jars you can use `devOnlyNonPublishable(rfg.deobf("dep:spec:1.2.3"))` to fetch an obfuscated jar from maven,
30+
* or `devOnlyNonPublishable(rfg.deobf(project.files("libs/my-mod-jar.jar")))` to use a file.
1631
*
1732
* To add a mod with CurseMaven, replace '("g:n:v:c")' in the above with 'rfg.deobf("curse.maven:project_slug-project_id:file_id")'
18-
* Example: implementation rfg.deobf("curse.maven:gregtech-ce-unofficial-557242:4527757")
33+
* Example: devOnlyNonPublishable(rfg.deobf("curse.maven:top-245211:2667280"))
1934
*
20-
* To shadow a dependency, use 'shadowImplementation'. For more info, see https://github.com/GregTechCEu/Buildscripts/blob/master/docs/shadow.md
35+
* Gradle names for some of the configuration can be misleading, compileOnlyApi and runtimeOnly both get published as dependencies in Maven, but compileOnly does not.
36+
* The buildscript adds runtimeOnlyNonPublishable to also have a runtime dependency that's not published.
2137
*
22-
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
38+
* For more details, see https://docs.gradle.org/8.4/userguide/java_library_plugin.html#sec:java_library_configurations_graph
2339
*/
2440
dependencies {
2541

0 commit comments

Comments
 (0)