2
0
mirror of https://github.com/rehlds/reapi.git synced 2024-12-27 23:25:30 +03:00

Add version upgrade to another resource.

This commit is contained in:
s1lentq 2017-01-12 04:04:35 +07:00
parent f93e992674
commit f416f1b30f
2 changed files with 27 additions and 1 deletions

View File

@ -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'
}

View File

@ -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'
}