From 3723ac1e45c62aecd36d29e294b5c58c070b0236 Mon Sep 17 00:00:00 2001 From: YTG123 <54103478+YTG1234@users.noreply.github.com> Date: Tue, 16 Feb 2021 10:58:54 +0200 Subject: [PATCH] Cleaned up guide/export, aliased guide/build to it, and created faq/artifacts --- tags/faq/artifacts.ytag | 23 +++++++++++++++++++++++ tags/guide/build.ytag | 2 ++ tags/guide/export.ytag | 5 ++++- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 tags/faq/artifacts.ytag create mode 100644 tags/guide/build.ytag diff --git a/tags/faq/artifacts.ytag b/tags/faq/artifacts.ytag new file mode 100644 index 0000000..597d7e4 --- /dev/null +++ b/tags/faq/artifacts.ytag @@ -0,0 +1,23 @@ +type: text + +--- + +After compiling and exporting your mod to a JAR archive, you will notice that there are four files inside `build/libs`. + +*Which one to use?* +TL;DR use the one without `-sources` or `-dev` (the shortest one). + +**What do they do?** +Let's walk through the compilation process (when you run the `build` task): +- Firstly, Gradle compiles your mod normally using the `jar` task to produce the `-dev` JAR (Loom changes the `jar` task's classifier to `dev`). +- Secondly, Loom remaps the produced JAR (`-dev`) to the intermediary names (`remapJar` task). These names are used in a production environment (this is the JAR file without a classifier). +- Additionally, Gradle also produces a sources JAR using the `sourcesJar` task (`-sources`). This JAR uses the mappings you configured (the same as your real sources). +- Then, Loom remaps the sources to intermediary (`remapSourcesJar`), changes the original sources JAR name to `-sources-dev`, and produces its own intermediary sources JAR (`-sources`). This uses source code remapping, and as such, won't work with languages other than Java. + +**What does all this mean?** +42, obviously. + +As mentioned earlier, the intermediary names are the names used in a production environment, and as such the classifier-less JAR is the only one that is usable outside a development environment. +When depending on other mods using Gradle, it is still recommended that you download the JAR without a classifier (and not append `:dev`), because the named JAR may use outdated/different mappings than your project. (Same for sources) + +The sources JAR is, of course, unusable and isn't runnable JIT-able code. It should only be used in IDEs. diff --git a/tags/guide/build.ytag b/tags/guide/build.ytag new file mode 100644 index 0000000..82823af --- /dev/null +++ b/tags/guide/build.ytag @@ -0,0 +1,2 @@ +type: alias +target: guide/export diff --git a/tags/guide/export.ytag b/tags/guide/export.ytag index 6036cc1..8cb9e75 100644 --- a/tags/guide/export.ytag +++ b/tags/guide/export.ytag @@ -2,4 +2,7 @@ type: text --- -Exporting your mod as a JAR: run in a terminal from the same directory as the mod project directory `./gradlew build` on GNU/Linux and Mac, or `gradlew build` on Windows. Alternatively, in IntelliJ IDEA, open the Gradle tab on the right and execute `build` under `tasks`. The JARs should appear in `${projectDir}/build/libs`. Use the one with the shortest name outside development. +Exporting your mod as a JAR file: Run in a terminal from the same directory as the mod project directory: +`./gradlew build` on GNU/Linux and macOS, or `gradlew.bat build` on Windows (`.\gradlew.bat build` in PowerShell). +Alternatively, in IntelliJ IDEA, open the Gradle tab on the right and execute `build` under tasks. The JARs should appear in `${projectDir}/build/libs`. +Use the one with the shortest name outside development.