Commit 0965ac6e authored by maweidong's avatar maweidong

feat:新增APP版本

parent 9f92431c
import javax.net.ssl.HostnameVerifier
import javax.net.ssl.HttpsURLConnection
import javax.net.ssl.SSLSession
import java.text.SimpleDateFormat
import java.util.regex.Matcher
import java.util.regex.Pattern
......@@ -94,37 +91,34 @@ def isSnapshot() {
return "SNAPSHOT" == getChannelString()
}
//task printenv() {
//// for (Map.Entry<String, String> entry : System.getenv()) {
//// println("key:${entry.key},value:${entry.value}")
//// }
// getBizModuleLastVersion()
//}
task printenv() {
getBizModuleLastVersion()
}
def getBizModuleLastVersion() {
def modules = [
"yit_shell",
"yit_shop",
"yit_live",
"yit_cms",
"yit_base",
"yit_food",
"yit_browser",
"yit_category",
"yit_qr",
"yit_productinfo",
"yit_mine",
"yit_search",
"yit_cart",
"yit_post",
"yit_login",
"yit_auction",
"yit_social",
"yit_imagepicker",
"yit_share",
"yit_picker",
"yit_flutter"
// "yit_shop",
// "yit_live",
// "yit_cms",
// "yit_base",
// "yit_food",
// "yit_browser",
// "yit_category",
// "yit_qr",
// "yit_productinfo",
// "yit_mine",
// "yit_search",
// "yit_cart",
// "yit_post",
// "yit_login",
// "yit_auction",
// "yit_social",
// "yit_imagepicker",
// "yit_share",
// "yit_picker",
// "yit_flutter"
]
def group = "com.yitlib.module"
for (def module : modules) {
......@@ -139,41 +133,27 @@ def getHttpVersion(def group, def module) {
HttpURLConnection connection = null
InputStream is = null
BufferedReader br = null
String result = null// 返回结果字符串
StringBuilder builder = new StringBuilder("\n")// 返回结果字符串
try {
// 创建远程url连接对象
URL url = new URL("https://nexus3.yit.com/repository/maven-public/$group_path/$module/maven-metadata.xml")
// 通过远程url连接对象打开一个连接 , 强转成httpURLConnection类
println(url)
connection = (HttpURLConnection) url.openConnection()
// 设置连接方式:get
connection.setRequestMethod("GET")
// 设置连接主机服务器的超时时间:15000毫秒
connection.setConnectTimeout(15000)
// 设置读取远程返回的数据时间:60000毫秒
connection.setReadTimeout(60000)
// 发送请求
connection.connect()
// 通过connection连接,获取输入流
if (connection.getResponseCode() == 200) {
is = connection.getInputStream()
// 封装输入流is,并指定字符集
br = new BufferedReader(new InputStreamReader(is, "UTF-8"))
// 存放数据
StringBuffer sbf = new StringBuffer()
String temp = null
String temp
while ((temp = br.readLine()) != null) {
sbf.append(temp)
sbf.append("\r\n")
builder.append(temp).append("\n")
}
result = sbf.toString()
}
} catch (MalformedURLException e) {
e.printStackTrace()
} catch (IOException e) {
} catch (Exception e) {
e.printStackTrace()
} finally {
// 关闭资源
if (null != br) {
try {
br.close()
......@@ -189,12 +169,31 @@ def getHttpVersion(def group, def module) {
e.printStackTrace()
}
}
connection.disconnect()// 关闭远程连接
}
def xmlSlurper = new XmlSlurper()
def response = xmlSlurper.parseText(result)
println("$module=${response.versioning.latest}")
Pattern pattern = Pattern.compile("<versions>(.|\n)+</versions>")
Matcher matcher = pattern.matcher(builder)
List<String> dataSet = new ArrayList<>()
try {
if (matcher.find()) {
def versions = matcher.group()
.replaceAll("<version>", "")
.replaceAll("</version>", "")
.replaceAll("<versions>", "")
.replaceAll("</versions>", "")
.split("\n")
for (String version : versions) {
dataSet.add(version)
}
}
} catch (Exception e) {
e.printStackTrace()
}
// dataSet.each { it -> println(it) }
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment