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

Port to MDG, make runs work #592

Merged
merged 4 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
107 changes: 61 additions & 46 deletions helper_from_refinedarchitect_now_local.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ buildscript {
classpath 'info.solidsoft.gradle.pitest:gradle-pitest-plugin:1.15.0'
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:4.4.1.3373'
classpath 'org.spongepowered:vanillagradle:0.2.1-SNAPSHOT'
classpath 'net.neoforged.gradle:userdev:7.0.152'
classpath 'fabric-loom:fabric-loom.gradle.plugin:1.7-SNAPSHOT'
classpath 'net.darkhax.curseforgegradle:CurseForgeGradle:1.1.18'
classpath 'com.modrinth.minotaur:Minotaur:2.+'
// https://projects.neoforged.net/neoforged/ModDevGradle
classpath 'net.neoforged:moddev-gradle:0.1.122'
}
}

Expand Down Expand Up @@ -55,10 +56,6 @@ allprojects {
it.options.compilerArgs << "-Xmaxerrs" << "999"
}

repositories {
mavenCentral()
}

dependencies {
implementation "com.google.code.findbugs:jsr305:3.0.2"
}
Expand All @@ -84,6 +81,8 @@ allprojects {

ext {
minecraftVersion = "1.21"
// See: https://projects.neoforged.net/neoforged/neoform
neoFormVersion = "1.21-20240613.152323"
forgeVersion = "21.0.42-beta"
fabricLoaderVersion = "0.15.11"
fabricApiVersion = "0.100.4+1.21"
Expand Down Expand Up @@ -165,9 +164,9 @@ allprojects {
}

ext.commonProject = {
apply plugin: org.spongepowered.gradle.vanilla.VanillaGradle
minecraft {
version(minecraftVersion)
apply plugin : net.neoforged.moddevgradle.boot.ModDevPlugin
neoForge {
neoFormVersion = rootProject.neoFormVersion
}
sourceSets {
main.resources.srcDirs += 'src/generated/resources'
Expand All @@ -176,66 +175,82 @@ allprojects {
compileOnly "org.spongepowered:mixin:0.8.5"
}
}

ext.forgeProject = { String modId, Project commonProject = null, ArrayList apis = [], ArrayList compileApis = [] ->
apply plugin: net.neoforged.gradle.userdev.UserDevPlugin
if (file('src/main/resources/META-INF/accesstransformer.cfg').exists()) {
minecraft.accessTransformers.file file('src/main/resources/META-INF/accesstransformer.cfg')
}
runs {
configureEach {
modSource project.sourceSets.main
}
client {
systemProperty 'neoforge.enabledGameTestNamespaces', modId
}
server {
systemProperty 'neoforge.enabledGameTestNamespaces', modId
programArgument '--nogui'
}
gameTestServer {
systemProperty 'neoforge.enabledGameTestNamespaces', modId
modSource project.sourceSets.test
apply plugin : net.neoforged.moddevgradle.boot.ModDevPlugin

neoForge {
version = forgeVersion
// The test source set does not inherit any "local" dependencies of main
// this ensures Minecraft classes are available to it.
addModdingDependenciesTo(project.sourceSets.test)
mods {
"${modId}" {
modSourceSets = [project.sourceSets.main, project.sourceSets.test]
for (var api : apis) {
modSourceSets.add(project(api).sourceSets.main)
}
for (var api : compileApis) {
modSourceSets.add(project(api).sourceSets.main)
}
if (commonProject != null) {
modSourceSets.add(commonProject.sourceSets.main)
}
}
}
data {
var destinationProject = commonProject != null ? commonProject : project
var existingProject = commonProject != null ? commonProject : project
programArguments.addAll '--mod', modId, '--all', '--output', destinationProject.file('src/generated/resources/').getAbsolutePath(), '--existing', existingProject.file('src/main/resources/').getAbsolutePath()
runs {
client {
client()
systemProperty 'neoforge.enabledGameTestNamespaces', modId
}
server {
server()
systemProperty 'neoforge.enabledGameTestNamespaces', modId
programArgument '--nogui'
}
gameTestServer {
type = "gameTestServer"
systemProperty 'neoforge.enabledGameTestNamespaces', modId
}
data {
data()
var destinationProject = commonProject != null ? commonProject : project
var existingProject = commonProject != null ? commonProject : project
programArguments.addAll '--mod', modId, '--all', '--output', destinationProject.file('src/generated/resources/').getAbsolutePath(), '--existing', existingProject.file('src/main/resources/').getAbsolutePath()
}
}
}
dependencies {
implementation "net.neoforged:neoforge:${forgeVersion}"
testImplementation "net.neoforged:testframework:${forgeVersion}"
apis.collect {
implementation project(it)
compileOnly project(it)
testCompileOnly project(it)
}
compileApis.collect {
implementation project(it)
compileOnly project(it)
testCompileOnly project(it)
}
if (commonProject != null) {
implementation commonProject
compileOnly commonProject
testCompileOnly commonProject
}
}
sourceSets {
main.resources.srcDirs += 'src/generated/resources'
}
processResources {
if (commonProject != null) {
from commonProject.sourceSets.main.resources
}
from project.sourceSets.main.resources
}
Spec<Task> notNeoTask = { Task t -> !t.name.startsWith("neo") } as Spec<Task>
tasks.withType(JavaCompile).matching(notNeoTask).configureEach {
tasks.withType(Jar).configureEach {
duplicatesStrategy = "exclude"
apis.collect {
source(project(it).sourceSets.main.allSource)
from(project(it).sourceSets.main.output)
}
compileApis.collect {
source(project(it).sourceSets.main.allSource)
from(project(it).sourceSets.main.output)
}
if (commonProject != null) {
source(commonProject.sourceSets.main.allSource)
from(commonProject.sourceSets.main.output)
}
// These come in from the common API jars but should not end up in the neoforge jar
excludes = ['fabric.mod.json']
}
}

Expand Down
4 changes: 2 additions & 2 deletions refinedstorage-platform-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ plugins {
id 'java-library'
}

commonProject()

archivesBaseName = 'refinedstorage-platform-api'

commonProject()
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flipping this around was an accident and is not necessary


dependencies {
api libs.apiguardian
api project(':refinedstorage-core-api')
Expand Down
5 changes: 5 additions & 0 deletions refinedstorage-platform-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ archivesBaseName = 'refinedstorage-platform-common'

commonProject()

sourceSets {
main.resources.srcDirs += 'src/generated/resources'
}

dependencies {
compileOnly "org.spongepowered:mixin:0.8.5"
api project(':refinedstorage-platform-api')
api project(':refinedstorage-core-api')
api project(':refinedstorage-resource-api')
Expand Down
1 change: 1 addition & 0 deletions refinedstorage-platform-neoforge/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

forgeProject("refinedstorage", project(":refinedstorage-platform-common"), apis, compileApis)

archivesBaseName = 'refinedstorage-platform-neoforge'
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

gradle.ext.refinedArchitectVersion = "0.14.3"

dependencyResolutionManagement {
Expand Down