Skip to content

Commit

Permalink
Merge pull request #139 from refinedmods/feat/GH-138/switch-to-mdg
Browse files Browse the repository at this point in the history
Switch to mdg
  • Loading branch information
raoulvdberge authored Jul 5, 2024
2 parents f30ac23 + cc9ad82 commit faa4152
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/actions/setup-java/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ runs:
using: "composite"
steps:
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/actions/wrapper-validation@v3
- name: Setup JDK 21
uses: actions/setup-java@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
# https://docs.sonarqube.org/latest/analysis/github-integration/
- name: Cache SonarQube packages
if: ${{ inputs.sonarqube == true }}
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
Expand All @@ -50,7 +50,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Analyze
if: ${{ inputs.sonarqube == true }}
run: ./gradlew sonar
run: ./gradlew assemble sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Changed

- Switched from NeoGradle to ModDevGradle.
- Upgrade cache and Gradle wrapper validation actions.
- Disable implicit compilation in Sonar Gradle plugin.

## [0.14.3] - 2024-07-03

### Fixed
Expand Down
107 changes: 64 additions & 43 deletions helper.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ buildscript {
dependencies {
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 @@ -84,6 +84,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 +167,10 @@ allprojects {
}

ext.commonProject = {
apply plugin: org.spongepowered.gradle.vanilla.VanillaGradle
minecraft {
version(minecraftVersion)
apply plugin: net.neoforged.moddevgradle.boot.ModDevPlugin
neoForge {
neoFormVersion = rootProject.neoFormVersion
addModdingDependenciesTo(project.sourceSets.test)
}
sourceSets {
main.resources.srcDirs += 'src/generated/resources'
Expand All @@ -178,64 +181,81 @@ allprojects {
}

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
sourceSet = project.sourceSets.test
}
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 Expand Up @@ -334,6 +354,7 @@ tasks.register('codeCoverageReport', JacocoReport) {
}

ext.enableSonarQube = (String projectKey, String organization = "refinedmods") -> {
System.setProperty("sonar.gradle.skipCompile", "true")
apply plugin: org.sonarqube.gradle.SonarQubePlugin
// https://docs.sonarqube.org/latest/analysis/github-integration/
sonarqube {
Expand All @@ -344,4 +365,4 @@ ext.enableSonarQube = (String projectKey, String organization = "refinedmods") -
property "sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/jacoco/codeCoverageReport/codeCoverageReport.xml"
}
}
}
}

0 comments on commit faa4152

Please sign in to comment.