Skip to content

Commit

Permalink
Update CurseForgeGradle support
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredlll08 committed Jan 22, 2022
1 parent 08c3f90 commit 75a756d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 55 deletions.
5 changes: 3 additions & 2 deletions Fabric/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import com.blamejared.modtemplate.Utils
import net.darkhax.curseforgegradle.TaskPublishCurseForge
import net.darkhax.curseforgegradle.Constants as CFG_Contants

plugins {
`maven-publish`
Expand Down Expand Up @@ -153,8 +154,8 @@ tasks.create<TaskPublishCurseForge>("publishCurseForge") {

val mainFile = upload(curseProjectId, file("${project.buildDir}/libs/$baseArchiveName-$version.jar"))
mainFile.changelogType = "markdown"
mainFile.changelog = file("changelog.md")
mainFile.releaseType = net.darkhax.curseforgegradle.Constants.RELEASE_TYPE_RELEASE
mainFile.changelog = Utils.getFullChangelog(project)
mainFile.releaseType = CFG_Contants.RELEASE_TYPE_RELEASE
mainFile.addJavaVersion("Java $modJavaVersion")
mainFile.addRequirement("ingredient-extension-api")
mainFile.addRequirement("fabric-api")
Expand Down
29 changes: 14 additions & 15 deletions Forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ minecraft {
all {
lazyToken("minecraft_classpath") {
configurations.library.get().copyRecursive().resolve()
.joinToString(File.pathSeparator) { it.absolutePath }
.joinToString(File.pathSeparator) { it.absolutePath }
}
}
create("client") {
Expand Down Expand Up @@ -109,13 +109,13 @@ minecraft {
workingDirectory(project.file("run"))
ideaModule("${rootProject.name}.${project.name}.main")
args(
"--mod",
modId,
"--all",
"--output",
file("src/generated/resources/"),
"--existing",
file("src/main/resources/")
"--mod",
modId,
"--all",
"--output",
file("src/generated/resources/"),
"--existing",
file("src/main/resources/")
)
args("-mixin.config=${modId}.mixins.json", "-mixin.config=${modId}.forge.mixins.json")
mods {
Expand Down Expand Up @@ -193,11 +193,11 @@ publishing {
deps.map { it as Node }.forEach { dep ->
val versionList = dep.getAt(QName("http://maven.apache.org/POM/4.0.0", "version"))
versionList.map { it as Node }.map { it.value() as NodeList }.map { it.text() }
.forEach { version ->
if (version.contains("_mapped_")) {
dep.parent().remove(dep)
.forEach { version ->
if (version.contains("_mapped_")) {
dep.parent().remove(dep)
}
}
}
}
}
}
Expand All @@ -210,15 +210,14 @@ publishing {
}

tasks.create<TaskPublishCurseForge>("publishCurseForge") {
apiToken = System.getenv("curseforgeApiToken") ?: 0
apiToken = Utils.locateProperty(project, "curseforgeApiToken") ?: 0

val mainFile = upload(curseProjectId, file("${project.buildDir}/libs/$baseArchiveName-$version.jar"))
mainFile.changelogType = "markdown"
mainFile.changelog = file("changelog.md")
mainFile.changelog = Utils.getFullChangelog(project)
mainFile.releaseType = CFG_Contants.RELEASE_TYPE_RELEASE
mainFile.addJavaVersion("Java $modJavaVersion")


doLast {
project.ext.set("curse_file_url", "${curseHomepageLink}/files/${mainFile.curseFileId}")
}
Expand Down
40 changes: 5 additions & 35 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import com.blamejared.modtemplate.Utils
import com.diluv.schoomp.Webhook
import com.diluv.schoomp.message.Message
import com.diluv.schoomp.message.embed.Embed
import java.io.ByteArrayOutputStream
import java.io.IOException
import java.text.SimpleDateFormat
import java.util.*
Expand All @@ -11,11 +10,9 @@ import java.util.*
buildscript {
repositories {
mavenCentral()
maven("https://maven.blamejared.com") { }
}
dependencies {
classpath("com.diluv.schoomp:Schoomp:1.2.5")
classpath("com.blamejared:ModTemplate:[2.0.0.34,)")
}
}

Expand All @@ -39,6 +36,7 @@ val modVersion: String by project
plugins {
`java-library`
idea
id("com.blamejared.modtemplate") version ("3.0.0.37")
}

version = Utils.updatingSemVersion(modVersion)
Expand Down Expand Up @@ -166,7 +164,6 @@ subprojects {
options.release.set(modJavaVersion.toInt())
options.compilerArgs.add("-Acrafttweaker.processor.document.output_directory=${rootProject.file("docsOut")}")
options.compilerArgs.add("-Acrafttweaker.processor.document.multi_source=true")

}

tasks {
Expand Down Expand Up @@ -246,17 +243,17 @@ tasks.create("postDiscord") {
}

downloadSources.add(
"<:maven:932165250738970634> `\"com.blamejared.crafttweaker:${project(":Common").base.archivesName.get()}:${
"<:maven:932165250738970634> `\"${project(":Common").group}:${project(":Common").base.archivesName.get()}:${
project(":Common").version
}\"`"
)
downloadSources.add(
"<:maven:932165250738970634> `\"com.blamejared.crafttweaker:${project(":Fabric").base.archivesName.get()}:${
"<:maven:932165250738970634> `\"${project(":Fabric").group}:${project(":Fabric").base.archivesName.get()}:${
project(":Fabric").version
}\"`"
)
downloadSources.add(
"<:maven:932165250738970634> `\"com.blamejared.crafttweaker:${project(":Forge").base.archivesName.get()}:${
"<:maven:932165250738970634> `\"${project(":Forge").group}:${project(":Forge").base.archivesName.get()}:${
project(":Forge").version
}\"`"
)
Expand All @@ -270,7 +267,7 @@ tasks.create("postDiscord") {
}

// Just use the Forge changelog for now, the files are the same anyway.
embed.addField("Changelog", getCIChangelog().take(1000), false)
embed.addField("Changelog", Utils.getCIChangelog(project, gitRepo).take(1000), false)

embed.color = 0xF16436
message.addEmbed(embed)
Expand All @@ -282,31 +279,4 @@ tasks.create("postDiscord") {
}
}

}

fun getCIChangelog(): String {
return try {
val stdout = ByteArrayOutputStream()
val gitHash: String? = System.getenv("GIT_COMMIT")
val gitPrevHash: String? = System.getenv("GIT_PREVIOUS_COMMIT")
val repo = "$gitRepo/commit/"
if (gitHash != null && gitPrevHash != null) {
exec {
this.commandLine("git")
.args("log", "--pretty=tformat:- [%s]($repo%H) - %aN ", "$gitPrevHash...$gitHash").standardOutput =
stdout
}
stdout.toString().trim()
} else if (gitHash != null) {
exec {
this.commandLine("git")
.args("log", "--pretty=tformat:- [%s]($repo%H) - %aN ", "-1", gitHash).standardOutput = stdout
}
stdout.toString().trim()
} else {
"Unavailable"
}
} catch (ignored: Exception) {
"Unavailable"
}
}
3 changes: 0 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ pluginManagement {
if (requested.id.id == "org.spongepowered.mixin") {
useModule("org.spongepowered:mixingradle:${requested.version}")
}
if (requested.id.id == "com.blamejared.modtemplate") {
useModule("com.blamejared:ModTemplate:${requested.version}")
}
}
}
}
Expand Down

0 comments on commit 75a756d

Please sign in to comment.