Skip to content

Commit

Permalink
* fix version api
Browse files Browse the repository at this point in the history
  • Loading branch information
lomanyong committed Nov 30, 2016
1 parent cc4c038 commit 39ff5a4
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class FreelineDownloader {
private static final String PARAM_LOCAL = "freelineLocal"

private static final String GITHUB_API = "https://api.github.com/repos/alibaba/freeline/releases/latest"
private static final String FREELINE_API = "http://api.freelinebuild.com/versions/latest"
private static final String FREELINE_API = "https://www.freelinebuild.com/api/versions/latest"
private static final String CDN_URL = "http://static.freelinebuild.com/freeline"

public static void execute(Project project) {
Expand Down Expand Up @@ -128,16 +128,16 @@ class FreelineDownloader {
}

private static String fetchData(Project project, String cdnUrl, boolean mirror) {
def json = fetchDataFromAPI()
def json = fetchDataFromAPI(project)
if (json != null) {
String version = json.freelineVersion.version
checkVersion(project, version)
return getDownloadUrl(mirror, cdnUrl, version, json.freelineVersion.download_url as String)
}

json = fetchDataFromGithub()
json = fetchDataFromGithub(project)
if (json != null) {
String version = json.assets[0].name
String version = json.name
checkVersion(project, version)
return getDownloadUrl(mirror, cdnUrl, version, json.assets[0].browser_download_url as String)
}
Expand All @@ -153,23 +153,24 @@ class FreelineDownloader {
}
}

private static def fetchDataFromAPI() {
private static def fetchDataFromAPI(Project project) {
try {
def json = FreelineUtils.getJson(FREELINE_API)
return json
} catch (Exception e) {
println "[ERROR] Fetching data from api occurs error: ${e.getMessage()}"
println "[ERROR] Fetching data from api occurs error"
return null
}
}

private static def fetchDataFromGithub() {
private static def fetchDataFromGithub(Project project) {
try {
def json = FreelineUtils.getJson(GITHUB_API)
if (json == null || json == '') {
println "Download Error: failed to get json from ${GITHUB_API}"
return null
}
return json
} catch (Exception e) {
println "[ERROR] Fetching data from github occurs error: ${e.getMessage()}"
return null
Expand Down

0 comments on commit 39ff5a4

Please sign in to comment.