2021-04-05 15:47:34 +02:00
|
|
|
import org.apache.http.HttpEntity
|
|
|
|
import org.apache.http.client.methods.CloseableHttpResponse
|
|
|
|
import org.apache.http.client.methods.HttpPost
|
|
|
|
import org.apache.http.entity.ContentType
|
|
|
|
import org.apache.http.entity.mime.MultipartEntityBuilder
|
|
|
|
import org.apache.http.impl.client.CloseableHttpClient
|
|
|
|
import org.apache.http.impl.client.HttpClients
|
|
|
|
|
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
maven {url "https://plugins.gradle.org/m2/"}
|
|
|
|
mavenCentral()
|
|
|
|
mavenLocal()
|
|
|
|
}
|
|
|
|
dependencies {
|
|
|
|
classpath "org.apache.httpcomponents:httpmime:4.5.13"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
id "com.matthewprenger.cursegradle" version "1.4.0"
|
|
|
|
}
|
|
|
|
|
2018-07-23 02:43:29 +02:00
|
|
|
apply plugin: 'java'
|
2019-12-30 16:18:14 +01:00
|
|
|
apply plugin: 'maven-publish'
|
2018-07-23 02:43:29 +02:00
|
|
|
apply plugin: 'idea'
|
|
|
|
apply plugin: 'eclipse'
|
|
|
|
|
2021-04-05 15:47:34 +02:00
|
|
|
def branch = System.getenv("GITHUB_REF");
|
|
|
|
def sha = System.getenv("GITHUB_SHA");
|
2021-05-09 04:45:31 +02:00
|
|
|
def isDevBranch = branch == null || (!(branch.startsWith("refs/heads/release/") || branch.startsWith("refs/tags/")))
|
2021-04-05 15:47:34 +02:00
|
|
|
|
2021-04-05 16:07:56 +02:00
|
|
|
group = 'com.sekwah.advancedportals'
|
2021-05-05 03:14:25 +02:00
|
|
|
version = getPluginData("version") + (isDevBranch ? '-SNAPSHOT' : '')
|
2021-04-05 16:07:56 +02:00
|
|
|
|
2018-07-23 02:43:29 +02:00
|
|
|
description = ""
|
|
|
|
|
|
|
|
sourceCompatibility = 1.8
|
|
|
|
targetCompatibility = 1.8
|
|
|
|
|
|
|
|
tasks.withType(JavaCompile) {
|
|
|
|
options.encoding = 'UTF-8'
|
|
|
|
}
|
|
|
|
|
2019-05-31 05:04:33 +02:00
|
|
|
String getPluginData(String tag) {
|
2019-08-12 10:40:06 +02:00
|
|
|
File file = file("src/main/resources/plugin.yml")
|
2019-05-31 05:04:33 +02:00
|
|
|
String version = "notfound"
|
|
|
|
file.readLines("UTF-8").each {String line ->
|
|
|
|
line = line.trim()
|
|
|
|
if(line.startsWith(tag)) {
|
|
|
|
version = line.substring(tag.length() + 2, line.length())
|
|
|
|
}
|
|
|
|
}
|
2019-06-02 05:39:08 +02:00
|
|
|
println "Advanced Portals v" + version
|
2019-05-31 05:04:33 +02:00
|
|
|
return version
|
|
|
|
}
|
|
|
|
|
2018-07-23 02:43:29 +02:00
|
|
|
configurations {
|
|
|
|
// configuration that holds jars to copy into lib
|
|
|
|
includeLibs
|
|
|
|
}
|
|
|
|
|
|
|
|
repositories {
|
2020-01-20 11:55:18 +01:00
|
|
|
maven { url "https://repo.maven.apache.org/maven2" }
|
2018-07-23 02:43:29 +02:00
|
|
|
maven { url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" }
|
2020-01-20 11:55:18 +01:00
|
|
|
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
|
2020-12-30 03:49:45 +01:00
|
|
|
maven { url "https://nexus.velocitypowered.com/repository/maven-public/" }
|
2021-05-09 04:45:31 +02:00
|
|
|
maven { url 'https://papermc.io/repo/repository/maven-public/' }
|
2018-07-23 02:43:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// includeLibs just says to include the library in the final jar
|
|
|
|
dependencies {
|
2020-06-26 01:42:39 +02:00
|
|
|
//implementation "org.bukkit:bukkit:1.16.1-R0.1-SNAPSHOT"
|
|
|
|
implementation "org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT"
|
2020-01-20 11:55:18 +01:00
|
|
|
implementation "net.md-5:bungeecord-api:1.15-SNAPSHOT"
|
|
|
|
|
2020-12-30 03:49:45 +01:00
|
|
|
implementation "com.velocitypowered:velocity-api:1.1.0-SNAPSHOT"
|
|
|
|
annotationProcessor "com.velocitypowered:velocity-api:1.1.0-SNAPSHOT"
|
|
|
|
|
2019-12-30 16:18:14 +01:00
|
|
|
implementation "io.netty:netty-all:4.0.4.Final"
|
2021-05-09 04:45:31 +02:00
|
|
|
compileOnly 'com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT'
|
2020-06-21 03:49:18 +02:00
|
|
|
|
|
|
|
//compile fileTree(dir: 'libs', include: ['*.jar'])
|
2018-07-23 02:43:29 +02:00
|
|
|
}
|
|
|
|
|
2021-04-05 15:47:34 +02:00
|
|
|
/** For pre-releases and testers to be able to try the latest commits if they want.
|
|
|
|
* If the builds start exceeding 8MB then we may want to upload to s3 instead and periodically clear.
|
|
|
|
* TODO possibly add a task that announces when builds are made?
|
|
|
|
* Though add a note that it may take a while for Curse to approve the files.
|
|
|
|
*/
|
|
|
|
task discordupload {
|
|
|
|
dependsOn(jar)
|
|
|
|
doLast {
|
|
|
|
String discordWebhook = System.getenv("DISCORD_WEBHOOK")
|
|
|
|
|
|
|
|
if(discordWebhook != null) {
|
|
|
|
println("Logging Into Discord")
|
|
|
|
|
|
|
|
CloseableHttpClient httpClient = HttpClients.createDefault()
|
|
|
|
HttpPost uploadFile = new HttpPost(discordWebhook)
|
|
|
|
|
|
|
|
MultipartEntityBuilder builder = MultipartEntityBuilder.create()
|
|
|
|
builder.addTextBody("content", "New automated dev build\n\n" +
|
|
|
|
"Current Features: <${project.github}/blob/${sha}/CHANGELOG.md>")
|
|
|
|
|
|
|
|
builder.addBinaryBody("file", file(jar.archiveFile).newInputStream(), ContentType.APPLICATION_OCTET_STREAM, jar.archiveName)
|
|
|
|
|
|
|
|
HttpEntity multipart = builder.build()
|
|
|
|
|
|
|
|
uploadFile.setEntity(multipart)
|
|
|
|
CloseableHttpResponse response = httpClient.execute(uploadFile)
|
|
|
|
response.getEntity()
|
|
|
|
|
|
|
|
println("Posted build")
|
|
|
|
|
|
|
|
} else {
|
|
|
|
println("Discord webhook unspecified")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.curseforge.enabled = System.getenv("CURSE_API") != null
|
|
|
|
|
|
|
|
curseforge {
|
|
|
|
logger.info("Curse api: " + System.getenv("CURSE_API"))
|
|
|
|
if (System.getenv("CURSE_API") != null) {
|
|
|
|
apiKey = System.getenv("CURSE_API")
|
|
|
|
}
|
|
|
|
project {
|
|
|
|
id = project.curse_project_id
|
|
|
|
// TODO add code to reference this but also cut the latest change logs in for the files
|
|
|
|
changelog = "${project.github}/blob/${sha}/CHANGELOG.md"
|
|
|
|
changelogType = 'markdown'
|
2021-05-09 04:45:31 +02:00
|
|
|
releaseType = 'release'
|
2021-04-05 15:47:34 +02:00
|
|
|
addGameVersion '1.16'
|
|
|
|
addGameVersion '1.15'
|
|
|
|
addGameVersion '1.14'
|
|
|
|
addGameVersion '1.13'
|
|
|
|
|
|
|
|
mainArtifact(jar){
|
|
|
|
|
|
|
|
}
|
|
|
|
//addArtifact sourcesJar
|
|
|
|
//addArtifact deobfJar
|
|
|
|
//addArtifact javadocJar
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-02 05:39:08 +02:00
|
|
|
task copyPlugin {
|
|
|
|
doLast {
|
|
|
|
copy {
|
|
|
|
if(System.env.MC_SERVER_LOC == null) {
|
2020-01-22 17:30:59 +01:00
|
|
|
throw new Exception('You must set the server location and jar to use')
|
2019-06-02 05:39:08 +02:00
|
|
|
}
|
|
|
|
println "$buildDir/libs/Advanced-Portals-${version}.jar"
|
|
|
|
println "${System.env.MC_SERVER_LOC}/plugins/Advanced-Portals-${version}.jar"
|
|
|
|
try {
|
|
|
|
delete fileTree("${System.env.MC_SERVER_LOC}/plugins/") {
|
|
|
|
include "*.jar"
|
|
|
|
}
|
|
|
|
}
|
2019-12-30 15:52:00 +01:00
|
|
|
catch(RuntimeException e) {
|
2019-06-02 05:39:08 +02:00
|
|
|
println e.getLocalizedMessage()
|
|
|
|
}
|
|
|
|
from file("$buildDir/libs/Advanced-Portals-${version}.jar")
|
|
|
|
into file("${System.env.MC_SERVER_LOC}/plugins/")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-07-23 02:43:29 +02:00
|
|
|
|
|
|
|
// Set SPIGOT_LOC to the location of your server and SPIGOT_JAR as the name of the jar file in the server you want to run
|
|
|
|
// DIReallyKnowWhatIAmDoingISwear is to remove the stupid pause spigot has at the start
|
|
|
|
task runJar() {
|
|
|
|
doLast {
|
2019-06-02 05:39:08 +02:00
|
|
|
if(System.env.MC_SERVER_LOC == null || System.env.MC_SERVER_JAR == null) {
|
2020-01-22 17:30:59 +01:00
|
|
|
throw new Exception('You must set the server location and jar to use MC_SERVER_LOC and MC_SERVER_JAR')
|
2019-06-02 05:39:08 +02:00
|
|
|
}
|
2018-07-23 02:43:29 +02:00
|
|
|
javaexec {
|
|
|
|
main "-jar"
|
|
|
|
args "${System.env.MC_SERVER_LOC}\\${System.env.MC_SERVER_JAR}.jar"
|
2018-08-27 22:43:02 +02:00
|
|
|
jvmArgs = ["-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005", "-DIReallyKnowWhatIAmDoingISwear=true"]
|
2018-07-23 02:43:29 +02:00
|
|
|
workingDir "${System.env.MC_SERVER_LOC}"
|
|
|
|
}
|
|
|
|
}
|
2019-12-30 15:52:00 +01:00
|
|
|
}
|