mirror of
https://github.com/rehlds/reapi.git
synced 2024-12-29 08:05:36 +03:00
74 lines
2.3 KiB
Groovy
74 lines
2.3 KiB
Groovy
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))
|
|
GradleCppUtils.copyFile(project.file(from), dst, false)
|
|
}
|
|
|
|
void _copyFile(String from, String to) {
|
|
GradleCppUtils.copyFile(project.file(from), project.file(to), false)
|
|
}
|
|
|
|
task publishPrepareFiles << {
|
|
def pubRootDir = project.file('publish/publishRoot')
|
|
if (pubRootDir.exists()) {
|
|
if (!pubRootDir.deleteDir()) {
|
|
throw new RuntimeException("Failed to delete ${pubRootDir}")
|
|
}
|
|
}
|
|
|
|
pubRootDir.mkdirs()
|
|
|
|
project.file('publish/publishRoot/reapi/addons/amxmodx/modules').mkdirs()
|
|
//project.file('publish/publishRoot/reapi/addons/amxmodx/scripting/include').mkdirs()
|
|
|
|
_copyFileToDir('publish/reapi_amxx.dll', 'publish/publishRoot/reapi/addons/amxmodx/modules/')
|
|
//_copyFileToDir('publish/reapi_amxx.pdb', 'publish/publishRoot/reapi/addons/amxmodx/modules/')
|
|
_copyFile('publish/libreapi_amxx_i386.so', 'publish/publishRoot/reapi/addons/amxmodx/modules/reapi_amxx_i386.so')
|
|
|
|
copy {
|
|
from 'reapi/extra'
|
|
into 'publish/publishRoot/reapi/addons'
|
|
}
|
|
copy {
|
|
from 'reapi/version/reapi_version.inc'
|
|
into 'publish/publishRoot/reapi/addons/amxmodx/scripting/include'
|
|
}
|
|
}
|
|
|
|
task publishPackage(type: Zip, dependsOn: 'publishPrepareFiles') {
|
|
baseName = "reapi_${project.version}"
|
|
destinationDir file('publish')
|
|
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', 'updateVersion'
|
|
|
|
}
|