Files
UniMixins/build.gradle
ah-OOG-ah e34254cd1e Consolidate build
Don't alter the group or artifact ID of the main module when publishing locally. Also update the NH maven so it builds.
2025-04-08 16:15:17 -04:00

151 lines
3.6 KiB
Groovy

/** The root of the build. Exposed for flexibility, but you shouldn't edit it
unless you have to. Edit project.gradle instead. */
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "https://maven.minecraftforge.net/"
}
maven {
url = "https://jitpack.io"
}
}
dependencies {
classpath 'com.github.GTNewHorizons:ForgeGradle:1.2.11'
}
}
plugins {
id 'com.github.johnrengelman.shadow' version '6.1.0' apply false
}
allprojects {
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'maven-publish'
// For some reason this is needed when using Gradle 6.9 (but not if using 4.4.1)
repositories {
mavenCentral()
mavenLocal()
maven {
name 'Overmind forge repo mirror'
url 'https://gregtech.overminddl1.com/'
}
maven {
name = "forge"
url = "https://maven.minecraftforge.net/"
}
maven {
name = 'sponge'
url = 'https://repo.spongepowered.org/maven/'
}
maven {
url = "https://mvn.falsepattern.com/releases"
}
maven {
name = "GTNH Maven"
url = "https://nexus.gtnewhorizons.com/nexus/content/groups/public/"
allowInsecureProtocol = true
}
maven {
url 'https://jitpack.io'
}
}
apply from: "${project.rootDir}/buildscript/forge-1.7.gradle"
def projectVersion = version
dependencies {
// TODO only include IFMLLoadingPlugin, Mod and ComparableVersion
compileOnly "net.minecraftforge:forge:1.12.2-14.23.5.2860:universal"
}
// The all module is published without any suffix, and to the normal group
// Other modules are published if publishAll is set, to io.github.legacymoddingmc.unimixins, with a -1.7.10 suffix
boolean publishAll = project.hasProperty("publishAll")
ext.mainModule = project.name == "module-all"
ext.publishModuleToMaven = mainModule || publishAll
ext.mavenGroupId = !mainModule ? project.group : project.group.replace(".unimixins", "")
if (project.name.startsWith("module-") && project.name != "module-mixin" && project.name != "module-common") {
if (project.name != "module-all") {
tasks.register('sourcesJar', Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
}
afterEvaluate {
if (!mainModule) {
tasks.register('devJar', Jar) {
classifier = 'dev'
def jarTask = (jar.enabled ? jar : shadowJar)
from zipTree(jarTask.getOutputs().getFiles().getSingleFile())
manifest = jarTask.manifest
dependsOn jarTask
}
}
reobf.dependsOn devJar
artifacts {
archives tasks."sourcesJar"
archives tasks."devJar"
}
if (publishModuleToMaven) {
publishing {
publications {
create("maven", MavenPublication) {
artifact jar.enabled ? jar : shadowJar
artifact source: tasks."sourcesJar", classifier: 'sources'
artifact source: tasks."devJar", classifier: 'dev'
if (mainModule)
artifactId = "unimixins"
else
artifactId = archivesBaseName.substring(1)
version = projectVersion
groupId = mavenGroupId
}
}
}
}
project.tasks.forEach {
if (it.name.startsWith("publish") && it.name.contains("PublicationTo")) {
it.dependsOn reobf
}
}
}
}
publishing {
repositories {
if (System.getenv("MAVEN_USER") != null) {
maven {
url = System.getenv("MAVEN_URL")
credentials {
username = System.getenv("MAVEN_USER") ?: "NONE"
password = System.getenv("MAVEN_PASSWORD") ?: "NONE"
}
}
}
}
}
// Put license, credits and readme in jar
delete "$projectDir/build/tmp/license"
copy {
from "$projectDir"
into "$projectDir/build/tmp/license"
include "CREDITS", "LICENSE*", "README*"
}
sourceSets.main.resources.srcDir("build/tmp/license")
}