From 959f368e37bb2620947fecd5a9ca2a2b6dcebab0 Mon Sep 17 00:00:00 2001
From: Dennisbonke <dennisb@kabelfoon.net>
Date: Sun, 1 Oct 2017 22:49:59 +0200
Subject: [PATCH] Commited some changes, maven auto deploy.

Signed-off-by: Dennisbonke <dennisb@kabelfoon.net>
---
 .gitignore                                    | 10 ++
 build.gradle                                  | 91 ++++++++++++++++++-
 build.properties                              |  3 +
 .../java/com/advancedmods/amcore/AMCore.java  | 10 +-
 4 files changed, 107 insertions(+), 7 deletions(-)
 create mode 100644 .gitignore
 create mode 100644 build.properties

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8846014
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,10 @@
+bin
+eclipse
+.classpath
+.gradle
+.idea
+.project
+.settings
+*.iml
+*.ipr
+*.iws
diff --git a/build.gradle b/build.gradle
index 2ee5d88..20592f1 100644
--- a/build.gradle
+++ b/build.gradle
@@ -16,10 +16,12 @@ buildscript {
 }
 
 apply plugin: 'forge'
+apply plugin: 'maven'
+apply plugin: 'maven-publish'
 
 project.ext.buildnumber = "CUSTOM_BUILD" // referenced as project.buildnumber
 
-if (System.getenv().BUILD_NUMBER) // assuming jenkins ofcourse
+/*if (System.getenv().BUILD_NUMBER) // assuming jenkins ofcourse
 {
     project.buildnumber = System.getenv().BUILD_NUMBER
     println "Using build number ${project.buildnumber}..."
@@ -28,15 +30,70 @@ else
 {
     project.buildnumber = "0"
     println "!! No build number set !!"
-}
+}*/
+
+project.buildnumber = "1"
 
 version = "1.7.10-0.2.2-B1" + "-" + project.buildnumber
-group= "com.advancedmods.amcore" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
+group= "com.advancedmods" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
 archivesBaseName = "AMCore"
 
+
+// External properties
+ext.configFile = file "build.properties"
+configFile.withReader {
+    // Load config.  It shall from now be referenced as simply config or project.config
+    def prop = new Properties()
+    prop.load(it)
+    project.ext.config = new ConfigSlurper().parse prop
+}
+configurations {
+    deployerJars
+}
+
+task buildInfo {
+    def cmd = "git rev-parse --short HEAD"
+    def proc = cmd.execute()
+    proc.waitFor()
+    if (proc.exitValue() == 0) {
+        ext.revision = proc.text.trim()
+    } else {
+        ext.revision = "GITBORK"
+    }
+
+    if (System.getenv().BUILD_NUMBER != null) {
+        ext.buildNum = "build${System.getenv().BUILD_NUMBER}"
+    } else {
+        ext.buildNum = "DEV.${project.buildInfo.revision}"
+    }
+}
+
+/*if (System.getenv().ARTIFACT_VERSION == null) {
+    artifact_version = "${config.mod_version}.${project.buildInfo.buildNum}"
+}
+if (System.getenv().ARTIFACT_VERSION != null) {
+    artifact_version = "${system.getenv().ARTIFACT_VERSION}"
+}
+version = "${config.minecraft_version}-${artifact_version}"*/
+
 minecraft {
-    version = "1.7.10-10.13.4.1614-1.7.10"
+//    version = "1.7.10-10.13.4.1614-1.7.10"
+    version = config.minecraft_version + "-" + config.forge_version
     runDir = "eclipse"
+//    replace '${version}', project.version
+}
+
+dependencies {
+    deployerJars "org.apache.maven.wagon:wagon-ssh:2.2"
+}
+
+uploadArchives {
+    repositories.mavenDeployer {
+	configuration = configurations.deployerJars
+	repository(url: "sftp://web1.zsnode.com/srv/users/maven/apps/maven-repo-public/public") {
+	    authentication(userName: "maven", password: project.maven_pass)
+	}
+    }
 }
 
 dependencies {
@@ -102,6 +159,32 @@ artifacts {
     archives javadocJar
 }
 
+/*task("uploadJars", dependsOn:"build") {
+    
+    description = "uploads JARs"
+
+    if (project.hasProperty("local_maven") || project.hasProperty("sftp_maven")) {
+	    apply plugin: 'maven'
+        uploadArchives {
+            repositories {
+		    	if(project.hasProperty("local_maven"))
+			    {
+                    mavenDeployer {
+                        repository(url: "file://${local_maven}")
+				    }
+                }
+				if(project.hasProperty("sftp_maven")) {
+                    repositories.mavenDeployer {
+					    configuration = configurations.deployerJars
+                        repository(url: "sftp://${sftp_maven}"){
+						authentication(userName: "${sftp_username}",privateKey: "${sftp_key}")}
+				    }
+                }
+            }
+        }    
+    }
+}*/
+
 //apply plugin: 'curseforge'
 //curse {
 //    apiKey      = project.curseforge_key // gradle curse -Pcurseforge_key=your-api-key
diff --git a/build.properties b/build.properties
new file mode 100644
index 0000000..cd8a147
--- /dev/null
+++ b/build.properties
@@ -0,0 +1,3 @@
+minecraft_version=1.7.10
+forge_version=10.13.4.1614-1.7.10
+buildNum=0
diff --git a/src/main/java/com/advancedmods/amcore/AMCore.java b/src/main/java/com/advancedmods/amcore/AMCore.java
index 860ef42..7bd0398 100644
--- a/src/main/java/com/advancedmods/amcore/AMCore.java
+++ b/src/main/java/com/advancedmods/amcore/AMCore.java
@@ -37,10 +37,14 @@ public class AMCore extends BaseMod {
     @SidedProxy(clientSide = AMCoreProps.clientproxy, serverSide = AMCoreProps.commonproxy)
     public static CommonProxy proxy;
     public static Logger log = LogManager.getLogger("AMCore");
-    public static final String issueURL = "https://github.com/AdvancedMods/AMCore/issues";
-    public static final String updateURL = "https://raw.github.com/AdvancedMods/AMCore/master/VERSION";
+    //public static final String issueURL = "https://github.com/AdvancedMods/AMCore/issues";
+    //public static final String updateURL = "https://raw.github.com/AdvancedMods/AMCore/master/VERSION";
     //public static final String downloadURL = "http://ci.zsinfo.nl/job/AMCore/lastSuccessfulBuild/";
-    public static final String downloadURL = "https://github.com/AdvancedMods/AMCore/releases";
+    public static final String issueURL = "http://git.zsinfo.nl/advanced-mods/AMCore/issues";
+    // TODO: Look at these addresses and update if appropriate!
+    public static final String updateURL = "http://git.zsinfo.nl/advanced-mods/AMCore";
+    public static final String downloadURL = "http://git.zsinfo.nl/advanced-mods/AMCore";
+    //public static final String downloadURL = "https://github.com/AdvancedMods/AMCore/releases";
     public static ConfigurationHandler config;
 
     @EventHandler
-- 
GitLab