Skip to content

Commit

Permalink
Another try to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cherylking committed Sep 30, 2023
1 parent 20227c7 commit de535ee
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private void install(InstallLibertyTask task, File cacheDir, String url) throws
task.checkLicenseSet();

// download Liberty jar
task.downloadFile(downloadURL, cachedFile);
task.downloadFile(downloadURL, cachedFile, true);

// do license check
task.checkLicense(getLicenseCode(cachedFile));
Expand All @@ -91,7 +91,7 @@ private void install(InstallLibertyTask task, File cacheDir, String url) throws
task.installLiberty(cachedFile);
} else {
// download zip file
task.downloadFile(downloadURL, cachedFile);
task.downloadFile(downloadURL, cachedFile, true);

// unzip
task.unzipLiberty(cachedFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,14 @@ private void doExecute() throws Exception {
}

protected void downloadFile(URL source, File dest) throws IOException {
downloadFile(source, dest, false);
}

protected void downloadFile(URL source, File dest, boolean skipExisting) throws IOException {
if (offline) {
offlineDownload(source, dest);
} else {
onlineDownload(source, dest);
onlineDownload(source, dest, skipExisting);
}
}

Expand All @@ -113,13 +117,17 @@ private void offlineDownload(URL source, File dest) throws IOException {
}
}

private void onlineDownload(URL source, File dest) throws IOException {
private void onlineDownload(URL source, File dest, boolean skipExisting) throws IOException {
Get get = (Get) getProject().createTask("get");
DownloadProgress progress = null;
if (verbose) {
progress = new Get.VerboseProgress(System.out);
}
get.setUseTimestamp(true);
if (skipExisting) {
get.setSkipExisting(true);
} else {
get.setUseTimestamp(true);
}
get.setUsername(username);
get.setPassword(password);
get.setMaxTime(maxDownloadTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void install(InstallLibertyTask task) throws Exception {
String versionUrl = baseUrl + version + "/";
URL runtimeInfoUrl = new URL(versionUrl + "info.json");
File runtimeInfoFile = new File(cacheDir, version + ".json");
task.downloadFile(runtimeInfoUrl, runtimeInfoFile);
task.downloadFile(runtimeInfoUrl, runtimeInfoFile, true);

// Parse JSON
InputStream runtimeInfoIs = new FileInputStream(runtimeInfoFile);
Expand Down Expand Up @@ -93,7 +93,7 @@ public void install(InstallLibertyTask task) throws Exception {

URL runtimeUrl = new URL(runtimeUrlString);
File runtimeFile = new File(versionCacheDir, InstallUtils.getFile(runtimeUrl));
task.downloadFile(runtimeUrl, runtimeFile);
task.downloadFile(runtimeUrl, runtimeFile, true);

if(runtimeUrlString.endsWith(".jar")) {
task.installLiberty(runtimeFile);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,23 @@ public void install(InstallLibertyTask task) throws Exception {
// download license
URL licenseURL = new URL(selectedVersion.getLicenseUri());
File licenseFile = new File(versionCacheDir, InstallUtils.getFile(licenseURL));
task.downloadFile(licenseURL, licenseFile);
task.downloadFile(licenseURL, licenseFile, true);

// do license check
task.checkLicense(InstallUtils.getLicenseCode(licenseFile, LICENSE_REGEX));

// download Liberty jar
URL libertyURL = new URL(uri);
File libertyFile = new File(versionCacheDir, InstallUtils.getFile(libertyURL));
task.downloadFile(libertyURL, libertyFile);
task.downloadFile(libertyURL, libertyFile, true);

// install Liberty jar
task.installLiberty(libertyFile);
} else if(uri.endsWith(".zip")) {
// download zip file
URL libertyURL = new URL(uri);
File libertyFile = new File(versionCacheDir, InstallUtils.getFile(libertyURL));
task.downloadFile(libertyURL, libertyFile);
task.downloadFile(libertyURL, libertyFile, true);

// unzip
task.unzipLiberty(libertyFile);
Expand Down

0 comments on commit de535ee

Please sign in to comment.