Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up project, rename buildCi to collectBuilds #24

Merged
merged 4 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 9 additions & 13 deletions .github/workflows/report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,16 @@ on:
types: [completed]

permissions:
contents: read
actions: read
checks: write

jobs:
checks:
report:
runs-on: ubuntu-latest
steps:
- name: Download Test Report
uses: dawidd6/action-download-artifact@v2
with:
name: junit-test-results
workflow: ${{ github.event.workflow.id }}
run_id: ${{ github.event.workflow_run.id }}
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3.7.4
with:
commit: ${{github.event.workflow_run.head_sha}}
report_paths: '**/build/test-results/test/TEST-*.xml'
- uses: dorny/test-reporter@v1.9.1
with:
artifact: TestResult
name: Tests
path: '*.xml'
reporter: java-junit
28 changes: 14 additions & 14 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ on:


jobs:
test:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3.3.0
- name: Setup Java JDK
uses: actions/setup-java@v3.10.0
- uses: actions/checkout@v4
- name: Set up JDK 17 for x64
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '17'
distribution: 'temurin'
architecture: x64
- name: Setup Gradle
uses: gradle/gradle-build-action@v2.3.3
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 7.6
- name: Test
run: gradle test
gradle-version: 8.10
- name: Build
run: gradle build
- name: Upload Test Report
uses: actions/upload-artifact@v3
if: always() # always run even if the previous step fails
uses: actions/upload-artifact@v4
if: always()
with:
name: junit-test-results
path: '**/build/test-results/test/TEST-*.xml'
name: TestResult
path: build/test-results/test/*.xml
retention-days: 1
104 changes: 103 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,104 @@
# Discombobulator
A better preprocessor for gradle projects
A java preprocessor gradle plugin for Minecraft mod development.

This project seeks to improve the [ReplayMod preprocessor](https://github.com/ReplayMod/preprocessor) by Johni0702 in several ways

## Comparison
### Syntax
The ReplayMod preprocessor uses the following syntax:
```java
//#if MC>=11200
// This is the block for MC >= 1.12.0
category.addDetail(name, callable::call);
//#else
//$$ // This is the block for MC < 1.12.0
//$$ category.setDetail(name, callable::call);
//#endif
```
While the syntax is powerful, in practice, a lot of it is simply unnecessary and bothersome to write.
We noticed how we *always* use the "greater equals" syntax paired with else.
Furthermore, we dislike the version numbering that was chosen (11200), as it does not support snapshots versions
and when reading it, you always need a second untangle the version in your head, especially with 12001, 11202 or 12101

Hence we simplified the syntax by making it the default operator:
```java
//# 1.12
// This is the block for MC >= 1.12.0
category.addDetail(name, callable::call);
//# def
//$$ // This is the block for MC < 1.12.0
//$$ category.setDetail(name, callable::call);
//# end
```
With `# def` being the default lowest version

### Nesting
```java
//#if MC>=10904
public CPacketResourcePackStatus makeStatusPacket(String hash, Action action) {
//#if MC>=11002
return new CPacketResourcePackStatus(action);
//#else
//$$ return new CPacketResourcePackStatus(hash, action);
//#endif
}
//#else
//$$ public C19PacketResourcePackStatus makeStatusPacket(String hash, Action action) {
//$$ return new C19PacketResourcePackStatus(hash, action);
//$$ }
//#endif
```
Nesting is also supported by adding # to the version:
```java
//# 1.9.4
public CPacketResourcePackStatus makeStatusPacket(String hash, Action action) {
//## 1.10.2
return new CPacketResourcePackStatus(action);
//## def
//$$ return new CPacketResourcePackStatus(hash, action);
//## end
}
//# def
//$$ public C19PacketResourcePackStatus makeStatusPacket(String hash, Action action) {
//$$ return new C19PacketResourcePackStatus(hash, action);
//$$ }
//# end
```
With `## def` being the version of the parent block, in this case 1.9.4

### Patterns
The ReplayMod patterns are quite involved, requiring an annotation and a [class](https://github.com/ReplayMod/ReplayMod/blob/193e51b3c2023e1d8382384aedebb9f046a82436/src/main/java/com/replaymod/core/versions/Patterns.java).
While that may be superior, we opted to apply patterns on a line by line basis:

```java
System.out.println(mc.window); // @GetWindow;
```
Multiple patterns being applied like so:
```java
Minecraft.getMinecraft().setWindow(mc.window); // @GetWindow,GetMinecraft;
```
and all of them being registered in the build.gradle
```groovy
discombobulator {
patterns = [
GetWindow: [
"def": "mc.window",
"1.15.2": "mc.getWindow()"
],
GetMinecraft: [
//etc...
]
]
}
```
### Workflow
When editing code in ReplayMod, you can only edit and run one mod version at a time,
slowing things down considerably.

With Discombobulator, all versions are open at the same time
and you can edit the code in one version, which then gets copied to every other version after saving.

The main src folder is updated as well, which then gets committed via git. No more "switching to the newest version" for committing!

## Setup
More can be found via the [Discombobulator-Template](https://github.com/MinecraftTAS/Discombobulator-Template)
4 changes: 2 additions & 2 deletions Test/Test1.12.2/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.1-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
}

sourceCompatibility = targetCompatibility = 1.8
Expand All @@ -12,5 +12,5 @@ repositories {
dependencies {
minecraft "com.mojang:minecraft:1.12.2"
mappings "net.legacyfabric:yarn:1.12.2+build.mcp"
modImplementation "net.fabricmc:fabric-loader:0.14.11"
modImplementation "net.fabricmc:fabric-loader:0.16.9"
}
4 changes: 2 additions & 2 deletions Test/Test1.14.4/build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
plugins {
id 'fabric-loom' version '1.1-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
}

sourceCompatibility = targetCompatibility = 1.8

dependencies {
minecraft "com.mojang:minecraft:1.14.4"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:0.14.11"
modImplementation "net.fabricmc:fabric-loader:0.16.9"
}
2 changes: 1 addition & 1 deletion Test/build.gradle
ScribbleTAS marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'discombobulator' version '1.2.0'
id 'discombobulator' version '1.2.1'
}

discombobulator {
Expand Down
9 changes: 2 additions & 7 deletions Test/src/main/java/com/minecrafttas/test/Test.java
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
package com.minecrafttas.test;

import net.fabricmc.api.ModInitializer;
//# 1.15.2
//# def
//$$import net.minecraft.client.Minecraft;
//# end
import net.minecraft.client.Minecraft;

public class Test implements ModInitializer {

@Override
public void onInitialize() {
System.out.println("pancake tampered with your game");
// # 1.15.2
//$$ //HELP ME
// # 1.14.4
//$$ Minecraft.getInstance();
// # def
//$$ Minecraft.getMinecraft();
Minecraft.getMinecraft();
// # end
}
}
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
sourceCompatibility = targetCompatibility = 17

// Name, version and group for the project
version = "1.2.1-SNAPSHOT"
version = "1.2.1"
group = "com.minecrafttas"
archivesBaseName = "discombobulator"

Expand All @@ -27,7 +27,7 @@ repositories {
}

dependencies {
testImplementation(platform('org.junit:junit-bom:5.9.1'))
testImplementation(platform('org.junit:junit-bom:5.11.3'))
testImplementation('org.junit.jupiter:junit-jupiter')
}

Expand Down
Loading
Loading