From 084e78fb7955ca8dfaa8c9dd259f6212889c1fa4 Mon Sep 17 00:00:00 2001 From: MrTJP Date: Sat, 9 Dec 2023 18:20:36 -0500 Subject: [PATCH] build: create separate api jar --- README.md | 43 ++++++++++++++++--- api/build.gradle | 13 ++++++ .../java/mrtjp/projectred/api/BlockMover.java | 0 .../main/java/mrtjp/projectred/api/Frame.java | 0 .../projectred/api/FrameInteraction.java | 0 .../mrtjp/projectred/api/IBundledEmitter.java | 0 .../mrtjp/projectred/api/IBundledTile.java | 0 .../api/IBundledTileInteraction.java | 0 .../mrtjp/projectred/api/IConnectable.java | 0 .../mrtjp/projectred/api/IExpansionAPI.java | 0 .../projectred/api/IMaskedBundledTile.java | 0 .../mrtjp/projectred/api/IScrewdriver.java | 0 .../projectred/api/ITransmissionAPI.java | 0 .../projectred/api/MovementController.java | 0 .../projectred/api/MovementDescriptor.java | 0 .../api/MovingBlockEntityRenderCallback.java | 0 .../mrtjp/projectred/api/ProjectRedAPI.java | 0 .../mrtjp/projectred/api/package-info.java | 4 +- build.gradle | 1 + core/build.gradle | 3 ++ settings.gradle | 3 ++ 21 files changed, 58 insertions(+), 9 deletions(-) create mode 100644 api/build.gradle rename {core => api}/src/main/java/mrtjp/projectred/api/BlockMover.java (100%) rename {core => api}/src/main/java/mrtjp/projectred/api/Frame.java (100%) rename {core => api}/src/main/java/mrtjp/projectred/api/FrameInteraction.java (100%) rename {core => api}/src/main/java/mrtjp/projectred/api/IBundledEmitter.java (100%) rename {core => api}/src/main/java/mrtjp/projectred/api/IBundledTile.java (100%) rename {core => api}/src/main/java/mrtjp/projectred/api/IBundledTileInteraction.java (100%) rename {core => api}/src/main/java/mrtjp/projectred/api/IConnectable.java (100%) rename {core => api}/src/main/java/mrtjp/projectred/api/IExpansionAPI.java (100%) rename {core => api}/src/main/java/mrtjp/projectred/api/IMaskedBundledTile.java (100%) rename {core => api}/src/main/java/mrtjp/projectred/api/IScrewdriver.java (100%) rename {core => api}/src/main/java/mrtjp/projectred/api/ITransmissionAPI.java (100%) rename {core => api}/src/main/java/mrtjp/projectred/api/MovementController.java (100%) rename {core => api}/src/main/java/mrtjp/projectred/api/MovementDescriptor.java (100%) rename {core => api}/src/main/java/mrtjp/projectred/api/MovingBlockEntityRenderCallback.java (100%) rename {core => api}/src/main/java/mrtjp/projectred/api/ProjectRedAPI.java (100%) rename {core => api}/src/main/java/mrtjp/projectred/api/package-info.java (56%) diff --git a/README.md b/README.md index ef5cc4903..677e74a84 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,13 @@ A Minecraft Forge mod all about Redstone circuity. -| Release Branch | MC Version | Status | -|----------------------|:----------:|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Release Branch | MC Version | Status | +|------------------------|:----------:|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `publish/1.18/release` | 1.18.2 | [![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/MrTJP/3ef501bc64c896a86fd706dfea8ba367/raw/projectred-badge-1.18-release.json)](https://www.curseforge.com/minecraft/mc-mods/project-red-core) | -| `publish/1.18/beta` | 1.18.2 | [![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/MrTJP/3ef501bc64c896a86fd706dfea8ba367/raw/projectred-badge-1.18-beta.json)](https://www.curseforge.com/minecraft/mc-mods/project-red-core) | +| `publish/1.18/beta` | 1.18.2 | [![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/MrTJP/3ef501bc64c896a86fd706dfea8ba367/raw/projectred-badge-1.18-beta.json)](https://www.curseforge.com/minecraft/mc-mods/project-red-core) | | `publish/1.16/release` | 1.16.5 | [![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/MrTJP/3ef501bc64c896a86fd706dfea8ba367/raw/projectred-badge-1.16-release.json)](https://www.curseforge.com/minecraft/mc-mods/project-red-core) | -| `publish/1.16/beta` | 1.16.5 | [![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/MrTJP/3ef501bc64c896a86fd706dfea8ba367/raw/projectred-badge-1.16-beta.json)](https://www.curseforge.com/minecraft/mc-mods/project-red-core) | -| `publish/1.15/beta` | 1.15.2 | [![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/MrTJP/3ef501bc64c896a86fd706dfea8ba367/raw/projectred-badge-1.15-beta.json)](https://www.curseforge.com/minecraft/mc-mods/project-red-core) | +| `publish/1.16/beta` | 1.16.5 | [![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/MrTJP/3ef501bc64c896a86fd706dfea8ba367/raw/projectred-badge-1.16-beta.json)](https://www.curseforge.com/minecraft/mc-mods/project-red-core) | +| `publish/1.15/beta` | 1.15.2 | [![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/MrTJP/3ef501bc64c896a86fd706dfea8ba367/raw/projectred-badge-1.15-beta.json)](https://www.curseforge.com/minecraft/mc-mods/project-red-core) | ## Development Environment Setup @@ -20,7 +20,7 @@ Project Red uses a standard Forge Gradle environment. Setup steps should be the git checkout https://github.com/MrTJP/ProjectRed.git . ``` -2. Build the project: +2. Build the project: ``` ./gradlew build ``` @@ -29,8 +29,37 @@ Project Red uses a standard Forge Gradle environment. Setup steps should be the ``` ./gradlew genIntellijRuns ``` - + 4. Open the project directory in Intellij IDEA and give it a few minutes to set up and index the Gradle project. ### Building Locally + You can re-build jar files locally by running `./gradlew build`. The jars can be found in `.//build/libs`. + +## ProjectRed API + +### Setup +ProjectRed API can be consumed by your ForgeGradle project by adding the following to your `build.gradle`: +```groovy +// Add repository +repositories { + maven { url = "https://proxy-maven.covers1624.net/" } +} + +// Add dependency (replace ${mc_version} and ${pr_version} with the desired versions) +dependencies { + /* minecraft dependency is here */ + + // compile against the API but do not include it at runtime + compileOnly fg.deobf("mrtjp:ProjectRed-${mc_version}:${pr_version}:api") + + // at runtime, use the full mod jars of the required modules + runtimeOnly fg.deobf("mrtjp:ProjectRed-${mc_version}:${pr_version}:core") + runtimeOnly fg.deobf("mrtjp:ProjectRed-${mc_version}:${pr_version}:integration") + runtimeOnly fg.deobf("mrtjp:ProjectRed-${mc_version}:${pr_version}:transmission") + // etc... +} +``` + +### Usage +The primary entrypoint into the API is `mrtjp.projectred.api.ProjectRedAPI` where you will find static fields for each module of ProjectRed. If a module is installed, its corresponding field will be a non-null implementor of that module's API. See the javadocs for more information. \ No newline at end of file diff --git a/api/build.gradle b/api/build.gradle new file mode 100644 index 000000000..4a067626d --- /dev/null +++ b/api/build.gradle @@ -0,0 +1,13 @@ +plugins { + id 'net.minecraftforge.gradle' +} + +minecraft { + mappings channel: mcp_mappings, version: mc_version +// accessTransformer = file("../core/src/main/resources/META-INF/accesstransformer.cfg") +} + +dependencies { + minecraft "net.minecraftforge:forge:${mc_version}-${forge_version}" +} + diff --git a/core/src/main/java/mrtjp/projectred/api/BlockMover.java b/api/src/main/java/mrtjp/projectred/api/BlockMover.java similarity index 100% rename from core/src/main/java/mrtjp/projectred/api/BlockMover.java rename to api/src/main/java/mrtjp/projectred/api/BlockMover.java diff --git a/core/src/main/java/mrtjp/projectred/api/Frame.java b/api/src/main/java/mrtjp/projectred/api/Frame.java similarity index 100% rename from core/src/main/java/mrtjp/projectred/api/Frame.java rename to api/src/main/java/mrtjp/projectred/api/Frame.java diff --git a/core/src/main/java/mrtjp/projectred/api/FrameInteraction.java b/api/src/main/java/mrtjp/projectred/api/FrameInteraction.java similarity index 100% rename from core/src/main/java/mrtjp/projectred/api/FrameInteraction.java rename to api/src/main/java/mrtjp/projectred/api/FrameInteraction.java diff --git a/core/src/main/java/mrtjp/projectred/api/IBundledEmitter.java b/api/src/main/java/mrtjp/projectred/api/IBundledEmitter.java similarity index 100% rename from core/src/main/java/mrtjp/projectred/api/IBundledEmitter.java rename to api/src/main/java/mrtjp/projectred/api/IBundledEmitter.java diff --git a/core/src/main/java/mrtjp/projectred/api/IBundledTile.java b/api/src/main/java/mrtjp/projectred/api/IBundledTile.java similarity index 100% rename from core/src/main/java/mrtjp/projectred/api/IBundledTile.java rename to api/src/main/java/mrtjp/projectred/api/IBundledTile.java diff --git a/core/src/main/java/mrtjp/projectred/api/IBundledTileInteraction.java b/api/src/main/java/mrtjp/projectred/api/IBundledTileInteraction.java similarity index 100% rename from core/src/main/java/mrtjp/projectred/api/IBundledTileInteraction.java rename to api/src/main/java/mrtjp/projectred/api/IBundledTileInteraction.java diff --git a/core/src/main/java/mrtjp/projectred/api/IConnectable.java b/api/src/main/java/mrtjp/projectred/api/IConnectable.java similarity index 100% rename from core/src/main/java/mrtjp/projectred/api/IConnectable.java rename to api/src/main/java/mrtjp/projectred/api/IConnectable.java diff --git a/core/src/main/java/mrtjp/projectred/api/IExpansionAPI.java b/api/src/main/java/mrtjp/projectred/api/IExpansionAPI.java similarity index 100% rename from core/src/main/java/mrtjp/projectred/api/IExpansionAPI.java rename to api/src/main/java/mrtjp/projectred/api/IExpansionAPI.java diff --git a/core/src/main/java/mrtjp/projectred/api/IMaskedBundledTile.java b/api/src/main/java/mrtjp/projectred/api/IMaskedBundledTile.java similarity index 100% rename from core/src/main/java/mrtjp/projectred/api/IMaskedBundledTile.java rename to api/src/main/java/mrtjp/projectred/api/IMaskedBundledTile.java diff --git a/core/src/main/java/mrtjp/projectred/api/IScrewdriver.java b/api/src/main/java/mrtjp/projectred/api/IScrewdriver.java similarity index 100% rename from core/src/main/java/mrtjp/projectred/api/IScrewdriver.java rename to api/src/main/java/mrtjp/projectred/api/IScrewdriver.java diff --git a/core/src/main/java/mrtjp/projectred/api/ITransmissionAPI.java b/api/src/main/java/mrtjp/projectred/api/ITransmissionAPI.java similarity index 100% rename from core/src/main/java/mrtjp/projectred/api/ITransmissionAPI.java rename to api/src/main/java/mrtjp/projectred/api/ITransmissionAPI.java diff --git a/core/src/main/java/mrtjp/projectred/api/MovementController.java b/api/src/main/java/mrtjp/projectred/api/MovementController.java similarity index 100% rename from core/src/main/java/mrtjp/projectred/api/MovementController.java rename to api/src/main/java/mrtjp/projectred/api/MovementController.java diff --git a/core/src/main/java/mrtjp/projectred/api/MovementDescriptor.java b/api/src/main/java/mrtjp/projectred/api/MovementDescriptor.java similarity index 100% rename from core/src/main/java/mrtjp/projectred/api/MovementDescriptor.java rename to api/src/main/java/mrtjp/projectred/api/MovementDescriptor.java diff --git a/core/src/main/java/mrtjp/projectred/api/MovingBlockEntityRenderCallback.java b/api/src/main/java/mrtjp/projectred/api/MovingBlockEntityRenderCallback.java similarity index 100% rename from core/src/main/java/mrtjp/projectred/api/MovingBlockEntityRenderCallback.java rename to api/src/main/java/mrtjp/projectred/api/MovingBlockEntityRenderCallback.java diff --git a/core/src/main/java/mrtjp/projectred/api/ProjectRedAPI.java b/api/src/main/java/mrtjp/projectred/api/ProjectRedAPI.java similarity index 100% rename from core/src/main/java/mrtjp/projectred/api/ProjectRedAPI.java rename to api/src/main/java/mrtjp/projectred/api/ProjectRedAPI.java diff --git a/core/src/main/java/mrtjp/projectred/api/package-info.java b/api/src/main/java/mrtjp/projectred/api/package-info.java similarity index 56% rename from core/src/main/java/mrtjp/projectred/api/package-info.java rename to api/src/main/java/mrtjp/projectred/api/package-info.java index 73c451c2f..d3fd52129 100644 --- a/core/src/main/java/mrtjp/projectred/api/package-info.java +++ b/api/src/main/java/mrtjp/projectred/api/package-info.java @@ -3,7 +3,7 @@ @ParametersAreNonnullByDefault package mrtjp.projectred.api; -import net.covers1624.quack.annotation.FieldsAreNonnullByDefault; -import net.covers1624.quack.annotation.MethodsReturnNonnullByDefault; +import net.minecraft.FieldsAreNonnullByDefault; +import net.minecraft.MethodsReturnNonnullByDefault; import javax.annotation.ParametersAreNonnullByDefault; diff --git a/build.gradle b/build.gradle index c403b7683..b4f3eab2d 100644 --- a/build.gradle +++ b/build.gradle @@ -79,6 +79,7 @@ publishing { } publications { ProjectRed(MavenPublication) { + artifact project(':api').jar artifact project(':core').jar artifact project(':expansion').jar artifact project(':exploration').jar diff --git a/core/build.gradle b/core/build.gradle index da2e324ec..98675d448 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -5,6 +5,9 @@ plugins { String mod_id = 'projectred_core' +// Include all sources from API project +sourceSets.main.java.srcDirs += ['../api/src/main/java'] + minecraft { mappings channel: mcp_mappings, version: mc_version accessTransformer = file("src/main/resources/META-INF/accesstransformer.cfg") diff --git a/settings.gradle b/settings.gradle index 7e20c0c7a..bc5405e50 100644 --- a/settings.gradle +++ b/settings.gradle @@ -18,6 +18,9 @@ pluginManagement { rootProject.name = 'ProjectRed' +// Note: Standalone subproject ('core' subproject directly includes its sources) +include 'api' + include 'core', 'expansion', 'exploration', 'fabrication', 'illumination', 'integration', 'transmission' // Empty module for client/server run configurations