Skip to content

Commit

Permalink
wip: Update to latest multiloader, remove common-bridge in favor of s…
Browse files Browse the repository at this point in the history
…ourceset
  • Loading branch information
BlayTheNinth committed May 18, 2024
1 parent db3b4ee commit e889930
Show file tree
Hide file tree
Showing 174 changed files with 254 additions and 192 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
id "com.modrinth.minotaur" version "2.+" apply(false)
}

subprojects {
/*subprojects {
apply plugin: 'java'
java.toolchain.languageVersion = JavaLanguageVersion.of(java_version)
Expand Down Expand Up @@ -86,4 +86,4 @@ subprojects {
tasks.withType(GenerateModuleMetadata).configureEach {
enabled = false
}
}
}*/
3 changes: 3 additions & 0 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
id 'groovy-gradle-plugin'
}
118 changes: 118 additions & 0 deletions buildSrc/src/main/groovy/multiloader-common.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
plugins {
id 'java-library'
id 'maven-publish'
}

base {
archivesName = "${mod_id}-${project.name}-${minecraft_version}"
}

java {
toolchain.languageVersion = JavaLanguageVersion.of(java_version)
withSourcesJar()
withJavadocJar()
}

repositories {
mavenCentral()
// https://docs.gradle.org/current/userguide/declaring_repositories.html#declaring_content_exclusively_found_in_one_repository
exclusiveContent {
forRepository {
maven {
name = 'Sponge'
url = 'https://repo.spongepowered.org/repository/maven-public'
}
}
filter { includeGroupAndSubgroups("org.spongepowered") }
}
maven { url "https://maven.twelveiterations.com/repository/maven-public/" }
}

dependencies {
implementation 'org.jetbrains:annotations:24.1.0'
}

// Declare capabilities on the outgoing configurations.
// Read more about capabilities here: https://docs.gradle.org/current/userguide/component_capabilities.html#sec:declaring-additional-capabilities-for-a-local-component
['apiElements', 'runtimeElements', 'sourcesElements', 'javadocElements'].each { variant ->
configurations."$variant".outgoing {
capability("$group:$mod_id-${project.name}-${minecraft_version}:$version")
capability("$group:$mod_id:$version")
}
publishing.publications.configureEach {
suppressPomMetadataWarningsFor(variant)
}
}

sourcesJar {
from(rootProject.file("LICENSE")) {
rename { "${it}_${mod_name}" }
}
}

jar {
from(rootProject.file("LICENSE")) {
rename { "${it}_${mod_name}" }
}

manifest {
attributes([
'Specification-Title' : mod_name,
'Specification-Vendor' : mod_author,
'Specification-Version' : project.jar.archiveVersion,
'Implementation-Title' : project.name,
'Implementation-Version': project.jar.archiveVersion,
'Implementation-Vendor' : mod_author,
'Built-On-Minecraft' : minecraft_version
])
}
}

processResources {
def expandProps = [
"version": version,
"group": project.group, //Else we target the task's group.
"minecraft_version": minecraft_version,
"forge_version": forge_version,
"forge_loader_version_range": forge_loader_version_range,
"forge_version_range": forge_version_range,
"minecraft_version_range": minecraft_version_range,
"fabric_version": fabric_version,
"fabric_loader_version": fabric_loader_version,
"mod_name": mod_name,
"mod_author": mod_author,
"mod_id": mod_id,
"license": license,
"description": project.description,
"neoforge_version": neoforge_version,
"neoforge_version_range": neoforge_version_range,
"neoforge_loader_version_range": neoforge_loader_version_range,
"credits": credits,
"java_version": java_version,
"pack_format_number": pack_format_number
]

filesMatching(['pack.mcmeta', 'fabric.mod.json', 'META-INF/mods.toml', 'META-INF/neoforge.mods.toml', '*.mixins.json']) {
expand expandProps
}
inputs.properties(expandProps)
}

publishing {
publications {
register('mavenJava', MavenPublication) {
version = project.version + (!project.version.endsWith("SNAPSHOT") ? "+" + minecraft_version : "")
artifactId base.archivesName.get()
from components.java
}
}
repositories {
maven {
var releasesRepoUrl = "https://maven.twelveiterations.com/repository/maven-releases/"
var snapshotsRepoUrl = "https://maven.twelveiterations.com/repository/maven-snapshots/"
url = uri(version.toString().endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl)
name = "twelveIterationsNexus"
credentials(PasswordCredentials)
}
}
}
44 changes: 44 additions & 0 deletions buildSrc/src/main/groovy/multiloader-loader.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
plugins {
id 'multiloader-common'
}

configurations {
commonJava {
canBeResolved = true
}
commonResources {
canBeResolved = true
}
}

dependencies {
compileOnly(project(':common')) {
capabilities {
requireCapability "$group:$mod_id"
}
}
commonJava project(path: ':common', configuration: 'commonJava')
commonResources project(path: ':common', configuration: 'commonResources')
}

tasks.named('compileJava', JavaCompile) {
dependsOn(configurations.commonJava)
source(configurations.commonJava)
}

processResources {
dependsOn(configurations.commonResources)
from(configurations.commonResources)
}

tasks.named('javadoc', Javadoc).configure {
dependsOn(configurations.commonJava)
source(configurations.commonJava)
}

tasks.named("sourcesJar", Jar) {
dependsOn(configurations.commonJava)
from(configurations.commonJava)
dependsOn(configurations.commonResources)
from(configurations.commonResources)
}
38 changes: 28 additions & 10 deletions shared/build.gradle → common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
plugins {
id 'idea'
id 'java'
id 'maven-publish'
id 'multiloader-common'
id 'org.spongepowered.gradle.vanilla' version '0.2.1-SNAPSHOT'
}

Expand All @@ -11,24 +9,36 @@ base {

minecraft {
version(minecraft_version)
if(file("src/main/resources/${mod_id}.accesswidener").exists()){
accessWideners(file("src/main/resources/${mod_id}.accesswidener"))
def aw = file("src/main/resources/${mod_id}.accesswidener")
if (aw.exists()) {
accessWideners(aw)
}
}

dependencies {
compileOnly "org.spongepowered:mixin:$mixin_version"

compileOnly project(":shared-bridge")
}

apply from: rootProject.file('repositories.gradle')
apply from: 'dependencies.gradle'

tasks.withType(JavaCompile).configureEach {
source(project(":shared-bridge").sourceSets.main.allSource)
configurations {
commonJava {
canBeResolved = false
canBeConsumed = true
}
commonResources {
canBeResolved = false
canBeConsumed = true
}
}

artifacts {
commonJava sourceSets.main.java.sourceDirectories.singleFile
commonResources sourceSets.main.resources.sourceDirectories.singleFile
}

publishing {
/*publishing {
publications {
mavenJava(MavenPublication) {
artifactId = mod_id + "-common"
Expand All @@ -55,4 +65,12 @@ publishing {
credentials(PasswordCredentials)
}
}
}*/

sourceSets {
main {
java {
srcDir 'src/shell/java'
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
54 changes: 10 additions & 44 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
plugins {
id 'multiloader-loader'
id 'fabric-loom'
id 'maven-publish'
id 'idea'
id 'net.darkhax.curseforgegradle'
id "com.modrinth.minotaur"
}

base {
archivesName = "${mod_id}-fabric-${minecraft_version}"
}

dependencies {
minecraft "com.mojang:minecraft:${minecraft_version}"
mappings loom.officialMojangMappings()

modImplementation "net.fabricmc:fabric-loader:${fabric_loader_version}"
modImplementation "net.fabricmc.fabric-api:fabric-api:${fabric_version}"

implementation project(":shared")
implementation project(":shared-bridge")

compileOnly "org.jetbrains:annotations:22.0.0"
}

apply from: rootProject.file('repositories.gradle')
apply from: 'dependencies.gradle'

loom {
if (project(":shared").file("src/main/resources/${mod_id}.accesswidener").exists()) {
accessWidenerPath.set(project(":shared").file("src/main/resources/${mod_id}.accesswidener"))
def aw = project(":common").file("src/main/resources/${mod_id}.accesswidener")
if (aw.exists()) {
accessWidenerPath.set(aw)
}

mixin {
Expand All @@ -39,13 +30,13 @@ loom {
client()
setConfigName("fabric Client")
ideConfigGenerated(true)
runDir("run")
runDir("runs/client")
}
server {
server()
setConfigName("fabric Server")
ideConfigGenerated(true)
runDir("run")
runDir("runs/server")
}
data {
inherit client
Expand All @@ -54,15 +45,15 @@ loom {
runDir("build/datagen")

vmArg "-Dfabric-api.datagen"
vmArg "-Dfabric-api.datagen.output-dir=${project(":shared").file("src/main/generated")}"
vmArg "-Dfabric-api.datagen.output-dir=${project(":common").file("src/main/generated")}"
vmArg "-Dfabric-api.datagen.modid=${mod_id}"
}
}
}

sourceSets.main.resources.srcDir('src/generated/resources')

tasks.withType(JavaCompile).configureEach {
/*tasks.withType(JavaCompile).configureEach {
source(project(":shared").sourceSets.main.allSource)
source(project(":shared-bridge").sourceSets.main.allSource)
}
Expand All @@ -73,32 +64,7 @@ tasks.withType(Javadoc).configureEach {
tasks.named("sourcesJar", Jar) {
from(project(":shared").sourceSets.main.allSource)
from(project(":shared-bridge").sourceSets.main.allSource)
}

processResources {
from project(":shared").sourceSets.main.resources
}

publishing {
publications {
mavenJava(MavenPublication) {
artifactId = mod_id + "-fabric"
version = project.version + (!project.version.endsWith("SNAPSHOT") ? "+" + minecraft_version : "")

from components.java
}
}

repositories {
maven {
var releasesRepoUrl = "https://maven.twelveiterations.com/repository/maven-releases/"
var snapshotsRepoUrl = "https://maven.twelveiterations.com/repository/maven-snapshots/"
url = uri(version.toString().endsWith("SNAPSHOT") ? snapshotsRepoUrl : releasesRepoUrl)
name = "twelveIterationsNexus"
credentials(PasswordCredentials)
}
}
}
}*/

task curseforge(type: net.darkhax.curseforgegradle.TaskPublishCurseForge) {
dependsOn('build')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package net.blay09.mods.balm.api.block.entity;

import net.minecraft.core.BlockPos;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;

import java.util.List;

public abstract class BalmBlockEntityBase extends BlockEntity {
public BalmBlockEntityBase(BlockEntityType<?> blockEntityType, BlockPos blockPos, BlockState blockState) {
super(blockEntityType, blockPos, blockState);
}

protected abstract void buildProviders(List<Object> providers);
}
13 changes: 13 additions & 0 deletions fabric/src/main/java/net/blay09/mods/balm/api/event/BalmEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package net.blay09.mods.balm.api.event;

public abstract class BalmEvent {
private boolean canceled;

public boolean isCanceled() {
return canceled;
}

public void setCanceled(boolean canceled) {
this.canceled = canceled;
}
}
Loading

0 comments on commit e889930

Please sign in to comment.