1
0
forked from xjboss/KCauldronX
KCauldronX/build.gradle
2015-06-09 11:01:23 +07:00

229 lines
6.7 KiB
Groovy

import groovy.json.JsonSlurper
import kcauldron.CreateChangelog
import kcauldron.InstallBundle
buildscript {
repositories {
mavenCentral()
mavenLocal()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
}
}
tasks.whenTaskAdded {
if (it.name.startsWith('publish')) it.dependsOn 'preparePublication'
}
apply plugin: 'maven'
apply plugin: 'cauldron'
apply plugin: 'maven-publish'
apply plugin: 'signing'
minecraft {
version = '1.7.10'
mcpVersion = '9.05'
mainClass = 'cpw.mods.fml.relauncher.ServerLaunchWrapper'
tweakClass = 'cpw.mods.fml.common.launcher.FMLTweaker'
installerVersion = "1.4"
subprojects {
repositories {
mavenCentral()
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
}
srgExtra "PK: org/bukkit/craftbukkit org/bukkit/craftbukkit/v1_7_R4"
}
group = 'pw.prok'
ext.buildInfoCached = null;
def buildInfo(String key) {
if (!buildInfoCached) {
if (project.hasProperty('officialBuild')) {
buildInfoCached = new JsonSlurper().parse(new URL("https://prok.pw/version/${group}/${name}"))
} else {
buildInfoCached = [
nextBuildNumber: 'UNOFFICIAL.' + gitInfo('hash'),
version : 'NONE'
]
}
}
return key ? buildInfoCached[key] : buildInfoCached;
}
ext.gitInfoCached = null;
def gitInfo(String key) {
if (!gitInfoCached) {
if (file('.git').exists()) {
gitInfoCached = [
hash : ['git', 'log', "--format=%h", '-n', '1'].execute().text.trim(),
fullHash: ['git', 'log', "--format=%H", '-n', '1'].execute().text.trim(),
branch : System.getenv("CI_BUILD_REF_NAME") ?: ['git', 'symbolic-ref', '--short', 'HEAD'].execute().text.trim(),
message : ['git', 'log', "--format=%B", '-n', '1'].execute().text.trim()
]
} else {
gitInfoCached = [
hash : 'NOT_A_GIT',
fullHash: 'NOT_A_GIT',
branch : 'NOT_A_GIT',
message : 'NOT_A_GIT'
]
}
}
return key ? gitInfoCached[key] : gitInfoCached;
}
ext.mcVersion = "1.7.10"
ext.forgeVersion = "1420"
ext.revision = buildInfo('nextBuildNumber')
version = "${mcVersion}-${forgeVersion}.${revision}"
println "Updated KCauldron version: ${version}"
launch4j {
jreMinVersion = '1.6.0'
}
tasks.packageUniversal {
classifier = 'server'
manifest.attributes([
'KCauldron-Git-Branch' : gitInfo('branch'),
'KCauldron-Git-Hash' : gitInfo('fullHash'),
'KCauldron-Version' : project.version,
'KCauldron-Channel' : project.name,
'Implementation-Vendor' : 'Prototik',
'Implementation-Title' : project.name,
'Implementation-Version': project.version,
'Forge-Version' : '10.13.3.1420',
'Specification-Vendor' : 'Bukkit Team',
'Specification-Title' : 'Bukkit',
'Specification-Version' : '1.7.10-R0.1-SNAPSHOT'
])
}
tasks.createChangelog.onlyIf { false }
task packageChangelog(type: CreateChangelog) {
onlyIf { project.hasProperty('officialBuild') }
classifier = 'changelog'
extension = 'txt'
oldChangelogUrl = "https://prok.pw/repo/${project.group.replace('.','/')}/${project.name}/${buildInfo('version')}/${project.name}-${buildInfo('version')}-changelog.txt"
hash = gitInfo('hash')
message = gitInfo('message')
version = project.version
}
task installBundle(type: InstallBundle, dependsOn: packageInstaller) {
installer packageInstaller.archivePath
}
task packageBundle(type: Zip, dependsOn: installBundle) {
onlyIf { project.hasProperty('officialBuild') }
classifier = 'bundle'
from packageInstaller
from packageUniversal
from fileTree(installBundle.installLocation, {
include 'libraries/**'
include 'minecraft_server.*.jar'
})
}
task signJars(type: Sign, dependsOn: [packageUniversal, packageInstaller, packageChangelog, packageBundle]) {
sign packageInstaller
sign packageUniversal
sign packageChangelog
sign packageBundle
}
task preparePublication(dependsOn: signJars) {}
def getSignatureFiles = {
def allFiles = project.tasks.signJars.signatureFiles.collect { it }
def signedServer = allFiles.find { it.name.contains('-server') }
def signedInstaller = allFiles.find { it.name.contains('-installer') }
def signedChangelog = allFiles.find { it.name.contains('-changelog') }
def signedBundle = allFiles.find { it.name.contains('-bundle') }
return [
[archive: signedServer, classifier: 'server', extension: 'jar.asc'],
[archive: signedInstaller, classifier: 'installer', extension: 'jar.asc'],
[archive: signedChangelog, classifier: 'changelog', extension: 'txt.asc'],
[archive: signedBundle, classifier: 'bundle', extension: 'jar.asc']
]
}
publishing {
repositories {
maven {
name 'ProK'
url 'https://prok.pw/repo/'
credentials {
username project.hasProperty('prokRepoUsername') ? prokRepoUsername : null
password project.hasProperty('prokRepoPassword') ? prokRepoPassword : null
}
}
}
publications {
maven(MavenPublication) {
getSignatureFiles().each { signature ->
artifact(signature.archive) {
classifier = signature.classifier
extension = signature.extension
}
}
artifact packageUniversal
artifact packageInstaller
artifact packageChangelog
artifact packageBundle
}
}
}
tasks.generateProjectCauldron << {
def file = new File('eclipse/cauldron/build.gradle')
file.append('''
repositories {
maven {
url 'https://prok.pw/repo'
}
}
dependencies {
compile 'pw.prok:KImagine:0.1.12+@jar'
compile 'org.apache.httpcomponents:httpclient:4.4.1'
}
''')
}
configurations {
compile.extendsFrom exported
}
repositories {
maven {
url 'https://prok.pw/repo'
}
}
dependencies {
exported 'pw.prok:KImagine:0.1.12+@jar'
exported 'org.apache.httpcomponents:httpclient:4.4.1'
}
packageUniversal {
from { configurations.exported.collect { it.isDirectory() ? it : zipTree(it) } }
}