Skip to content

Commit

Permalink
Update Buildscript (#64)
Browse files Browse the repository at this point in the history
* Update buildscript and gradle.properties

* Update Gregtech
  • Loading branch information
ALongStringOfNumbers committed Jan 12, 2024
1 parent 413fbdb commit 267b5bc
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 28 deletions.
99 changes: 80 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//version: 1700970468
//version: 1704659416
/*
* DO NOT CHANGE THIS FILE!
* Also, you may replace this file at any time if there is an update available.
Expand All @@ -24,9 +24,9 @@ plugins {
id 'eclipse'
id 'maven-publish'
id 'org.jetbrains.gradle.plugin.idea-ext' version '1.1.7'
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.24'
id 'net.darkhax.curseforgegradle' version '1.1.16' apply false
id 'com.modrinth.minotaur' version '2.8.4' apply false
id 'com.gtnewhorizons.retrofuturagradle' version '1.3.25'
id 'net.darkhax.curseforgegradle' version '1.1.17' apply false
id 'com.modrinth.minotaur' version '2.8.6' apply false
id 'com.diffplug.spotless' version '6.13.0' apply false
id 'com.palantir.git-version' version '3.0.0' apply false
id 'com.github.johnrengelman.shadow' version '8.1.1' apply false
Expand Down Expand Up @@ -62,6 +62,7 @@ propertyDefaultIfUnset("generateGradleTokenClass", "")
propertyDefaultIfUnset("gradleTokenModId", "")
propertyDefaultIfUnset("gradleTokenModName", "")
propertyDefaultIfUnset("gradleTokenVersion", "")
propertyDefaultIfUnset("useSrcApiPath", false)
propertyDefaultIfUnset("includeWellKnownRepositories", true)
propertyDefaultIfUnset("includeCommonDevEnvMods", true)
propertyDefaultIfUnset("noPublishedSources", false)
Expand All @@ -72,13 +73,15 @@ propertyDefaultIfUnset("usesShadowedDependencies", false)
propertyDefaultIfUnset("minimizeShadowedDependencies", true)
propertyDefaultIfUnset("relocateShadowedDependencies", true)
propertyDefaultIfUnset("separateRunDirectories", false)
propertyDefaultIfUnset("versionDisplayFormat", '$MOD_NAME \u2212 $VERSION')
propertyDefaultIfUnsetWithEnvVar("modrinthProjectId", "", "MODRINTH_PROJECT_ID")
propertyDefaultIfUnset("modrinthRelations", "")
propertyDefaultIfUnsetWithEnvVar("curseForgeProjectId", "", "CURSEFORGE_PROJECT_ID")
propertyDefaultIfUnset("curseForgeRelations", "")
propertyDefaultIfUnsetWithEnvVar("releaseType", "release", "RELEASE_TYPE")
propertyDefaultIfUnset("generateDefaultChangelog", false)
propertyDefaultIfUnset("customMavenPublishUrl", "")
propertyDefaultIfUnset("mavenArtifactGroup", getDefaultArtifactGroup())
propertyDefaultIfUnset("enableModernJavaSyntax", false)
propertyDefaultIfUnset("enableSpotless", false)
propertyDefaultIfUnset("enableJUnit", false)
Expand All @@ -103,9 +106,16 @@ if (!getFile(targetPackageJava).exists() && !getFile(targetPackageScala).exists(
}

if (apiPackage) {
targetPackageJava = javaSourceDir + modGroupPath + '/' + apiPackagePath
targetPackageScala = scalaSourceDir + modGroupPath + '/' + apiPackagePath
targetPackageKotlin = kotlinSourceDir + modGroupPath + '/' + apiPackagePath
final String endApiPath = modGroupPath + '/' + apiPackagePath
if (useSrcApiPath) {
targetPackageJava = 'src/api/java/' + endApiPath
targetPackageScala = 'src/api/scala/' + endApiPath
targetPackageKotlin = 'src/api/kotlin/' + endApiPath
} else {
targetPackageJava = javaSourceDir + endApiPath
targetPackageScala = scalaSourceDir + endApiPath
targetPackageKotlin = kotlinSourceDir + endApiPath
}
if (!getFile(targetPackageJava).exists() && !getFile(targetPackageScala).exists() && !getFile(targetPackageKotlin).exists()) {
throw new GradleException("Could not resolve \"apiPackage\"! Could not find ${targetPackageJava} or ${targetPackageScala} or ${targetPackageKotlin}")
}
Expand Down Expand Up @@ -222,6 +232,16 @@ if (enableSpotless.toBoolean()) {
//noinspection GroovyAssignabilityCheck
eclipse('4.19.0').configFile(formatFile)
}
kotlin {
target 'src/*/kotlin/**/*.kt'

toggleOffOn()
ktfmt('0.39')

trimTrailingWhitespace()
indentWithSpaces(4)
endWithNewline()
}
scala {
target 'src/*/scala/**/*.scala'
scalafmt('3.7.1')
Expand Down Expand Up @@ -424,8 +444,7 @@ repositories {
}
maven {
name 'GTNH Maven'
url 'http://jenkins.usrv.eu:8081/nexus/content/groups/public'
allowInsecureProtocol = true
url 'https://nexus.gtnewhorizons.com/repository/public/'
}
}
if (usesMixins.toBoolean() || forceEnableMixins.toBoolean()) {
Expand Down Expand Up @@ -663,6 +682,19 @@ jar {
it.isDirectory() ? it : zipTree(it)
}
}

if (useSrcApiPath && apiPackage) {
from sourceSets.api.output
dependsOn apiClasses

include "${modGroupPath}/**"
include "assets/**"
include "mcmod.info"
include "pack.mcmeta"
if (accessTransformersFile) {
include "META-INF/${accessTransformersFile}"
}
}
}

// Configure default run tasks
Expand All @@ -679,12 +711,21 @@ if (separateRunDirectories.toBoolean()) {
// Create API library jar
tasks.register('apiJar', Jar) {
archiveClassifier.set 'api'
from(sourceSets.main.java) {
include "${modGroupPath}/${apiPackagePath}/**"
}
if (useSrcApiPath) {
from(sourceSets.api.java) {
include "${modGroupPath}/${apiPackagePath}/**"
}
from(sourceSets.api.output) {
include "${modGroupPath}/${apiPackagePath}/**"
}
} else {
from(sourceSets.main.java) {
include "${modGroupPath}/${apiPackagePath}/**"
}

from(sourceSets.main.output) {
include "${modGroupPath}/${apiPackagePath}/**"
from(sourceSets.main.output) {
include "${modGroupPath}/${apiPackagePath}/**"
}
}
}

Expand Down Expand Up @@ -878,7 +919,7 @@ if (cfApiKey.isPresent() || deploymentDebug.toBoolean()) {
def changelogFile = getChangelog()
def changelogRaw = changelogFile.exists() ? changelogFile.getText('UTF-8') : ""

mainFile.displayName = "${modName}: ${modVersion}"
mainFile.displayName = versionDisplayFormat.replace('$MOD_NAME', modName).replace('$VERSION', modVersion)
mainFile.releaseType = getReleaseType()
mainFile.changelog = changelogRaw
mainFile.changelogType = 'markdown'
Expand All @@ -894,6 +935,12 @@ if (cfApiKey.isPresent() || deploymentDebug.toBoolean()) {
}
String[] parts = dep.split(':')
String type = parts[0], slug = parts[1]
def types = [
'req' : 'requiredDependency', 'required': 'requiredDependency',
'opt' : 'optionalDependency', 'optional': 'optionalDependency',
'embed' : 'embeddedLibrary', 'embedded': 'embeddedLibrary',
'incomp': 'incompatible', 'fail' : 'incompatible']
if (types.containsKey(type)) type = types[type]
if (!(type in ['requiredDependency', 'embeddedLibrary', 'optionalDependency', 'tool', 'incompatible'])) {
throw new Exception('Invalid Curseforge dependency type: ' + type)
}
Expand All @@ -918,6 +965,7 @@ if (modrinthApiKey.isPresent() || deploymentDebug.toBoolean()) {
modrinth {
token = modrinthApiKey.getOrElse('debug_token')
projectId = modrinthProjectId
versionName = versionDisplayFormat.replace('$MOD_NAME', modName).replace('$VERSION', modVersion)
changelog = changelogFile.exists() ? changelogFile.getText('UTF-8') : ""
versionType = getReleaseType()
versionNumber = modVersion
Expand All @@ -935,7 +983,7 @@ if (modrinthApiKey.isPresent() || deploymentDebug.toBoolean()) {
}
String[] parts = dep.split(':')
String[] qual = parts[0].split('-')
addModrinthDep(qual[0], qual[1], parts[1])
addModrinthDep(qual[0], qual.length > 1 ? qual[1] : 'project', parts[1])
}
}
tasks.modrinth.dependsOn(build)
Expand All @@ -944,9 +992,17 @@ if (modrinthApiKey.isPresent() || deploymentDebug.toBoolean()) {

def addModrinthDep(String scope, String type, String name) {
com.modrinth.minotaur.dependencies.Dependency dep
def types = [
'req' : 'required',
'opt' : 'optional',
'embed' : 'embedded',
'incomp': 'incompatible', 'fail': 'incompatible']
if (types.containsKey(scope)) scope = types[scope]
if (!(scope in ['required', 'optional', 'incompatible', 'embedded'])) {
throw new Exception('Invalid modrinth dependency scope: ' + scope)
}
types = ['proj': 'project', '': 'project', 'p': 'project', 'ver': 'version', 'v': 'version']
if (types.containsKey(type)) type = types[type]
switch (type) {
case 'project':
dep = new ModDependency(name, scope)
Expand Down Expand Up @@ -974,8 +1030,8 @@ if (customMavenPublishUrl) {
}

// providers is not available here, use System for getting env vars
groupId = System.getenv('ARTIFACT_GROUP_ID') ?: project.group
artifactId = System.getenv('ARTIFACT_ID') ?: project.name
groupId = System.getenv('ARTIFACT_GROUP_ID') ?: project.mavenArtifactGroup
artifactId = System.getenv('ARTIFACT_ID') ?: project.modArchivesBaseName
version = System.getenv('RELEASE_VERSION') ?: publishedVersion
}
}
Expand Down Expand Up @@ -1027,7 +1083,7 @@ def getChangelog() {

// Buildscript updating

def buildscriptGradleVersion = '8.2.1'
def buildscriptGradleVersion = '8.5'

tasks.named('wrapper', Wrapper).configure {
gradleVersion = buildscriptGradleVersion
Expand Down Expand Up @@ -1120,6 +1176,11 @@ tasks.register('faq') {

// Helpers

def getDefaultArtifactGroup() {
def lastIndex = project.modGroup.lastIndexOf('.')
return lastIndex < 0 ? project.modGroup : project.modGroup.substring(0, lastIndex)
}

def getFile(String relativePath) {
return new File(projectDir, relativePath)
}
Expand Down
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ dependencies {
// therefore we manually deobf the regular jar
implementation rfg.deobf("curse.maven:codechicken-lib-1-8-242818:2779848") // CCL 3.2.3.358
// manually deobf the jar to prevent extra configuration for handling obf/deobf separation
implementation rfg.deobf("curse.maven:gregtech-ce-unofficial-557242:4951281-deobf-4951282-sources-4951283")
implementation rfg.deobf("curse.maven:gregtech-ce-unofficial-557242:4965457-deobf-4965458-sources-4965459")

// Soft Dependencies
implementation "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.684"
Expand Down
19 changes: 18 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ gradleTokenVersion = VERSION
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
apiPackage =

# If you want to keep your API code in src/api instead of src/main
useSrcApiPath = false

# Specify the configuration file for Forge's access transformers here. It must be placed into /src/main/resources/
# There can be multiple files in a comma-separated list.
# Example value: mymodid_at.cfg,jei_at.cfg
Expand All @@ -52,6 +55,8 @@ accessTransformersFile =
usesMixins = false
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
mixinsPackage =
# Automatically generates a mixin config json if enabled, with the name mixins.modid.json
generateMixinConfig = true
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
coreModClass =
Expand All @@ -62,6 +67,11 @@ containsMixinsAndOrCoreModOnly = false
# Enables Mixins even if this mod doesn't use them, useful if one of the dependencies uses mixins.
forceEnableMixins = true

# Outputs pre-transformed and post-transformed loaded classes to run/CLASSLOADER_TEMP. Can be used in combination with
# diff to see exactly what your ASM or Mixins are changing in the target file.
# Optionally can be specified with the 'CORE_MOD_DEBUG' env var. Will output a lot of files!
enableCoreModDebug = false

# Adds CurseMaven, Modrinth Maven, BlameJared maven, and some more well-known 1.12.2 repositories
includeWellKnownRepositories = true

Expand All @@ -82,8 +92,11 @@ relocateShadowedDependencies = true

# Separate run directories into "run/client" for runClient task, and "run/server" for runServer task.
# Useful for debugging a server and client simultaneously. If not enabled, it will be in the standard location "run/"
separateRunDirectories = false
separateRunDirectories = false

# The display name format of versions published to Curse and Modrinth. $MOD_NAME and $VERSION are available variables.
# Default: $MOD_NAME \u2212 $VERSION. \u2212 is the minus character which looks much better than the hyphen minus on Curse.
versionDisplayFormat = $MOD_NAME \u2212 $VERSION

# Publishing to modrinth requires you to set the MODRINTH_API_KEY environment variable to your current modrinth API token.

Expand Down Expand Up @@ -137,6 +150,10 @@ noPublishedSources = false
# Password is set with the 'MAVEN_PASSWORD' environment variable, default to "NONE"
customMavenPublishUrl =

# The group for maven artifacts. Defaults to the 'project.modGroup' until the last '.' (if any).
# So 'mymod' becomes 'mymod' and 'com.myname.mymodid' 'becomes com.myname'
mavenArtifactGroup =

# Enable spotless checks
# Enforces code formatting on your source code
# By default this will use the files found here: https://github.com/GregTechCEu/Buildscripts/tree/master/spotless
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
5 changes: 4 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
Expand Down
8 changes: 3 additions & 5 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ pluginManagement {
maven {
// RetroFuturaGradle
name 'GTNH Maven'
//noinspection HttpUrlsUsage
url 'http://jenkins.usrv.eu:8081/nexus/content/groups/public/'
allowInsecureProtocol = true
url 'https://nexus.gtnewhorizons.com/repository/public/'
//noinspection GroovyAssignabilityCheck
mavenContent {
includeGroup 'com.gtnewhorizons'
Expand All @@ -19,9 +17,9 @@ pluginManagement {
}

plugins {
id 'com.diffplug.blowdryerSetup' version '1.6.0'
id 'com.diffplug.blowdryerSetup' version '1.7.0'
// Automatic toolchain provisioning
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.4.0'
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.7.0'
}

blowdryerSetup {
Expand Down

0 comments on commit 267b5bc

Please sign in to comment.