Merge pull request #8 from solonovamax/gradle-test

Move Testing to gradle from test.sh
This commit is contained in:
dfsek 2020-11-02 10:32:35 -07:00 committed by GitHub
commit 92cdcba9f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 101 additions and 254 deletions

3
.gitignore vendored
View File

@ -131,3 +131,6 @@ build
/target/
.idea/sonarlint/**
.idea/codeStyles/**
.idea/**.xml
.idea/modules/**.iml

View File

@ -3,8 +3,13 @@ Terra is a data-driven world generator based on [Gaea](https://github.com/Polyhe
[Spigot page](https://www.spigotmc.org/resources/85151/)!
## Building and running Terra
To run Terra on a test server, clone this repo, package with Maven, then run `test.sh`. The script will clone a test
server skeleton (found [here](https://github.com/PolyhedralDev/WorldGenTestServer)) and set everything up to run.
To build, simply run `./gradlew build` on Linux/MacOS, or `gradlew.bat build` on Windows.
This will produce a jar in `build/libs` called `Terra-[CURRENT VERSION].jar`.
You can put this right into your plugins dir, along with the correct Gaea version.
If you would like to test it with a default server config, just run `./gradlew testWithPaper` or `gradlew.bat testWithPaper`.
This will download a default server config from [here](https://github.com/PolyhedralDev/WorldGenTestServer)
and install the server in the `target/server` directory, along with all the needed plugins.
**Note: You will need to adjust the `NAME` variable in test.sh if you are not using the default Terra config (you may
also change the value after server installation, in `bukkit.yml` of the test server)**
@ -12,6 +17,7 @@ also change the value after server installation, in `bukkit.yml` of the test ser
## Contributing
Contributions are welcome! If you want to see a feature in Terra, please, open an issue, or implement it yourself and
submit a PR!
Join the discord [here](https://discord.gg/PXUEbbF) if you would like to talk more about the project!
## Beta
Terra is still in beta! While it is stable, it is not feature-complete. There is a lot to be added!

View File

@ -1,7 +1,10 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import java.io.ByteArrayOutputStream
buildDir = file("target")
import java.net.URL
import java.nio.channels.Channels
import java.nio.file.Files
import java.nio.file.Paths
import java.nio.file.StandardCopyOption
plugins {
java
@ -12,41 +15,29 @@ repositories {
flatDir {
dirs("lib")
}
maven {
url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
}
maven {
url = uri("http://maven.enginehub.org/repo/")
}
maven {
url = uri("https://repo.codemc.org/repository/maven-public")
}
maven {
url = uri("https://papermc.io/repo/repository/maven-public/")
}
}
base {
libsDirName = "prod"
maven { url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") }
maven { url = uri("http://maven.enginehub.org/repo/") }
maven { url = uri("https://repo.codemc.org/repository/maven-public") }
maven { url = uri("https://papermc.io/repo/repository/maven-public/") }
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
val versionObj = Version("0", "0", "1", "dev.1")
val versionObj = Version("0", "0", "1", "dev.2")
version = versionObj
dependencies {
implementation("org.jetbrains:annotations:20.1.0") // more recent.
compileOnly("org.spigotmc:spigot-api:1.16.2-R0.1-SNAPSHOT")
compileOnly("org.jetbrains:annotations:20.1.0") // more recent.
implementation("commons-io:commons-io:2.4")
implementation(name = "Gaea-1.13.0", group = "")
implementation("org.apache.commons:commons-imaging:1.0-alpha2")
implementation("com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT")
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT")
implementation("org.bstats:bstats-bukkit:1.7")
implementation("com.googlecode.json-simple:json-simple:1.1")
compileOnly("com.googlecode.json-simple:json-simple:1.1")
implementation(name = "parsii-1.2", group = "")
implementation("io.papermc:paperlib:1.0.5")
@ -64,26 +55,80 @@ tasks.test {
maxParallelForks = 12
}
val testDir = "target/server/"
val setupServer = tasks.create("setupServer") {
dependsOn(tasks.shadowJar)
doFirst {
// clean
file("${testDir}/").deleteRecursively()
file("${testDir}/plugins").mkdirs()
// Downloading latest paper jar.
val paperUrl = URL("https://papermc.io/api/v1/paper/1.16.3/latest/download")
val paperReadableByteChannel = Channels.newChannel(paperUrl.openStream())
val paperFile = file("${testDir}/paper.jar")
val paperFileOutputStream = paperFile.outputStream()
val paperFileChannel = paperFileOutputStream.channel
paperFileChannel.transferFrom(paperReadableByteChannel, 0, Long.MAX_VALUE)
// Cloning test setup.
gitClone("https://github.com/PolyhedralDev/WorldGenTestServer")
// Copying plugins
Files.move(Paths.get("WorldGenTestServer/plugins"),
Paths.get("$testDir/plugins"),
StandardCopyOption.REPLACE_EXISTING)
// Copying config
val serverText = URL("https://raw.githubusercontent.com/PolyhedralDev/WorldGenTestServer/master/server.properties").readText()
file("${testDir}/server.properties").writeText(serverText)
val bukkitText = URL("https://raw.githubusercontent.com/PolyhedralDev/WorldGenTestServer/master/bukkit.yml").readText()
file("${testDir}/bukkit.yml").writeText(bukkitText.replace("\${world}", "world").replace("\${gen}", "Terra:DEFAULT"))
File("${testDir}/eula.txt").writeText("eula=true")
// Copy Terra into dir
copy {
from("${buildDir}/libs/Terra-${versionObj}.jar")
into("${testDir}/plugins/")
}
// clean up
file("WorldGenTestServer").deleteRecursively()
}
}
val testWithPaper = task<JavaExec>(name = "testWithPaper") {
dependsOn(setupServer)
main = "io.papermc.paperclip.Paperclip"
jvmArgs = listOf("-XX:+UseG1GC", "-XX:+ParallelRefProcEnabled", "-XX:MaxGCPauseMillis=200",
"-XX:+UnlockExperimentalVMOptions", "-XX:+DisableExplicitGC", "-XX:+AlwaysPreTouch",
"-XX:G1NewSizePercent=30", "-XX:G1MaxNewSizePercent=40", "-XX:G1HeapRegionSize=8M",
"-XX:G1ReservePercent=20", "-XX:G1HeapWastePercent=5", "-XX:G1MixedGCCountTarget=4",
"-XX:InitiatingHeapOccupancyPercent=15", "-XX:G1MixedGCLiveThresholdPercent=90",
"-XX:G1RSetUpdatingPauseTimePercent=5", "-XX:SurvivorRatio=32", "-XX:+PerfDisableSharedMem",
"-XX:MaxTenuringThreshold=1", "-Dusing.aikars.flags=https://mcflags.emc.gs",
"-Daikars.new.flags=true")
maxHeapSize = "2G"
workingDir = file("${testDir}/")
classpath = files("${testDir}/paper.jar")
}
tasks.named<ShadowJar>("shadowJar") {
archiveClassifier.set("")
archiveBaseName.set("Terra")
setVersion(project.version)
dependencies {
include(dependency("commons-io:commons-io"))
include(dependency("org.apache.commons:commons-imaging"))
include(dependency("org.bstats:bstats-bukkit"))
include(dependency(":parsii-1.2"))
include(dependency("io.papermc:paperlib"))
}
relocate("org.apache.commons", "com.dfsek.terra.lib.commons")
relocate("org.bstats.bukkit", "com.dfsek.terra.lib.bstats")
relocate("parsii", "com.dfsek.terra.lib.parsii")
relocate("io.papermc.lib", "com.dfsek.terra.lib.paperlib")
relocate("org.apache.commons", "lib.commons")
relocate("org.bstats.bukkit", "lib.bstats")
relocate("parsii", "lib.parsii")
relocate("io.papermc.lib", "lib.paperlib")
}
tasks.build {
dependsOn(tasks.test)
dependsOn("shadowJar")
dependsOn(tasks.shadowJar)
// dependsOn(testWithPaper)
tasks.shadowJar.get().mustRunAfter(tasks.test)
// testWithPaper.mustRunAfter(tasks.shadowJar)
}
@ -108,3 +153,11 @@ fun getGitHash(): String {
}
return stdout.toString().trim()
}
fun gitClone(name: String) {
val stdout = ByteArrayOutputStream()
exec {
commandLine = mutableListOf("git", "clone", name)
standardOutput = stdout
}
}

168
pom.xml
View File

@ -1,168 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dfsek</groupId>
<artifactId>Terra</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<groupId>com.scireum</groupId>
<artifactId>parsii</artifactId>
<version>1.2</version>
<packaging>jar</packaging>
<file>${basedir}/lib/parsii-1.2.jar</file>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<relocations>
<relocation>
<pattern>org.apache.commons</pattern>
<shadedPattern>com.dfsek.terra.lib.commons</shadedPattern>
</relocation>
<relocation>
<pattern>org.bstats.bukkit</pattern>
<shadedPattern>com.dfsek.terra.lib.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>parsii</pattern>
<shadedPattern>com.dfsek.terra.lib.parsii</shadedPattern>
</relocation>
<relocation>
<pattern>io.papermc.lib</pattern>
<shadedPattern>com.dfsek.terra.lib.paperlib</shadedPattern> <!-- Replace this -->
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<outputFile>target/prod/${project.artifactId}.jar</outputFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>enginehub-maven</id>
<url>http://maven.enginehub.org/repo/</url>
</repository>
<repository>
<id>CodeMC</id>
<url>https://repo.codemc.org/repository/maven-public</url>
</repository>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>16.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>org.polydev</groupId>
<artifactId>gaea</artifactId>
<version>1.12.2</version>
<scope>system</scope>
<systemPath>${basedir}/lib/Gaea-1.12.2.jar</systemPath>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-imaging</artifactId>
<version>1.0-alpha2</version>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.2.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>1.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.scireum</groupId>
<artifactId>parsii</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>io.papermc</groupId>
<artifactId>paperlib</artifactId>
<version>1.0.5</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

47
test.sh
View File

@ -1,47 +0,0 @@
DIRECTORY=./target
PROJECT=Terra
NAME="Terra:DEFAULT"
WORLD=world
REPO=https://github.com/PolyhedralDev/WorldGenTestServer
color() {
if [ $2 ]; then
echo -e "\e[$1;$2m"
else
echo -e "\e[$1m"
fi
}
colorend() {
echo -e "\e[m"
}
if [ ! -d "$DIRECTORY/server" ]; then
echo "$DIRECTORY/server not found. Cloning now."
git clone $REPO $DIRECTORY/server
fi
sed -i "s/\${gen}/$NAME/g" $DIRECTORY/server/bukkit.yml
sed -i "s/\${world}/$WORLD/g" $DIRECTORY/server/bukkit.yml
cp $DIRECTORY/prod/$PROJECT.jar $DIRECTORY/server/plugins/$PROJECT.jar
cd $DIRECTORY/server || exit
if ! test -f "paperclip.jar"; then
echo "Paper not found. Downloading now."
wget https://papermc.io/api/v1/paper/1.16.3/latest/download -O paperclip.jar
fi
if [ -z "$(grep true eula.txt 2>/dev/null)" ]; then
echo
echo "$(color 32) It appears you have not agreed to Mojangs EULA yet! Press $(color 1 33)y$(colorend) $(color 32)to confirm agreement to"
read -p " Mojangs EULA, found at:$(color 1 32) https://account.mojang.com/documents/minecraft_eula $(colorend) " -n 1 -r
echo ""
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "$(color 1 31)Aborted$(colorend)"
exit;
fi
echo "eula=true" > eula.txt
fi
java -Xms5G -Xmx5G -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC \
-XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 \
-XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 \
-XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true \
-jar paperclip.jar nogui