232 lines
6.9 KiB
Groovy
232 lines
6.9 KiB
Groovy
buildscript {
|
|
repositories {
|
|
jcenter()
|
|
maven {
|
|
name = "forge"
|
|
url = "http://files.minecraftforge.net/maven"
|
|
}
|
|
}
|
|
dependencies {
|
|
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
|
|
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
|
|
classpath 'com.diffplug.spotless:spotless-plugin-gradle:3.10.0'
|
|
}
|
|
}
|
|
|
|
repositories {
|
|
jcenter()
|
|
flatDir {
|
|
dirs "libs"
|
|
}
|
|
}
|
|
|
|
apply plugin: 'net.minecraftforge.gradle.forge'
|
|
apply plugin: 'com.github.johnrengelman.shadow'
|
|
apply plugin: 'java'
|
|
apply plugin: 'com.diffplug.gradle.spotless'
|
|
|
|
def mcVersion = '1.12.2'
|
|
def forgeVersion = '14.23.4.2705'
|
|
def modVersion = '3.0.5'
|
|
|
|
def jdaVersion = '3.6.0'
|
|
def jdaJob = 354
|
|
|
|
def downloadDir = "${buildDir}/download/"
|
|
|
|
version = 'mc' + mcVersion + '-' + modVersion
|
|
group = "chikachi.discord"
|
|
archivesBaseName = "DiscordIntegration"
|
|
|
|
sourceCompatibility = 1.8
|
|
targetCompatibility = 1.8
|
|
|
|
sourceSets {
|
|
main {
|
|
java {
|
|
srcDir 'src/main/java'
|
|
srcDir 'src/main/resources'
|
|
srcDir 'core/src/main/java'
|
|
}
|
|
resources {
|
|
srcDir 'core/src/main/resources'
|
|
}
|
|
}
|
|
test {
|
|
java {
|
|
srcDir 'core/src/test/java'
|
|
}
|
|
}
|
|
}
|
|
|
|
minecraft {
|
|
version = mcVersion + '-' + forgeVersion
|
|
|
|
if (file('../run').exists()) {
|
|
runDir = '../run'
|
|
} else {
|
|
runDir = 'run'
|
|
}
|
|
|
|
mappings = "snapshot_20180317"
|
|
}
|
|
|
|
def printDebug(message) {
|
|
println '[' + archivesBaseName + '] ' + message
|
|
}
|
|
|
|
/*
|
|
* Copyright (C) 2017 Chikachi
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
* License, or (at your option) any later version.
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see http://www.gnu.org/licenses.
|
|
*/
|
|
|
|
class CurseForgeDependencyInfo {
|
|
public String module, version, ext
|
|
private String fileid
|
|
|
|
CurseForgeDependencyInfo(String module, String version, String ext, String fileid) {
|
|
this.module = module
|
|
this.version = version
|
|
this.ext = ext
|
|
this.fileid = fileid
|
|
}
|
|
|
|
String GetFileId() {
|
|
return Integer.parseInt(fileid.substring(0, 4)) + "/" + Integer.parseInt(fileid.substring(4))
|
|
}
|
|
}
|
|
|
|
def CurseForgeDependencyDownloader = { dependencyInfo ->
|
|
String url = "https://media.forgecdn.net/files/${dependencyInfo.GetFileId()}/${dependencyInfo.module}-${dependencyInfo.version}.${dependencyInfo.ext}"
|
|
File file = new File("${downloadDir}/${dependencyInfo.module}-${dependencyInfo.version}.${dependencyInfo.ext}")
|
|
file.parentFile.mkdirs()
|
|
if (!file.exists()) {
|
|
printDebug "Download ${url}"
|
|
new URL(url).withInputStream { downloadStream ->
|
|
file.withOutputStream { fileOut ->
|
|
fileOut << downloadStream
|
|
}
|
|
}
|
|
}
|
|
files(file.absolutePath)
|
|
}
|
|
|
|
def JDADependencyDownloader = {
|
|
String url = "http://home.dv8tion.net:8080/job/JDA/${jdaJob}/artifact/build/libs/JDA-${jdaVersion}_${jdaJob}-withDependencies.jar"
|
|
File file = new File("${downloadDir}/JDA-${jdaVersion}_${jdaJob}-withDependencies.jar")
|
|
file.parentFile.mkdirs()
|
|
if (!file.exists()) {
|
|
printDebug "Download ${url}"
|
|
new URL(url).withInputStream { downloadStream ->
|
|
file.withOutputStream { fileOut ->
|
|
fileOut << downloadStream
|
|
}
|
|
}
|
|
}
|
|
files(file.absolutePath)
|
|
}
|
|
|
|
// Dependencies on CurseForge
|
|
List<CurseForgeDependencyInfo> curseForgeDependencies = new ArrayList<CurseForgeDependencyInfo>()
|
|
curseForgeDependencies.add(new CurseForgeDependencyInfo("Dynmap", "2.6-beta-1-forge-1.12", "jar", "2436596"))
|
|
|
|
dependencies {
|
|
compile JDADependencyDownloader()
|
|
compile 'com.vdurmont:emoji-java:4.0.0'
|
|
|
|
// CurseForge
|
|
for (CurseForgeDependencyInfo dependency : curseForgeDependencies) {
|
|
if (file('../' + dependency.module).exists()) {
|
|
printDebug 'Using local ' + dependency.module + ' project'
|
|
compile project(':' + dependency.module)
|
|
continue
|
|
}
|
|
if (file('./' + dependency.module + '.jar').exists()) {
|
|
printDebug 'Using local ' + dependency.module + ' compiled jar'
|
|
compile files('./' + dependency.module + '.jar')
|
|
continue
|
|
}
|
|
provided CurseForgeDependencyDownloader(dependency)
|
|
}
|
|
|
|
// IntelliJ
|
|
compile 'org.jetbrains:annotations:15.0'
|
|
|
|
testCompile 'junit:junit:4.12'
|
|
testCompile 'org.mockito:mockito-core:2.+'
|
|
}
|
|
|
|
shadowJar {
|
|
classifier = ""
|
|
relocate "com.mashape.unirest", "chikachi.discord.repack.com.mashape.unirest"
|
|
relocate "com.neovisionaries.ws.client", "chikachi.discord.repack.com.neovisionaries.ws.client"
|
|
relocate "com.sun.jna", "chikachi.discord.repack.com.sun.jna"
|
|
relocate "com.vdurmont.emoji", "chikachi.discord.repack.com.vdurmont.emoji"
|
|
relocate "javax.sound", "chikachi.discord.repack.javax.sound"
|
|
relocate "javazoom", "chikachi.discord.repack.javazoom"
|
|
relocate "net.dv8tion.jda", "chikachi.discord.repack.net.dv8tion.jda"
|
|
relocate "net.sourceforge.jaad", "chikachi.discord.repack.net.sourceforge.jaad"
|
|
relocate "org.apache.commons.codec", "chikachi.discord.repack.org.apache.commons.codec"
|
|
relocate "org.apache.commons.collections4", "chikachi.discord.repack.org.apache.commons.collections4"
|
|
relocate "org.json", "chikachi.discord.repack.org.json"
|
|
relocate "org.kc7bfi.jflac", "chikachi.discord.repack.orgkc7bfi.jflac"
|
|
relocate "org.slf4j", "chikachi.discord.repack.org.slf4j"
|
|
relocate "org.tritonus", "chikachi.discord.repack.org.tritonus"
|
|
relocate "tomp2p.opuswrapper", "chikachi.discord.repack.tomp2p.opuswrapper"
|
|
|
|
relocate "org.apache.http", "chikachi.discord.repack.org.apache.http"
|
|
relocate "org.apache.commons.logging", "chikachi.discord.repack.org.apache.commons.logging"
|
|
|
|
dependencies {
|
|
include(dependency("net.dv8tion:JDA:${jdaVersion}_${jdaJob}:withDependencies"))
|
|
include(dependency('com.vdurmont:emoji-java:4.0.0'))
|
|
}
|
|
}
|
|
|
|
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': modVersion, 'mcversion': project.minecraft.version
|
|
}
|
|
|
|
// copy everything else, that's not the mcmod.info
|
|
from(sourceSets.main.resources.srcDirs) {
|
|
exclude 'mcmod.info'
|
|
}
|
|
}
|
|
|
|
test {
|
|
useJUnit()
|
|
}
|
|
|
|
spotless {
|
|
java {
|
|
encoding 'UTF-8'
|
|
removeUnusedImports()
|
|
trimTrailingWhitespace()
|
|
indentWithSpaces(4)
|
|
endWithNewline()
|
|
}
|
|
}
|
|
|
|
reobf { shadowJar { mappingType = "SEARGE" } }
|
|
tasks.reobfShadowJar.mustRunAfter shadowJar
|
|
|
|
idea { module { inheritOutputDirs = true } }
|