1
0
forked from xjboss/KCauldronX
KCauldronX/build.gradle

334 lines
11 KiB
Groovy
Raw Normal View History

2015-05-26 14:16:16 +00:00
import groovy.json.JsonSlurper
2015-06-01 10:29:21 +00:00
import kcauldron.CreateChangelog
2015-06-09 04:01:23 +00:00
import kcauldron.InstallBundle
2015-06-27 12:47:27 +00:00
import kcauldron.VersionParser
2015-05-26 14:16:16 +00:00
2015-03-22 17:38:04 +00:00
buildscript {
repositories {
maven {
2015-06-22 10:00:20 +00:00
name 'prok'
url 'https://repo.prok.pw/'
2015-03-22 17:38:04 +00:00
}
maven {
2015-06-22 10:00:20 +00:00
name 'forge'
url 'http://files.minecraftforge.net/maven'
2015-03-22 17:38:04 +00:00
}
2015-06-22 10:00:20 +00:00
mavenCentral()
2015-03-22 17:38:04 +00:00
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
}
}
2015-05-26 14:16:16 +00:00
tasks.whenTaskAdded {
if (it.name.startsWith('publish')) it.dependsOn 'preparePublication'
}
2015-03-22 17:38:04 +00:00
apply plugin: 'maven'
apply plugin: 'cauldron'
2015-05-26 14:16:16 +00:00
apply plugin: 'maven-publish'
apply plugin: 'signing'
2015-03-22 17:38:04 +00:00
2015-06-22 10:00:20 +00:00
repositories {
clear()
maven {
name 'prok'
url 'https://repo.prok.pw/'
}
maven {
name 'forge'
url 'http://files.minecraftforge.net/maven'
}
maven {
name 'minecraft'
url 'https://libraries.minecraft.net/'
}
mavenCentral()
}
2015-03-22 17:38:04 +00:00
minecraft {
version = '1.7.10'
mcpVersion = '9.05'
mainClass = 'cpw.mods.fml.relauncher.ServerLaunchWrapper'
tweakClass = 'cpw.mods.fml.common.launcher.FMLTweaker'
installerVersion = "1.4"
srgExtra "PK: org/bukkit/craftbukkit org/bukkit/craftbukkit/v1_7_R4"
}
2015-05-26 14:16:16 +00:00
group = 'pw.prok'
2015-06-01 10:29:21 +00:00
ext.buildInfoCached = null;
def buildInfo(String key) {
if (!buildInfoCached) {
if (project.hasProperty('officialBuild')) {
2015-06-21 19:01:58 +00:00
buildInfoCached = new JsonSlurper().parse(new URL("https://api.prok.pw/repo/version/${group}/${name}"))
2015-06-01 10:29:21 +00:00
} else {
buildInfoCached = [
2015-06-16 16:54:22 +00:00
nextBuildNumber: 'UNOFFICIAL',
2015-06-01 10:29:21 +00:00
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(),
2015-06-01 10:29:21 +00:00
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;
2015-05-31 11:21:26 +00:00
}
2015-03-22 17:38:04 +00:00
ext.mcVersion = "1.7.10"
2015-06-27 21:35:19 +00:00
ext.forgeVersion = VersionParser.parseForgeRevision(file('src/main/resources/fmlversion.properties'))
2015-06-22 06:32:21 +00:00
ext.revision = project.hasProperty('revision') ? project.getProperty('revision') : buildInfo('nextBuildNumber')
2015-05-26 14:16:16 +00:00
version = "${mcVersion}-${forgeVersion}.${revision}"
2015-06-16 16:54:22 +00:00
if (project.hasProperty('officialBuild')) println "Updated KCauldron version: ${version}"
2015-03-22 17:38:04 +00:00
launch4j {
jreMinVersion = '1.6.0'
2015-03-22 17:38:04 +00:00
}
configurations {
compile.extendsFrom exported
libraries
bootstrap
}
dependencies {
bootstrap 'pw.prok:KBootstrap:0.1.+'
2015-06-27 12:47:27 +00:00
libraries 'net.minecraft:launchwrapper:1.12@jar'
libraries 'org.ow2.asm:asm-all:5.0.3'
libraries 'com.typesafe.akka:akka-actor_2.11:2.3.3'
libraries 'com.typesafe:config:1.2.1'
libraries 'org.scala-lang:scala-actors-migration_2.11:1.1.0'
libraries 'org.scala-lang:scala-compiler:2.11.1'
libraries 'org.scala-lang.plugins:scala-continuations-library_2.11:1.0.2'
libraries 'org.scala-lang.plugins:scala-continuations-plugin_2.11.1:1.0.2'
libraries 'org.scala-lang:scala-library:2.11.1'
libraries 'org.scala-lang:scala-parser-combinators_2.11:1.0.1'
libraries 'org.scala-lang:scala-reflect:2.11.1'
libraries 'org.scala-lang:scala-swing_2.11:1.0.1'
libraries 'org.scala-lang:scala-xml_2.11:1.0.2'
2015-06-22 10:00:20 +00:00
libraries 'net.sf.jopt-simple:jopt-simple:4.7'
libraries 'lzma:lzma:0.0.1'
libraries 'org.yaml:snakeyaml:1.9'
libraries 'commons-lang:commons-lang:2.6'
libraries 'org.avaje:ebean:2.7.3'
libraries 'jline:jline:2.6'
libraries 'net.md-5:SpecialSource:1.7-SNAPSHOT'
libraries 'net.sourceforge.argo:argo:2.25'
libraries 'org.fusesource.jansi:jansi:1.8'
libraries 'com.googlecode.json-simple:json-simple:1.1'
libraries 'org.xerial:sqlite-jdbc:3.7.2'
libraries 'mysql:mysql-connector-java:5.1.14'
libraries 'javax.persistence:persistence-api:1.0.2'
libraries 'net.minecraft:server:1.7.10'
libraries 'pw.prok:KImagine:0.2.0@jar'
libraries 'org.apache.httpcomponents:httpclient:4.4.1'
}
packageUniversal {
from { configurations.exported.collect { it.isDirectory() ? it : zipTree(it) } }
}
def String repeat(String string, int times) {
StringBuilder builder = new StringBuilder(string.length() * times)
times.times { builder.append(string) }
builder as String
}
def generateClasspath(boolean legacy = false) {
def classpath = ''
configurations.libraries.resolvedConfiguration.resolvedArtifacts.collect { it.moduleVersion.id }.each {
def jar = "${it.group.replace('.', '/')}/${it.name}/${it.version}/${it.name}-${it.version}.jar"
classpath += " ${legacy ? 'libraries/' : repeat('../', (group as String).split('\\.').length + 2)}${jar}"
}
return classpath.trim()
}
def generateManifest(boolean legacy = false) {
[
2015-06-01 10:29:21 +00:00
'KCauldron-Git-Branch' : gitInfo('branch'),
'KCauldron-Git-Hash' : gitInfo('fullHash'),
2015-06-16 16:54:22 +00:00
'KCauldron-Group' : project.group,
'KCauldron-Channel' : project.name,
2015-06-16 16:54:22 +00:00
'KCauldron-Version' : project.version,
'KCauldron-Legacy' : legacy,
2015-06-01 10:29:21 +00:00
'Implementation-Vendor' : 'Prototik',
'Implementation-Title' : project.name,
2015-06-01 10:29:21 +00:00
'Implementation-Version': project.version,
'Specification-Vendor' : 'Bukkit Team',
'Specification-Title' : 'Bukkit',
'Specification-Version' : '1.7.10-R0.1-SNAPSHOT',
2015-06-27 21:35:19 +00:00
'Forge-Version' : VersionParser.parseForgeVersion(file('forge/src/main/java/net/minecraftforge/common/ForgeVersion.java'), file('src/main/resources/fmlversion.properties')),
'TweakClass' : 'cpw.mods.fml.common.launcher.FMLTweaker',
'Main-Class' : 'cpw.mods.fml.relauncher.ServerLaunchWrapper',
'Class-Path' : generateClasspath(legacy)
]
}
tasks.packageUniversal {
classifier = 'server'
setManifest {}
manifest.attributes(generateManifest(true))
}
task jar(type: Jar, dependsOn: packageUniversal) {
destinationDir file("${buildDir}/distributions")
from zipTree(tasks.packageUniversal.archivePath)
manifest.attributes(generateManifest())
2015-03-22 17:38:04 +00:00
}
2015-05-26 14:16:16 +00:00
tasks.createChangelog.onlyIf { false }
tasks.packageInstaller.onlyIf { false }
2015-05-26 14:16:16 +00:00
2015-06-01 10:29:21 +00:00
task packageChangelog(type: CreateChangelog) {
onlyIf { project.hasProperty('officialBuild') }
classifier = 'changelog'
extension = 'txt'
2015-06-21 19:01:58 +00:00
oldChangelogUrl = "https://repo.prok.pw/${project.group.replace('.', '/')}/${project.name}/${buildInfo('version')}/${project.name}-${buildInfo('version')}-changelog.txt"
2015-06-01 10:29:21 +00:00
hash = gitInfo('hash')
message = gitInfo('message')
version = project.version
}
task bundleStub(type: Jar) {
classifier = 'stub'
manifest.attributes([
'Main-Class': 'cpw.mods.fml.relauncher.ServerLaunchWrapper',
'Class-Path': "bin/${project.group.replace('.', '/')}/${project.name}/${project.version}/${project.name}-${project.version}.jar"
])
}
2015-06-22 06:32:21 +00:00
task installBundle(type: InstallBundle, dependsOn: jar) {
serverJar tasks.jar.archivePath
bootstrapClasspath configurations.bootstrap
bootstrapMain 'pw.prok.bootstrap.Main'
2015-06-09 04:01:23 +00:00
}
task packageBundle(type: Zip, dependsOn: installBundle) {
classifier = 'bundle'
from fileTree(installBundle.installLocation)
from bundleStub
rename bundleStub.archiveName, 'KCauldron.jar'
2015-06-09 04:01:23 +00:00
}
task signJars(type: Sign, dependsOn: [packageUniversal, packageChangelog, packageBundle, jar, 'generatePomFileForMavenPublication']) {
2015-05-26 14:16:16 +00:00
sign packageUniversal
2015-06-01 10:29:21 +00:00
sign packageChangelog
2015-06-09 04:01:23 +00:00
sign packageBundle
sign jar
2015-05-26 14:16:16 +00:00
}
task signPom(type: Sign, dependsOn: 'generatePomFileForMavenPublication') {
outputs.upToDateWhen { false }
sign file("${buildDir}/publications/maven/pom-default.xml")
}
task preparePublication(dependsOn: [signJars, signPom]) {}
2015-05-26 14:16:16 +00:00
2015-06-16 16:54:22 +00:00
def getPomSignature = {
return project.tasks.signPom.signatureFiles.collect { it }[0]
}
2015-05-26 14:16:16 +00:00
def getSignatureFiles = {
def allFiles = project.tasks.signJars.signatureFiles.collect { it }
def signedServer = allFiles.find { it.name.contains('-server') }
2015-06-01 10:29:21 +00:00
def signedChangelog = allFiles.find { it.name.contains('-changelog') }
2015-06-09 04:01:23 +00:00
def signedBundle = allFiles.find { it.name.contains('-bundle') }
def signedJar = (allFiles - [signedServer, signedChangelog, signedBundle])[0]
2015-05-26 14:16:16 +00:00
return [
[archive: signedServer, classifier: 'server', extension: 'jar.asc'],
2015-06-09 04:01:23 +00:00
[archive: signedChangelog, classifier: 'changelog', extension: 'txt.asc'],
2015-06-21 19:01:58 +00:00
[archive: signedBundle, classifier: 'bundle', extension: 'zip.asc'],
[archive: signedJar, classifier: null, extension: 'jar.asc']
2015-05-26 14:16:16 +00:00
]
}
publishing {
repositories {
maven {
name 'ProK'
2015-06-21 19:01:58 +00:00
url 'https://repo.prok.pw/'
2015-06-01 10:29:21 +00:00
credentials {
2015-05-26 14:16:16 +00:00
username project.hasProperty('prokRepoUsername') ? prokRepoUsername : null
password project.hasProperty('prokRepoPassword') ? prokRepoPassword : null
}
}
}
publications {
2015-06-01 10:29:21 +00:00
maven(MavenPublication) {
2015-05-26 14:16:16 +00:00
getSignatureFiles().each { signature ->
artifact(signature.archive) {
classifier = signature.classifier
extension = signature.extension
}
}
2015-06-16 16:54:22 +00:00
artifact(getPomSignature()) {
classifier = null
extension = 'pom.asc'
}
2015-05-26 14:16:16 +00:00
artifact packageUniversal
2015-06-01 10:29:21 +00:00
artifact packageChangelog
2015-06-09 04:01:23 +00:00
artifact packageBundle
artifact jar
2015-05-26 14:16:16 +00:00
}
}
2015-05-08 09:29:14 +00:00
}
tasks.generateProjectCauldron << {
2015-06-01 10:29:21 +00:00
def file = new File('eclipse/cauldron/build.gradle')
file.append('''
repositories {
2015-06-22 10:00:20 +00:00
clear()
maven {
name 'prok'
url 'https://repo.prok.pw/'
}
maven {
name 'forge'
url 'http://files.minecraftforge.net/maven'
}
maven {
name 'minecraft'
url 'https://libraries.minecraft.net/'
}
mavenCentral()
}
dependencies {
''')
configurations.libraries.resolvedConfiguration.resolvedArtifacts.collect { it.moduleVersion.id }.each { module ->
if (['net.minecraft:server:', 'org.ow2.asm:asm-all'].findAll { (module as String).startsWith it }.size() > 0) {
return
}
file.append(" compile '${module}'\n")
2015-06-01 10:29:21 +00:00
}
file.append('}')
}
task resolveAllDependencies {
doLast {
configurations.each { it.resolve() }
}
}