Skip to content

Commit

Permalink
Update gradle to publish jars for each subpackage
Browse files Browse the repository at this point in the history
  • Loading branch information
Commoble committed Jan 8, 2022
1 parent 8cdc59c commit 260c7cb
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 13 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ configurations {
}
dependencies {
compile fg.deobf("commoble.databuddy:${databuddy_branch}:${databuddy_version}")
implementation fg.deobf("commoble.databuddy:${databuddy_branch}:${databuddy_version}")
shade fg.deobf("commoble.databuddy:${databuddy_branch}:${databuddy_version}")
// where ${databuddy_branch} is e.g. databuddy-1.17.x
// where ${databuddy_version} is e.g. 2.0.0.1
Expand All @@ -58,6 +58,14 @@ tasks.build.dependsOn reobfShadowJar
jar.finalizedBy('reobfShadowJar')
```

As of 2.1.0.0, databuddy also builds jars from individual packages, which can be used if the entire project is not needed:

```groovy
shade fg.deobf("commoble.databuddy:${databuddy_branch}:${databuddy_version}:config")
```

Valid package artifacts are codec, config, data, datagen, nbt, and plugin.

Alternatively, many of the source classes within are relatively self-contained and can be repackaged into your own sources as-needed; please be considerate and keep the license and copyright notice in any source files you copy into your own projects in this manner.

###### The Example Mod
Expand Down
50 changes: 39 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'java'

version = "${mod_version}"
group = "commoble.${modid}" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
Expand Down Expand Up @@ -87,10 +88,14 @@ test {
useJUnitPlatform()
}

java
{
withSourcesJar()
withJavadocJar()
}

// Example for how to get properties into the manifest for reading by the runtime..
jar {
//from sourceSets.main.output
//from sourceSets.main.allJava
manifest {
attributes([
"Specification-Title": "${modid}",
Expand All @@ -106,19 +111,36 @@ jar {
}
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = "javadoc"
from javadoc.destinationDir
}

task sourcesJar(type: Jar) {
classifier = "sources"
from sourceSets.main.allJava
}
["codec", "config", "data", "datagen", "nbt", "plugin"].forEach(x -> {
tasks.create(name: "${x}Jar", type: Jar) {
classifier = x
from sourceSets.main.output
include "commoble/databuddy/${x}/**"
manifest {
attributes([
"Specification-Title": "${modid}",
"Specification-Vendor": "Commoble",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${project.version}",
"Implementation-Vendor" :"Commoble",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"),
"Maven-Artifact":"${project.group}:${project.archivesBaseName}:${project.version}",
"FMLModType": "GAMELIBRARY"
])
}
}
})

artifacts {
archives javadocJar
archives sourcesJar
archives codecJar
archives configJar
archives dataJar
archives datagenJar
archives nbtJar
archives pluginJar
}

jar.finalizedBy('reobfJar')
Expand All @@ -132,6 +154,12 @@ publishing {
artifact jar
artifact sourcesJar
artifact javadocJar
artifact codecJar
artifact configJar
artifact dataJar
artifact datagenJar
artifact nbtJar
artifact pluginJar
}
}
repositories {
Expand Down
1 change: 0 additions & 1 deletion src/main/java/commoble/databuddy/config/ConfigHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public static <T> T register(
/**
* Define a config value for a complex object.
* @param <T> The type of the thing in the config we are making a listener for
* @param builder the forge config builder
* @param name The name of the field in your config that will hold objects of this type
* @param codec A Codec for de/serializing your object type.
* @param defaultObject The default instance of your config field. The given codec must be able to serialize this;
Expand Down

0 comments on commit 260c7cb

Please sign in to comment.