Skip to content

Commit

Permalink
build: create separate api jar
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTJP committed Dec 11, 2023
1 parent e90b746 commit 3d48f16
Show file tree
Hide file tree
Showing 21 changed files with 58 additions and 9 deletions.
43 changes: 36 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
```
Expand All @@ -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 `./<module>/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.
13 changes: 13 additions & 0 deletions api/build.gradle
Original file line number Diff line number Diff line change
@@ -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}"
}

Original file line number Diff line number Diff line change
Expand Up @@ -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;
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ publishing {
}
publications {
ProjectRed(MavenPublication) {
artifact project(':api').jar
artifact project(':core').jar
artifact project(':expansion').jar
artifact project(':exploration').jar
Expand Down
3 changes: 3 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
3 changes: 3 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3d48f16

Please sign in to comment.