From f416f1b30fc42fcb88d6294083dd43387e29cc7d Mon Sep 17 00:00:00 2001 From: s1lentq Date: Thu, 12 Jan 2017 04:04:35 +0700 Subject: [PATCH] Add version upgrade to another resource. --- buildSrc/build.gradle | 2 ++ publish.gradle | 26 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle index 0d93aa3..722ca4a 100644 --- a/buildSrc/build.gradle +++ b/buildSrc/build.gradle @@ -20,4 +20,6 @@ dependencies { compile 'org.doomedsociety.gradlecpp:gradle-cpp-plugin:1.2' compile 'org.eclipse.jgit:org.eclipse.jgit:3.7.0.201502260915-r' compile 'org.apache.velocity:velocity:1.7' + compile group: 'org.codehaus.groovy.modules.http-builder', name: 'http-builder', version: '0.7.1' + } diff --git a/publish.gradle b/publish.gradle index 55b2c98..9c02dfb 100644 --- a/publish.gradle +++ b/publish.gradle @@ -1,5 +1,7 @@ import org.doomedsociety.gradlecpp.GradleCppUtils import org.apache.commons.io.FilenameUtils +import groovyx.net.http.HTTPBuilder +import static groovyx.net.http.Method.POST void _copyFileToDir(String from, String to) { def dst = new File(project.file(to), FilenameUtils.getName(from)) @@ -43,7 +45,29 @@ task publishPackage(type: Zip, dependsOn: 'publishPrepareFiles') { from 'publish/publishRoot/reapi' } +Properties repoCreds = new Properties() +project.ext.repoCreds = repoCreds +if (file('repo_creds.properties').exists()) { + println 'Loading credentials' + file('repo_creds.properties').withReader('UTF-8', { Reader r -> + repoCreds.load(r) + }) +} + +task updateVersion { + def http = new HTTPBuilder("http://rehlds.ru/version/update.php?appid=reapi&key=" + repoCreds.getProperty('key') + "&version=" + project.ext.reapiVersionInfo.asMavenVersion(false)); + http.headers = [ "User-Agent": "Mozilla/5.0" ]; + http.request(POST) { + response.success = { resp -> + println "Version version success! Status: ${resp.status}" + } + response.failure = { resp -> + println "Request failed with status ${resp.status}" + } + } +} + task doPackage { - dependsOn 'publishPackage' + dependsOn 'publishPackage', 'updateVersion' }