CarryOn/build.gradle
2020-09-06 17:12:05 +02:00

203 lines
5.3 KiB
Groovy

buildscript {
repositories {
maven { url = 'https://files.minecraftforge.net/maven' }
jcenter()
mavenCentral()
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
}
}
apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/22e7d543a18cd30675277fbfa3669e3d9e206010/generic/secrets.gradle'
import net.minecraftforge.gradle.common.task.SignJar
import groovy.json.JsonSlurper
import groovy.json.JsonOutput
if (project.hasProperty('secretFile')) {
loadSecrets(new File((String) findProperty('secretFile')))
}
version = "${version}"
group = "tschipp.carryon"
archivesBaseName = "carryon-${minecraft_version}"
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
if (System.getenv('BUILD_NUMBER') != null) {
version += "." + System.getenv('BUILD_NUMBER')
}
minecraft {
mappings channel: 'snapshot', version: "${mcp_mappings}"
runs {
client {
workingDirectory project.file('run')
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
mods {
carryon {
source sourceSets.main
}
}
}
server {
workingDirectory project.file('run')
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
mods {
carryon {
source sourceSets.main
}
}
}
data {
workingDirectory project.file('run')
property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
args '--mod', 'carryon', '--all', '--output', file('src/generated/resources/')
mods {
carryon {
source sourceSets.main
}
}
}
}
}
repositories {
maven {
url "https://maven.blamejared.com/"
}
}
dependencies {
minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}"
}
// Example for how to get properties into the manifest for reading by the runtime..
jar {
manifest {
attributes([
"Specification-Title": "carryon",
"Specification-Vendor": "Carry On",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"Carry On",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
jar.finalizedBy('reobfJar')
task sourcesJar(type: Jar, dependsOn: classes) {
description = 'Creates a JAR containing the source code.'
from sourceSets.main.allSource
classifier = 'sources'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
description = 'Creates a JAR containing the JavaDocs.'
from javadoc.destinationDir
classifier = 'javadoc'
}
task deobfJar(type: Jar) {
description = 'Creates a JAR containing the non-obfuscated compiled code.'
from sourceSets.main.output
classifier = "deobf"
}
artifacts {
archives sourcesJar
archives javadocJar
archives deobfJar
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version project.version
from components.java
// Allows the maven pom file to be modified.
pom.withXml {
// Go through all the dependencies.
asNode().dependencies.dependency.each { dep ->
println 'Surpressing artifact ' + dep.artifactId.last().value().last() + ' from maven dependencies.'
assert dep.parent().remove(dep)
}
}
artifact sourcesJar {
classifier 'sources'
}
artifact javadocJar {
classifier 'javadoc'
}
artifact deobfJar {
classifier 'deobf'
}
}
}
repositories {
maven {
url "file://" + System.getenv("local_maven")
}
}
}
task signJar(type: SignJar, dependsOn: jar) {
// Skips if the keyStore property is missing.
onlyIf {
project.hasProperty('modkeyStore')
}
// findProperty allows us to reference the property without it existing.
// Using project.propName would cause the script to fail validation if
// the property did not exist.
keyStore = project.findProperty('modkeyStore')
alias = project.findProperty('modkeyStoreAlias')
storePass = project.findProperty('modkeyStorePass')
keyPass = project.findProperty('modkeyStoreKeyPass')
inputFile = jar.archivePath
outputFile = jar.archivePath
}
// Runs this task automatically when build is ran.
build.dependsOn signJar