Hbm-s-Nuclear-Tech-GIT/build.gradle
2026-05-31 21:00:59 +02:00

259 lines
6.4 KiB
Groovy

import org.gradle.plugins.ide.eclipse.model.internal.FileReferenceFactory
import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.StandardCopyOption
buildscript {
repositories {
maven { url = 'https://maven.ntmr.dev/proxy/' }
maven { url = 'https://maven.minecraftforge.net/' }
maven { url = 'https://plugins.gradle.org/m2' }
mavenCentral()
}
dependencies {
classpath ('com.anatawa12.forge:ForgeGradle:1.2-1.0.+') {changing = true}
}
}
apply plugin: 'forge'
apply plugin: 'curseforge'
apply plugin: 'maven-publish'
if(Files.exists(Paths.get("curseforge.properties"))) {
// Load CurseForge configuration
ext.cfprops = parseConfig(file("curseforge.properties"))
}
if(Files.exists(Paths.get("maven.properties"))) {
ext.mavenprops = parseConfig(file("maven.properties"))
}
def version_name = version = mod_version
if(!mod_build_number.isEmpty()) {
version_name = mod_version + "_X" + mod_build_number
version = "[${version_name}]"
}
group = "com.hbm" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "HBM-NTM"
compileJava.options.encoding = 'UTF-8'
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
minecraft {
version = "1.7.10-10.13.4.1614-1.7.10"
runDir = "eclipse"
}
// A little hack to fix codechicken's crazy maven structure (at least in 1.7.10)
eclipse.classpath.file.whenMerged { cp ->
// Find all codechicken source jars
def srcent = cp.entries.findAll { entry -> entry.path.contains("codechicken") && entry.path.endsWith("-src.jar") }
// Remove them from classpath
cp.entries.removeAll srcent
// Map the source entries to their dev counterparts based on basename
Map<String, File> srcmap = new HashMap<String, File>()
srcent.forEach { entry ->
def file = new File(entry.path)
srcmap.put(file.getName().replace("-src.jar", "-dev.jar"), file)
}
// Create file reference factory
def fileref = new FileReferenceFactory()
// Find all codechicken development jars
cp.entries.findAll { entry -> entry.path.contains("codechicken") && entry.path.endsWith("-dev.jar") }.forEach { entry ->
File srcmapping = new File(entry.path) // Initialize the srcmapping from the dev jar path
srcmapping = srcmap.get(srcmapping.getName()) // Transform it using the sourcemap
entry.sourcePath = fileref.fromFile(srcmapping) // Set the source path
}
}
repositories {
maven {
name = 'Blerg'
url = 'https://maven.ntmr.dev/proxy/'
}
maven {
name = 'ModMaven'
url = 'https://modmaven.dev'
}
maven {
name = "gt"
url = "https://gregtech.mechaenetia.com/"
}
//maven {
// name = "CurseForge"
// url = "https://minecraft.curseforge.com/api/maven/"
//}
maven {
name = "Jitpack"
url = "https://jitpack.io"
}
maven {
name = "CurseMaven"
url = "https://cursemaven.com"
}
maven {
name = "OpenComputers"
url = "https://maven.cil.li/"
}
}
dependencies {
implementation('codechicken:CodeChickenCore:1.7.10-1.0.4.29:dev') { transitive = false }
compileOnly('codechicken:CodeChickenCore:1.7.10-1.0.4.29:src') { transitive = false }
implementation('codechicken:CodeChickenLib:1.7.10-1.1.3.140:dev') { transitive = false }
compileOnly('codechicken:CodeChickenLib:1.7.10-1.1.3.140:src') { transitive = false }
implementation('codechicken:NotEnoughItems:1.7.10-1.0.3.74:dev') { transitive = false }
compileOnly('codechicken:NotEnoughItems:1.7.10-1.0.3.74:src') { transitive = false }
compileOnly("inventorytweaks:InventoryTweaks:1.59-dev:deobf") { transitive = false }
compileOnly("li.cil.oc:OpenComputers:MC1.7.10-1.5.+:api") { transitive = false }
compileOnly("com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta.56-GTNH:dev") { transitive = false }
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
filesMatching('mcmod.info') {
// replace version, mcversion and credits
expand([
version: version_name,
credits: project.credits
])
}
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
// add AT to meta-inf
jar {
manifest {
attributes 'FMLAT': 'HBM_at.cfg'
}
}
task sourceJar(type: Jar) {
from sourceSets.main.allJava
classifier "src"
manifest {
attributes 'FMLAT': 'HBM_at.cfg'
}
}
task devJar(type: Jar) {
from(sourceSets.main.output) {
include "**"
}
classifier "dev"
manifest {
attributes 'FMLAT': 'HBM_at.cfg'
}
}
task version {
doFirst {
println project.version
}
}
if(Files.exists(Paths.get("curseforge.properties"))) {
curse {
apiKey = cfprops.api_key
projectId = cfprops.project_id
releaseType = "release"
displayName = "Hbm's Nuclear Tech Mod " + version_name.replace("_", "") + " for Minecraft 1.7.10"
gameVersions.addAll([
"Forge",
"Java 8",
"Client", "Server"
])
if (Files.exists(Paths.get("changelog"))) {
changelog = String.join("\r\n", Files.readAllLines(Paths.get("changelog")))
// Perform a backup of the changelog and create a new file for next changes
doLast {
Files.move(Paths.get("changelog"), Paths.get("changelog.bak"), StandardCopyOption.REPLACE_EXISTING)
Files.createFile(Paths.get("changelog"))
}
}
}
}
if(Files.exists(Paths.get("maven.properties"))) {
publishing {
publications {
release(MavenPublication) {
artifactId archivesBaseName
version version_name
from components.java
artifact sourceJar {
classifier "src"
}
artifact devJar {
classifier "dev"
}
pom.withXml {
// NTM doesn't really feature any special runtime dependencies anyone would need, so blast those away
def node = asNode()
def dependencies = node.get("dependencies")
node.remove(dependencies)
node
}
}
}
repositories {
maven {
name "Nuggies"
url "https://maven.ntmr.dev/releases"
credentials {
username mavenprops.username
password mavenprops.password
}
authentication {
basic(BasicAuthentication)
}
}
}
}
}
// Properties file parsing helper
static def parseConfig(File config) {
config.withReader {
def prop = new Properties()
prop.load(it)
return (new ConfigSlurper().parse(prop))
}
}