Skip to content
This repository was archived by the owner on Jun 11, 2026. It is now read-only.

Commit 6572828

Browse files
committed
improve simplifyArtifact tasks
1 parent e89174d commit 6572828

8 files changed

Lines changed: 102 additions & 25 deletions

File tree

.github/workflows/release-artifacts.yml

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,60 @@ jobs:
2525
with:
2626
java-version: '17'
2727

28-
# api artifact
29-
- name: Build API Artifact
30-
run: ./gradlew :api:simplifyArtifact
28+
- name: Build Artifacts
29+
run: ./gradlew simplifyArtifact
30+
3131
- name: Upload API JAR to Release
3232
id: upload-api-assets
3333
uses: actions/upload-release-asset@v1
3434
with:
3535
upload_url: ${{ github.event.release.upload_url }}
36-
asset_path: api/build/libs/mcsd-api.jar
37-
asset_name: "mcsd-api-${{ github.event.release.tag_name }}.zip"
36+
asset_path: build/libs/mcsd-api.jar
37+
asset_name: "mcsd-api-${{ github.event.release.tag_name }}.jar"
38+
asset_content_type: application/java-archive
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Upload Core JAR to Release
43+
id: upload-api-assets
44+
uses: actions/upload-release-asset@v1
45+
with:
46+
upload_url: ${{ github.event.release.upload_url }}
47+
asset_path: build/libs/mcsd-core.jar
48+
asset_name: "mcsd-core-${{ github.event.release.tag_name }}.jar"
3849
asset_content_type: application/java-archive
3950
env:
4051
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41-
42-
# spigot artifact
43-
- name: Build Spigot Artifact
44-
run: ./gradlew :spigot:testPlugin
52+
4553
- name: Upload Spigot Plugin to Release
4654
id: upload-spigot-assets
4755
uses: actions/upload-release-asset@v1
4856
with:
4957
upload_url: ${{ github.event.release.upload_url }}
50-
asset_path: spigot/run/plugins/mcsd-spigot.jar
51-
asset_name: "mcsd-spigot-${{ github.event.release.tag_name }}.zip"
58+
asset_path: build/libs/mcsd-spigot.jar
59+
asset_name: "mcsd-spigot-${{ github.event.release.tag_name }}.jar"
60+
asset_content_type: application/java-archive
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
64+
- name: Upload Forge Mod to Release
65+
id: upload-forge-assets
66+
uses: actions/upload-release-asset@v1
67+
with:
68+
upload_url: ${{ github.event.release.upload_url }}
69+
asset_path: build/libs/mcsd-forge.jar
70+
asset_name: "mcsd-forge-${{ github.event.release.tag_name }}.jar"
71+
asset_content_type: application/java-archive
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
75+
- name: Upload Fabric Mod to Release
76+
id: upload-fabric-assets
77+
uses: actions/upload-release-asset@v1
78+
with:
79+
upload_url: ${{ github.event.release.upload_url }}
80+
asset_path: build/libs/mcsd-fabric.jar
81+
asset_name: "mcsd-fabric-${{ github.event.release.tag_name }}.jar"
5282
asset_content_type: application/java-archive
5383
env:
5484
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

api/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ dependencies {
4242
}
4343

4444
task simplifyArtifact(type: Copy) {
45+
// api module should be slim, and only contain mcsd's own api
4546
dependsOn jar
4647
from jar.outputs.files.singleFile
47-
into "$buildDir/libs/"
48+
into "$rootDir/build/libs/"
4849
rename { n -> "mcsd-api.jar" }
4950
}

core/build.gradle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
plugins {
22
id 'java-library'
33
id 'org.springframework.boot' version '3.0.+'
4+
id 'com.github.johnrengelman.shadow' version '8.1.1'
45
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
56
}
67

@@ -120,3 +121,18 @@ dependencies {
120121
testImplementation 'org.springframework.security:spring-security-test'
121122
testImplementation 'io.projectreactor:reactor-test'
122123
}
124+
125+
shadowJar {
126+
dependsOn project(':api').simplifyArtifact
127+
128+
configurations.clear()
129+
from sourceSets.main.output
130+
from project(':api').sourceSets.main.output
131+
}
132+
133+
task simplifyArtifact(type: Copy) {
134+
dependsOn shadowJar
135+
from shadowJar.outputs.files.singleFile
136+
into "$rootDir/build/libs/"
137+
rename { n -> "mcsd-core.jar" }
138+
}

fabric/build.gradle

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,15 @@ publishing {
133133

134134
mavenLocal()
135135
}
136-
}
136+
}
137+
138+
shadowJar {
139+
dependsOn project(':api').simplifyArtifact
140+
}
141+
142+
task simplifyArtifact(type: Copy) {
143+
dependsOn remappedShadowJar
144+
from remappedShadowJar.outputs.files.singleFile
145+
into "$rootDir/build/libs/"
146+
rename { n -> "mcsd-fabric.jar" }
147+
}

forge/build.gradle

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
plugins {
2+
id 'com.github.johnrengelman.shadow' version '8.1.1'
3+
id "de.undercouch.download" version "5.5.0"
24
id 'eclipse'
35
id 'idea'
46
id 'maven-publish'
@@ -153,7 +155,7 @@ dependencies {
153155
// http://www.gradle.org/docs/current/userguide/dependency_management.html
154156

155157
// mcsd api
156-
implementation project(':api') // todo: include as jarjar
158+
implementation project(':api')
157159
}
158160

159161
// This block of code expands all declared replace properties in the specified resource targets.
@@ -215,3 +217,14 @@ publishing {
215217
tasks.withType(JavaCompile).configureEach {
216218
options.encoding = 'UTF-8' // Use the UTF-8 charset for Java compilation
217219
}
220+
221+
shadowJar {
222+
dependsOn project(':api').simplifyArtifact
223+
}
224+
225+
task simplifyArtifact(type: Copy) {
226+
dependsOn shadowJar
227+
from shadowJar.outputs.files.singleFile
228+
into "$rootDir/build/libs/"
229+
rename { n -> "mcsd-forge.jar" }
230+
}

spigot/build.gradle

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,24 @@ tasks.register('serverJar', Copy) {
2626
rename { n -> "server.jar" }
2727
}
2828

29+
shadowJar {
30+
dependsOn project(':api').simplifyArtifact
31+
}
32+
2933
tasks.register('testPlugin', Copy) {
3034
dependsOn shadowJar, serverJar
3135
from shadowJar.outputs.files.singleFile
3236
into "${projectDir}/run/plugins"
3337
rename { n -> "mcsd-spigot.jar" }
3438
}
3539

40+
task simplifyArtifact(type: Copy) {
41+
dependsOn shadowJar
42+
from shadowJar.outputs.files.singleFile
43+
into "$rootDir/build/libs/"
44+
rename { n -> "mcsd-spigot.jar" }
45+
}
46+
3647
repositories {
3748
mavenCentral()
3849
maven {

src/forge/main/java/org/comroid/mcsd/forge/Config.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99
import net.minecraftforge.fml.event.config.ModConfigEvent;
1010
import net.minecraftforge.registries.ForgeRegistries;
1111
import org.comroid.api.Polyfill;
12-
import org.comroid.mcsd.api.dto.AgentInfo;
13-
import org.comroid.mcsd.api.dto.PlayerEvent;
14-
import org.comroid.util.REST;
1512

1613
import java.util.List;
1714
import java.util.Set;
@@ -33,7 +30,7 @@ public class Config
3330

3431
static final ForgeConfigSpec SPEC = BUILDER.build();
3532

36-
static AgentInfo info;
33+
//static AgentInfo info;
3734

3835
private static boolean validateItemName(final Object obj)
3936
{
@@ -48,6 +45,6 @@ static void onLoad(final ModConfigEvent event)
4845
var hubBaseUrl=Token.get();
4946
var token=BaseUrl.get();
5047
var baseUrl=HubBaseUrl.get();
51-
info=new AgentInfo(target,agent,hubBaseUrl,token,baseUrl);
48+
//info=new AgentInfo(target,agent,hubBaseUrl,token,baseUrl);
5249
}
5350
}

src/forge/main/java/org/comroid/mcsd/forge/MCSD_Forge.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
import net.minecraftforge.registries.ForgeRegistries;
3232
import net.minecraftforge.registries.RegistryObject;
3333
import org.comroid.api.Polyfill;
34-
import org.comroid.mcsd.api.dto.PlayerEvent;
35-
import org.comroid.util.REST;
3634
import org.slf4j.Logger;
3735

3836
// The value here should match an entry in the META-INF/mods.toml file
@@ -73,10 +71,10 @@ public void onServerStarting(ServerStartingEvent event)
7371

7472
@SubscribeEvent
7573
static void onChat(final ServerChatEvent event) {
76-
REST.put(Config.info.getHubBaseUrl()+"/api/agent/chat"+Config.info.getAgent(),
77-
new PlayerEvent(event.getUsername(), event.getMessage().getString(), PlayerEvent.Type.Chat).json())
78-
.thenApply(REST.Response::validate2xxOK)
79-
.exceptionally(Polyfill.exceptionLogger());
74+
// REST.put(Config.info.getHubBaseUrl()+"/api/agent/chat"+Config.info.getAgent(),
75+
// new PlayerEvent(event.getUsername(), event.getMessage().getString(), PlayerEvent.Type.Chat).json())
76+
// .thenApply(REST.Response::validate2xxOK)
77+
// .exceptionally(Polyfill.exceptionLogger());
8078
}
8179

8280
// You can use EventBusSubscriber to automatically register all static methods in the class annotated with @SubscribeEvent

0 commit comments

Comments
 (0)