Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
344baf3
commit 6604294
Showing
69 changed files
with
4,548 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
* text eol=lf | ||
*.bat text eol=crlf | ||
*.patch text eol=lf | ||
*.java text eol=lf | ||
*.gradle text eol=crlf | ||
*.png binary | ||
*.gif binary | ||
*.exe binary | ||
*.dll binary | ||
*.jar binary | ||
*.lzma binary | ||
*.zip binary | ||
*.pyd binary | ||
*.cfg text eol=lf | ||
*.jks binary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
*.class | ||
|
||
# Package Files # | ||
*.war | ||
*.ear | ||
build | ||
eclipse | ||
bin | ||
out | ||
|
||
*.classpath | ||
*.project | ||
.gradle | ||
.settings | ||
.idea | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.metadata/* | ||
*.eml | ||
run/ | ||
usernamecache.json | ||
*.stackdump | ||
secrets.json | ||
changelog.md | ||
*.launch | ||
|
||
logs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/env groovy | ||
|
||
pipeline { | ||
agent any | ||
tools { | ||
jdk "jdk-17.0.1" | ||
} | ||
environment { | ||
curseforgeApiToken = credentials('curseforge_token') | ||
discordCFWebhook = credentials('discord_cf_webhook') | ||
versionTrackerKey = credentials('version_tracker_key') | ||
versionTrackerAPI = credentials('version_tracker_api') | ||
} | ||
stages { | ||
stage('Clean') { | ||
steps { | ||
echo 'Cleaning Project' | ||
sh 'chmod +x gradlew' | ||
sh './gradlew clean' | ||
} | ||
} | ||
stage('Build') { | ||
steps { | ||
echo 'Building' | ||
sh './gradlew build' | ||
} | ||
} | ||
stage('Git Changelog') { | ||
steps { | ||
sh './gradlew genGitChangelog' | ||
} | ||
} | ||
|
||
stage('Publish') { | ||
steps { | ||
echo 'Updating version' | ||
sh './gradlew updateVersionTracker' | ||
|
||
echo 'Deploying to Maven' | ||
sh './gradlew publish' | ||
|
||
echo 'Deploying to CurseForge' | ||
sh './gradlew publishCurseForge postDiscord' | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import com.blamejared.searchables.gradle.Properties | ||
import com.blamejared.searchables.gradle.Versions | ||
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.IOException | ||
import java.util.* | ||
|
||
plugins { | ||
`java-library` | ||
} | ||
|
||
version = Utils.updatingVersion(Versions.MOD) | ||
|
||
tasks.create("postDiscord") { | ||
|
||
doLast { | ||
try { | ||
|
||
// Create a new webhook instance for Discord | ||
val webhook = Webhook(Utils.locateProperty(project, "discordCFWebhook"), "${Properties.NAME} CurseForge Gradle Upload") | ||
|
||
// Craft a message to send to Discord using the webhook. | ||
val message = Message() | ||
message.username = Properties.NAME | ||
message.avatarUrl = Properties.AVATAR | ||
message.content = "${Properties.NAME} $version for Minecraft ${Versions.MINECRAFT} has been published!" | ||
|
||
val embed = Embed() | ||
val downloadSources = StringJoiner("\n") | ||
|
||
mapOf(Pair("fabric", "<:fabric:932163720568782878>"), Pair("forge", "<:forge:932163698003443804>")) | ||
.filter { | ||
project(":${it.key}").ext.has("curse_file_url") | ||
}.map { "${it.value} [${it.key.capitalize(Locale.ENGLISH)}](${project(":${it.key}").ext.get("curse_file_url")})" } | ||
.forEach { downloadSources.add(it) } | ||
|
||
listOf("common", "fabric", "forge") | ||
.map { project(":${it}") } | ||
.map { "<:maven:932165250738970634> `\"${it.group}:${it.base.archivesName.get()}:${it.version}\"`" } | ||
.forEach { downloadSources.add(it) } | ||
|
||
// Add Curseforge DL link if available. | ||
val downloadString = downloadSources.toString() | ||
|
||
if (downloadString.isNotEmpty()) { | ||
|
||
embed.addField("Download", downloadString, false) | ||
} | ||
|
||
embed.addField("Changelog", Utils.getCIChangelog(project, Properties.GIT_REPO).take(1000), false) | ||
|
||
embed.color = 0xF16436 | ||
message.addEmbed(embed) | ||
|
||
webhook.sendMessage(message) | ||
} catch (e: IOException) { | ||
|
||
project.logger.error("Failed to push CF Discord webhook.") | ||
project.file("post_discord_error.log").writeText(e.stackTraceToString()) | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import org.gradle.kotlin.dsl.`kotlin-dsl` | ||
|
||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
gradlePluginPortal() | ||
maven("https://maven.blamejared.com") { | ||
name = "BlameJared" | ||
} | ||
} | ||
|
||
dependencies { | ||
gradleApi() | ||
implementation(group = "com.blamejared", name = "ModTemplate", version = "3.0.0.38") | ||
implementation(group = "net.darkhax.curseforgegradle", name = "CurseForgeGradle", version = "1.0.10") | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
create("default") { | ||
id = "com.blamejared.searchables.default" | ||
implementationClass = "com.blamejared.searchables.gradle.DefaultPlugin" | ||
} | ||
create("loader") { | ||
id = "com.blamejared.searchables.loader" | ||
implementationClass = "com.blamejared.searchables.gradle.LoaderPlugin" | ||
} | ||
} | ||
} |
196 changes: 196 additions & 0 deletions
196
buildSrc/src/main/kotlin/com/blamejared/searchables/gradle/DefaultPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
package com.blamejared.searchables.gradle | ||
|
||
import com.blamejared.modtemplate.Utils | ||
import groovy.namespace.QName | ||
import groovy.util.Node | ||
import groovy.util.NodeList | ||
import org.gradle.api.JavaVersion | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.plugins.BasePlugin | ||
import org.gradle.api.plugins.BasePluginExtension | ||
import org.gradle.api.plugins.JavaLibraryPlugin | ||
import org.gradle.api.plugins.JavaPluginExtension | ||
import org.gradle.api.publish.PublishingExtension | ||
import org.gradle.api.publish.maven.MavenPublication | ||
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin | ||
import org.gradle.api.publish.tasks.GenerateModuleMetadata | ||
import org.gradle.api.tasks.compile.JavaCompile | ||
import org.gradle.api.tasks.javadoc.Javadoc | ||
import org.gradle.external.javadoc.StandardJavadocDocletOptions | ||
import org.gradle.jvm.tasks.Jar | ||
import org.gradle.jvm.toolchain.JavaLanguageVersion | ||
import org.gradle.kotlin.dsl.* | ||
import org.gradle.language.jvm.tasks.ProcessResources | ||
import org.gradle.plugins.ide.idea.IdeaPlugin | ||
import org.gradle.plugins.ide.idea.model.IdeaModel | ||
import java.nio.charset.StandardCharsets | ||
import java.text.SimpleDateFormat | ||
import java.util.* | ||
|
||
class DefaultPlugin : Plugin<Project> { | ||
|
||
override fun apply(project: Project): Unit = project.run { | ||
setupDefaults(project) | ||
applyJavaPlugin(project) | ||
applyIdeaPlugin(project) | ||
applyDependencies(project) | ||
applyMavenPlugin(project) | ||
} | ||
|
||
private fun setupDefaults(project: Project) { | ||
project.plugins.apply(BasePlugin::class.java) | ||
val base = project.extensions.getByType(BasePluginExtension::class.java) | ||
|
||
base.archivesName.set("${Properties.NAME}-${project.name.toLowerCase()}-${Versions.MINECRAFT}") | ||
project.version = Utils.updatingVersion(Versions.MOD) | ||
project.group = Properties.GROUP | ||
|
||
project.tasks.withType<GenerateModuleMetadata>().all { | ||
enabled = false | ||
} | ||
|
||
project.repositories { | ||
this.add(mavenCentral()) | ||
this.add(this.maven("https://repo.spongepowered.org/repository/maven-public/") { | ||
name = "Sponge" | ||
}) | ||
this.add(this.maven("https://maven.blamejared.com/") { | ||
name = "BlameJared" | ||
}) | ||
this.add(this.maven("https://maven.parchmentmc.org/") { | ||
name = "ParchmentMC" | ||
}) | ||
} | ||
|
||
} | ||
|
||
private fun applyJavaPlugin(project: Project) { | ||
project.plugins.apply(JavaLibraryPlugin::class.java) | ||
|
||
with(project.extensions.getByType(JavaPluginExtension::class.java)) { | ||
toolchain.languageVersion.set(JavaLanguageVersion.of(JavaVersion.VERSION_17.majorVersion)) | ||
withSourcesJar() | ||
withJavadocJar() | ||
sourceSets { | ||
named("main") { | ||
resources { | ||
srcDirs.add(project.file("src/generated/resources")) | ||
} | ||
} | ||
} | ||
} | ||
|
||
project.tasks { | ||
named<JavaCompile>("compileTestJava") { | ||
this.options.isFork = true | ||
this.options.compilerArgs.add("-XDenableSunApiLintControl") | ||
} | ||
|
||
withType<JavaCompile> { | ||
this.options.encoding = StandardCharsets.UTF_8.toString() | ||
this.options.release.set(Versions.JAVA.toInt()) | ||
} | ||
|
||
withType<Javadoc> { | ||
this.options.encoding = StandardCharsets.UTF_8.toString() | ||
options { | ||
// Javadoc defines this specifically as StandardJavadocDocletOptions | ||
// but only has a getter for MinimalJavadocOptions, but let's just make sure to be safe | ||
if (this is StandardJavadocDocletOptions) { | ||
this.addStringOption("Xdoclint:none", "-quiet") | ||
} | ||
} | ||
} | ||
|
||
withType<ProcessResources> { | ||
outputs.upToDateWhen { false } | ||
inputs.property("version", project.version) | ||
filesMatching("*.mixins.json") { | ||
if (project.name == "fabric") { | ||
expand("refmap_target" to "${project.extensions.getByType(BasePluginExtension::class.java).archivesName.get()}-") | ||
} else { | ||
expand("refmap_target" to "${Properties.MODID}.") | ||
} | ||
} | ||
filesMatching("fabric.mod.json") { | ||
expand("version" to project.version) | ||
} | ||
} | ||
|
||
withType<Jar>().configureEach { | ||
manifest { | ||
attributes["Specification-Title"] = Properties.NAME | ||
attributes["Specification-Vendor"] = Properties.AUTHOR | ||
attributes["Specification-Version"] = archiveVersion | ||
attributes["Implementation-Title"] = project.name | ||
attributes["Implementation-Version"] = archiveVersion | ||
attributes["Implementation-Vendor"] = Properties.AUTHOR | ||
attributes["Implementation-Timestamp"] = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ").format(Date()) | ||
attributes["Timestamp"] = System.currentTimeMillis() | ||
attributes["Built-On-Java"] = "${System.getProperty("java.vm.version")} (${System.getProperty("java.vm.vendor")})" | ||
attributes["Built-On-Minecraft"] = Versions.MINECRAFT | ||
} | ||
} | ||
} | ||
|
||
} | ||
|
||
private fun applyDependencies(project: Project) { | ||
val implementation = project.configurations.getByName("implementation") | ||
val compileOnly = project.configurations.getByName("compileOnly") | ||
val annotationProcessor = project.configurations.getByName("annotationProcessor") | ||
|
||
implementation.dependencies.add(project.dependencies.create("com.google.code.findbugs:jsr305:3.0.2")) | ||
implementation.dependencies.add(project.dependencies.create("org.jetbrains:annotations:24.0.1")) | ||
implementation.dependencies.add(project.dependencies.create("com.google.auto.service:auto-service-annotations:1.0.1")) | ||
annotationProcessor.dependencies.add(project.dependencies.create("com.google.auto.service:auto-service:1.0.1")) | ||
} | ||
|
||
private fun applyIdeaPlugin(project: Project) { | ||
project.plugins.apply(IdeaPlugin::class.java) | ||
|
||
val idea = project.extensions.getByType<IdeaModel>() | ||
idea.module.excludeDirs.addAll(setOf(project.file("run"), project.file("run_server"), project.file("run_client"), project.file("run_game_test"))) | ||
} | ||
|
||
private fun applyMavenPlugin(project: Project) { | ||
project.plugins.apply(MavenPublishPlugin::class.java) | ||
|
||
val publishing = project.extensions.getByType<PublishingExtension>() | ||
project.afterEvaluate { | ||
val base = project.extensions.getByType<BasePluginExtension>() | ||
publishing.publications.register("mavenJava", MavenPublication::class.java) { | ||
artifactId = base.archivesName.get() | ||
from(project.components.getByName("java")) | ||
|
||
if (project.name.equals("forge")) { | ||
pom.withXml { | ||
val depNodeList = asNode()["dependencies"] as NodeList | ||
depNodeList.map { it as Node }.forEach { depList -> | ||
val deps = depList.getAt(QName("http://maven.apache.org/POM/4.0.0", "dependency")) | ||
deps.map { it as Node }.forEach { dep -> | ||
dep.parent().remove(dep) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
publishing.repositories { | ||
maven("file:///${System.getenv("local_maven")}") | ||
} | ||
} | ||
|
||
private fun common(project: Project): Project { | ||
return project.project(":common") | ||
} | ||
|
||
private fun commonJava(project: Project): JavaPluginExtension { | ||
return common(project).extensions.getByType(JavaPluginExtension::class.java) | ||
} | ||
|
||
private fun depJava(project: Project, other: String): JavaPluginExtension { | ||
return project.project(other).extensions.getByType(JavaPluginExtension::class.java) | ||
} | ||
} |
Oops, something went wrong.