Skip to content

Commit

Permalink
Set up project
Browse files Browse the repository at this point in the history
  • Loading branch information
BrainStone committed Apr 20, 2017
1 parent 209d59f commit 5c635ad
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
0.0.0-alpha
-----------

- Initial commit
159 changes: 159 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import java.util.regex.*

plugins {
id "org.spongepowered.plugin" version "0.8.1"
}

apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "maven"
apply plugin: "maven-publish"

def getChangelog() {
Pattern pattern = Pattern.compile("^.+?\n-+\n\n((?:- .+?\n)+)");
Matcher match = pattern.matcher(file("CHANGELOG.md").text.replaceAll("\r", ""));

if (match.find()) {
String res = match.group(1);

return res.substring(0, res.length() - 1);
} else {
return "";
}
}
def getVersionType() {
def lower_version = version.toLowerCase();

if (lower_version.contains("beta") || lower_version.contains("rc"))
return "beta";
else if (lower_version.contains("alpha"))
return "alpha";
else
return "release";
}
def getVersionName() {
try {
def version;
def tmp = "git describe --tags --dirty=-SNAPSHOT".execute().text.trim().substring(1).split("-");

if (tmp.length <= 2) {
version = tmp.join("-");
} else {
def versions = tmp[0].split("\\.");
versions[2] = String.valueOf(versions[2].toInteger() + tmp[1].toInteger());

version = versions.join(".");

if (tmp.length == 4)
version += "-" + tmp[3];
}

version = "${minecraft_version}-${version}";

if (mod_version_postfix.isEmpty())
return version;
else
return version.replaceFirst("(.+?-[^\\-]+)(-)?", "\$1-${mod_version_postfix}\$2");
} catch(Exception e) {
println e
return "UNKNOW-VERSION"
}
}
def signJar(archivePath) {
if (project.hasProperty("keyStoreAlias") && project.hasProperty("keyStore") && project.hasProperty("keyStorePass")) {
ant.signjar(
jar: archivePath,
alias: project.keyStoreAlias,
keystore: project.keyStore,
storepass: project.keyStorePass,
preservelastmodified: true
)
} else {
println "WARNING!!!\tCannot sign jar!"
}
}

def MainDirResources = fileTree(dir: file("."), includes: ["README.md", "LICENSE", "CHANGELOG.md"])
group = "jnc.world"
version = getVersionName()

repositories {
jcenter()
mavenCentral()
maven {
name = "sponge"
url = "https://repo.spongepowered.org/maven"
}
}

dependencies {
compile "org.spongepowered:spongeapi:${sponge_version}"
}

sponge {
plugin {
id = "invsync"

meta {
name = "Inventory Sync"
version = getVersionName()
description = "This plugin synchronizes the player inventory with a database"
}
}
}

task showVersion {
description "Displays the current version"
group "help"

generateMetadata.dependsOn showVersion

doLast {
println version

def versionFile = new File(buildDir, '.version');

versionFile.getParentFile().mkdirs();
versionFile.text = version;
}

outputs.upToDateWhen { false }
}

task gitTag {
description "Tags the current version in git. Specify the version by passing \"-PtagVersion=version\""
group "help"

doLast {
def tagVersion

if ( project.hasProperty("tagVersion") ) {
tagVersion = project.tagVersion
} else {
tagVersion = "v" + version.split("-")[1]
}

"git tag -a ${tagVersion} -m \"" + StringEscapeUtils.escapeJava(getChangelog()) + "\"".execute();
}
}

jar {
doLast {
signJar(jar)
}
}

task sourceJar (type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource

doLast {
signJar(sourceJar.archivePath)
}
}

artifacts {
archives jar
archives sourceJar
}

4 changes: 4 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
org.gradle.jvmargs=-Xmx1G

mod_version_postfix=alpha
sponge_version=6.0.0-SNAPSHOT

0 comments on commit 5c635ad

Please sign in to comment.