Skip to content

Commit

Permalink
update buildscript
Browse files Browse the repository at this point in the history
  • Loading branch information
FalsePattern committed Feb 5, 2022
1 parent 4f18a27 commit cc3883b
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 54 deletions.
108 changes: 58 additions & 50 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//version: 8fa7883b6196c1765266f4e6ddf3118d5043aafb
//version: 1641429628falsepattern5
/*
DO NOT CHANGE THIS FILE!
Also, you may replace this file at any time if there is an update available.
Please check https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/build.gradle for updates.
Please check https://github.com/FalsePattern/ExampleMod1.7.10/blob/main/build.gradle for updates.
*/


Expand Down Expand Up @@ -32,7 +32,7 @@ buildscript {
}
}
dependencies {
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.4'
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.6'
}
}

Expand Down Expand Up @@ -88,6 +88,13 @@ checkPropertyExists("containsMixinsAndOrCoreModOnly")
checkPropertyExists("usesShadowedDependencies")
checkPropertyExists("developmentEnvironmentUserName")

//Properties added in fork
checkPropertyExists("skipBuildScriptUpdateCheck")
checkPropertyExists("repositoryURL")
checkPropertyExists("repositoryName")
checkPropertyExists("mavenGroupId")
checkPropertyExists("mavenArtifactId")


String javaSourceDir = "src/main/java/"
String scalaSourceDir = "src/main/scala/"
Expand Down Expand Up @@ -153,7 +160,7 @@ configurations.all {
'git config core.fileMode false'.execute()
// Pulls version from git tag
try {
version = minecraftVersion + "-" + gitVersion()
version = gitVersion()
}
catch (Exception e) {
throw new IllegalStateException("This mod must be version controlled by Git AND the repository must provide at least one tag!");
Expand All @@ -166,6 +173,7 @@ if(project.hasProperty("customArchiveBaseName") && customArchiveBaseName) {
else {
archivesBaseName = modId
}
archivesBaseName += "-mc" + minecraftVersion

minecraft {
version = minecraftVersion + "-" + forgeVersion + "-" + minecraftVersion
Expand All @@ -186,6 +194,33 @@ minecraft {
replace gradleTokenGroupName, modGroup
}
}

def arguments = []
def jvmArguments = []

if(usesMixins.toBoolean()) {
arguments += [
"--mods=../build/libs/$modId-${version}.jar".toString(),
"--tweakClass org.spongepowered.asm.launch.MixinTweaker".toString()
]
jvmArguments += [
"-Dmixin.debug=true", "-Dmixin.debug.countInjections=true", "-Dmixin.debug.verbose=true", "-Dmixin.debug.export=true".toString()
]
}

clientRunConfig {
args(arguments)
jvmArgs(jvmArguments)

if(developmentEnvironmentUserName) {
args("--username", developmentEnvironmentUserName)
}
}

serverRunConfig {
args(arguments)
jvmArgs(jvmArguments)
}
}

if(file("addon.gradle").exists()) {
Expand Down Expand Up @@ -316,39 +351,6 @@ afterEvaluate {
}
}

runClient {
def arguments = []

if(usesMixins.toBoolean()) {
arguments += [
"--mods=../build/libs/$modId-${version}.jar",
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
]
}

if(developmentEnvironmentUserName) {
arguments += [
"--username",
developmentEnvironmentUserName
]
}

args(arguments)
}

runServer {
def arguments = []

if (usesMixins.toBoolean()) {
arguments += [
"--mods=../build/libs/$modId-${version}.jar",
"--tweakClass org.spongepowered.asm.launch.MixinTweaker"
]
}

args(arguments)
}

tasks.withType(JavaExec).configureEach {
javaLauncher.set(
javaToolchains.launcherFor {
Expand Down Expand Up @@ -488,6 +490,7 @@ artifacts {
}

// publishing

def getMavenSettingsCredentials = {
String userHome = System.getProperty( "user.home" );
File mavenSettings = new File(userHome, ".m2/settings.xml")
Expand All @@ -497,14 +500,19 @@ def getMavenSettingsCredentials = {
}

def getCredentials = {
def entries = getMavenSettingsCredentials()
for (entry in entries) {
if ( entry."id".text() == "mavenpattern" ) {
return [username: entry.username.text(), password: entry.password.text()]
try {
def entries = getMavenSettingsCredentials()
for (entry in entries) {
if (entry."id".text() == repositoryName) {
return [username: entry.username.text(), password: entry.password.text()]
}
}
} catch (Exception ignored) {
return [username: "none", password: "none"]
}
}

//Publishing
publishing {
publications {
maven(MavenPublication) {
Expand All @@ -515,16 +523,16 @@ publishing {
artifact source: apiJar, classifier: "api"
}

groupId = group
artifactId = modId
version = project.version
groupId = mavenGroupId
artifactId = mavenArtifactId + "-mc" + minecraftVersion
version = gitVersion()
}
}

repositories {
maven {
name = "mavenpattern"
url = "https://maven.falsepattern.com/"
name = repositoryName
url = repositoryURL
def creds = getCredentials()
credentials {
username = creds == null ? "none" : creds.username
Expand All @@ -543,7 +551,7 @@ task updateBuildScript {
}
}

if (isNewBuildScriptVersionAvailable(projectDir.toString())) {
if (!skipBuildScriptUpdateCheck.toBoolean() && isNewBuildScriptVersionAvailable(projectDir.toString())) {
if (autoUpdateBuildScript.toBoolean()) {
performBuildScriptUpdate(projectDir.toString())
} else {
Expand All @@ -552,7 +560,7 @@ if (isNewBuildScriptVersionAvailable(projectDir.toString())) {
}

static URL availableBuildScriptUrl() {
new URL("https://raw.githubusercontent.com/SinTh0r4s/ExampleMod1.7.10/main/build.gradle")
new URL("https://raw.githubusercontent.com/FalsePattern/ExampleMod1.7.10/main/build.gradle")
}

boolean performBuildScriptUpdate(String projectDir) {
Expand Down Expand Up @@ -594,7 +602,7 @@ configure(updateBuildScript) {

def checkPropertyExists(String propertyName) {
if (project.hasProperty(propertyName) == false) {
throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/SinTh0r4s/ExampleMod1.7.10/blob/main/gradle.properties")
throw new GradleException("This project requires a property \"" + propertyName + "\"! Please add it your \"gradle.properties\". You can find all properties and their description here: https://github.com/FalsePattern/ExampleMod1.7.10/blob/main/gradle.properties")
}
}

Expand Down
23 changes: 19 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,29 @@ modName = Triangulator
# This is a case-sensitive string to identify your mod. Convention is to use lower case.
modId = triangulator

modGroup = com.falsepattern
modGroup = com.falsepattern.triangulator

# WHY is there no version field?
# The build script relies on git to provide a version via tags. It is super easy and will enable you to always know the
# code base or your binary. Check out this tutorial: https://blog.mattclemente.com/2017/10/13/versioning-with-git-tags/

# The server to upload the artifacts to
repositoryURL = https://maven.falsepattern.com/releases/

# What name is the login information inside ~/.m2/settings.xml stored under
# (see https://gist.github.com/FalsePattern/82d93e3cfab01f671cc5f4a95931cfe3 for an example)
repositoryName = mavenpattern

# What the artifact should be called. These will be the "name" of the published package, suffixed with the minecraft version with a -mc prefix (groupid:artifactid-mcminecraftVersion:version:qualifier).
# For instance, the default values this example ships with would turn into com.myname:mymodid-mc1.7.10:version
# The version is determined automatically from the git version.
mavenGroupId = com.falsepattern
mavenArtifactId = triangulator

# Will update your build.gradle automatically whenever an update is available
autoUpdateBuildScript = false
# Disable checking of buildscript updates.
skipBuildScriptUpdateCheck = false

minecraftVersion = 1.7.10
forgeVersion = 10.13.4.1614
Expand All @@ -35,7 +50,7 @@ gradleTokenGroupName = GRADLETOKEN_GROUPNAME
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise you can
# leave this property empty.
# Example value: apiPackage = api + modGroup = com.myname.mymodid -> com.myname.mymodid.api
apiPackage = triangulator.api
apiPackage = api

# Specify the configuration file for Forge's access transformers here. I must be placed into /src/main/resources/META-INF/
# Example value: mymodid_at.cfg
Expand All @@ -44,9 +59,9 @@ accessTransformersFile =
# Provides setup for Mixins if enabled. If you don't know what mixins are: Keep it disabled!
usesMixins = true
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
mixinPlugin = triangulator.mixin.plugin.MixinPlugin
mixinPlugin = mixin.plugin.MixinPlugin
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
mixinsPackage = triangulator.mixin.mixins
mixinsPackage = mixin.mixins
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
# This parameter is for legacy compatability only
# Example value: coreModClass = asm.FMLPlugin + modGroup = com.myname.mymodid -> com.myname.mymodid.asm.FMLPlugin
Expand Down

0 comments on commit cc3883b

Please sign in to comment.