294 lines
8.9 KiB
Groovy
Executable File
294 lines
8.9 KiB
Groovy
Executable File
import groovy.json.JsonOutput
|
|
|
|
buildscript {
|
|
repositories {
|
|
mavenCentral()
|
|
maven {
|
|
name = "forge"
|
|
url = "http://files.minecraftforge.net/maven"
|
|
}
|
|
maven {
|
|
name = "sponge"
|
|
url = "https://repo.spongepowered.org/maven"
|
|
}
|
|
maven {
|
|
name = "sonatype"
|
|
url = "https://oss.sonatype.org/content/repositories/snapshots/"
|
|
}
|
|
}
|
|
dependencies {
|
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT'
|
|
classpath 'org.spongepowered:mixingradle:0.3-SNAPSHOT'
|
|
}
|
|
}
|
|
|
|
apply plugin: 'net.minecraftforge.gradle.forge'
|
|
apply plugin: 'org.spongepowered.mixin'
|
|
|
|
sourceCompatibility = 1.8
|
|
targetCompatibility = 1.8
|
|
|
|
version = gitDescribe()
|
|
group= "com.replaymod"
|
|
archivesBaseName = "replaymod"
|
|
|
|
minecraft {
|
|
coreMod = 'com.replaymod.core.LoadingPlugin'
|
|
version = '1.8-11.14.4.1563'
|
|
runDir = "eclipse"
|
|
mappings = "snapshot_nodoc_20141130"
|
|
replace '@MOD_VERSION@', project.version
|
|
// Includes intentional whitespace to stop Forge from declaring the mod to be compatible with
|
|
// a newer srg-compatible MC version (that may be using a different protocol version)
|
|
replace '@MC_VERSION@', "[ ${project.minecraft.version} ]"
|
|
}
|
|
|
|
repositories {
|
|
maven {
|
|
name = "SpongePowered Repo"
|
|
url = "http://repo.spongepowered.org/maven/"
|
|
}
|
|
maven {
|
|
url 'https://repo.spacehq.org/content/repositories/snapshots/'
|
|
}
|
|
}
|
|
|
|
configurations {
|
|
shade
|
|
compile.extendsFrom shade
|
|
}
|
|
|
|
dependencies {
|
|
compile 'org.projectlombok:lombok:1.16.4'
|
|
|
|
compile 'org.spongepowered:mixin:0.7.5-SNAPSHOT'
|
|
shade 'com.googlecode.mp4parser:isoparser:1.1.7'
|
|
shade 'org.apache.commons:commons-exec:1.3'
|
|
shade 'com.google.apis:google-api-services-youtube:v3-rev178-1.22.0'
|
|
shade 'com.google.api-client:google-api-client-gson:1.20.0'
|
|
shade 'com.google.api-client:google-api-client-java6:1.20.0'
|
|
shade 'com.google.oauth-client:google-oauth-client-jetty:1.20.0'
|
|
|
|
shade 'org.aspectj:aspectjrt:1.8.2'
|
|
|
|
compile project(':ReplayStudio')
|
|
|
|
testCompile 'junit:junit:4.11'
|
|
}
|
|
|
|
tasks['idea'].dependsOn ':ReplayStudio:preshadowJar'
|
|
|
|
jar {
|
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
|
|
|
dependsOn configurations.compile
|
|
dependsOn configurations.shade
|
|
dependsOn ':ReplayStudio:shadowJar'
|
|
|
|
def shade = {files(
|
|
configurations.compile.findAll {it.name.startsWith 'mixin-'}
|
|
+ configurations.shade
|
|
+ getTasks().getByPath(':ReplayStudio:shadowJar').outputs.files
|
|
)}
|
|
|
|
def noticeDir = file("$buildDir/NOTICE")
|
|
doFirst {
|
|
noticeDir.deleteDir()
|
|
noticeDir.mkdirs()
|
|
shade().collect { it.isDirectory() ? fileTree(it) : zipTree(it) }.each {
|
|
it.matching { include '**/NOTICE*' }.each {
|
|
new File(noticeDir, 'NOTICE.txt') << it.getText('UTF-8') + '\n'
|
|
}
|
|
}
|
|
}
|
|
from noticeDir
|
|
|
|
from ({shade().collect { it.isDirectory() ? it : zipTree(it) }}) {
|
|
exclude '**/NOTICE*'
|
|
// exclude everything taken in from jGui for running the mod in a dev environment
|
|
exclude { new File(file('jGui/src/main/resources'), it.relativePath.pathString).exists() }
|
|
eachFile {
|
|
if (getName() == 'LICENSE.txt') {
|
|
setName(getFile().getParentFile().getName().split('-')[0] + '-LICENSE.txt')
|
|
}
|
|
}
|
|
}
|
|
|
|
manifest {
|
|
attributes 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker',
|
|
'TweakOrder': '0',
|
|
'FMLAT': 'replaymod_at.cfg'
|
|
}
|
|
}
|
|
|
|
def gitDescribe() {
|
|
try {
|
|
def stdout = new ByteArrayOutputStream()
|
|
exec {
|
|
commandLine 'git', 'describe', '--always', '--dirty=*'
|
|
standardOutput = stdout
|
|
}
|
|
return stdout.toString().trim()
|
|
} catch (e) {
|
|
return "unknown"
|
|
}
|
|
}
|
|
|
|
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
|
|
expand 'version': project.version, 'mcversion': project.minecraft.version
|
|
}
|
|
|
|
// copy everything else, thats not the mcmod.info
|
|
from(sourceSets.main.resources.srcDirs) {
|
|
exclude 'mcmod.info'
|
|
}
|
|
}
|
|
|
|
sourceSets {
|
|
main {
|
|
// Directly include jGui into main build
|
|
// This could also be done by including it as a gradle subproject, however
|
|
// doing so caused classpath issues on some IntelliJ versions.
|
|
java {
|
|
srcDir 'jGui/src/main/java'
|
|
}
|
|
resources {
|
|
srcDir 'jGui/src/main/resources'
|
|
}
|
|
refMap = "mixins.replaymod.refmap.json"
|
|
}
|
|
integrationTest {
|
|
compileClasspath += main.runtimeClasspath + main.output
|
|
java {
|
|
srcDir file('src/integration-test/java')
|
|
}
|
|
resources.srcDir file('src/integration-test/resources')
|
|
}
|
|
}
|
|
|
|
task copySrg(type: Copy, dependsOn: 'genSrgs') {
|
|
from {project.tasks.genSrgs.mcpToSrg}
|
|
into 'build'
|
|
}
|
|
|
|
setupDecompWorkspace.dependsOn copySrg
|
|
setupDevWorkspace.dependsOn copySrg
|
|
project.tasks.idea.dependsOn copySrg
|
|
|
|
task runIntegrationTest(type: JavaExec, dependsOn: ["makeStart", "jar"]) {
|
|
main = 'GradleStart'
|
|
standardOutput = System.out
|
|
errorOutput = System.err
|
|
workingDir file(minecraft.runDir)
|
|
|
|
def testDir = new File(minecraft.runDir, "integration-test")
|
|
doFirst {
|
|
testDir.deleteDir()
|
|
testDir.mkdirs()
|
|
}
|
|
|
|
doLast {
|
|
testDir.deleteDir()
|
|
}
|
|
|
|
afterEvaluate {
|
|
def runClient = tasks.getByName("runClient")
|
|
runIntegrationTest.jvmArgs = runClient.jvmArgs + "-Dfml.noGrab=true"
|
|
runIntegrationTest.args = runClient.args + "--gameDir" + testDir.canonicalPath
|
|
runIntegrationTest.classpath runClient.classpath + sourceSets.integrationTest.output
|
|
}
|
|
}
|
|
|
|
def generateVersionsJson() {
|
|
// List all tags
|
|
def stdout = new ByteArrayOutputStream()
|
|
project.exec {
|
|
commandLine 'git', 'for-each-ref', '--sort=taggerdate', '--format=%(refname:short)', 'refs/tags'
|
|
standardOutput = stdout
|
|
}
|
|
def versions = stdout.toString().tokenize('\n').reverse()
|
|
def mcVersions = versions.collect {it.substring(0, it.indexOf('-'))}.unique().reverse()
|
|
|
|
def root = [
|
|
homepage: 'https://www.replaymod.com/download/',
|
|
promos: [:]
|
|
]
|
|
mcVersions.forEach { mcVersion ->
|
|
def mcVersionRoot = [:]
|
|
def latest
|
|
def recommended
|
|
versions.forEach {
|
|
def (thisMcVersion, modVersion, preVersion) = it.tokenize('-')
|
|
if (thisMcVersion == mcVersion) {
|
|
mcVersionRoot[it] = "See https://github.com/ReplayMod/ReplayMod/releases/$it"
|
|
if (latest == null) latest = it
|
|
if (preVersion == null) {
|
|
if (recommended == null) recommended = it
|
|
}
|
|
}
|
|
}
|
|
root[mcVersion] = mcVersionRoot
|
|
root.promos[mcVersion + '-latest'] = latest
|
|
if (recommended != null) {
|
|
root.promos[mcVersion + '-recommended'] = recommended
|
|
}
|
|
}
|
|
root
|
|
}
|
|
|
|
task doRelease() {
|
|
doLast {
|
|
// Parse version
|
|
def version = project.releaseVersion as String
|
|
if (project.version.endsWith('*')) {
|
|
throw new InvalidUserDataException('Git working tree is dirty. Make sure to commit all changes.')
|
|
}
|
|
def (mcVersion, modVersion, preVersion) = version.tokenize('-')
|
|
preVersion = preVersion != null && preVersion.startsWith('b') ? preVersion.substring(1) : null
|
|
|
|
// Create new tag
|
|
if (preVersion != null) {
|
|
project.exec {
|
|
commandLine 'git', 'tag',
|
|
'-m', "Pre-release $preVersion of $modVersion for Minecraft $mcVersion",
|
|
"$mcVersion-$modVersion-b$preVersion"
|
|
}
|
|
} else {
|
|
project.exec {
|
|
commandLine 'git', 'tag',
|
|
'-m', "Release $modVersion for Minecraft $mcVersion",
|
|
"$mcVersion-$modVersion"
|
|
}
|
|
}
|
|
|
|
// Switch to master branch to update versions.json
|
|
project.exec { commandLine 'git', 'checkout', 'master' }
|
|
|
|
// Generate versions.json content
|
|
def versionsRoot = generateVersionsJson()
|
|
def versionsJson = JsonOutput.prettyPrint(JsonOutput.toJson(versionsRoot))
|
|
|
|
// Write versions.json
|
|
new File('versions.json').write(versionsJson)
|
|
|
|
// Commit changes
|
|
project.exec { commandLine 'git', 'add', 'versions.json' }
|
|
project.exec { commandLine 'git', 'commit', '-m', "Update versions.json for $version" }
|
|
|
|
// Return to previous branch
|
|
project.exec { commandLine 'git', 'checkout', '-' }
|
|
}
|
|
}
|
|
|
|
defaultTasks 'build'
|