From f2503277c955d66efd08f35031a45339d71bb916 Mon Sep 17 00:00:00 2001 From: Cheryl King Date: Sat, 30 Sep 2023 18:24:19 -0500 Subject: [PATCH] Another try to fix tests --- .../tools/ant/install/ArchiveInstaller.java | 4 ++-- .../tools/ant/install/InstallLibertyTask.java | 16 ++++++++++++---- .../tools/ant/install/OpenLibertyInstaller.java | 4 ++-- .../tools/ant/install/WasDevInstaller.java | 6 +++--- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/main/java/io/openliberty/tools/ant/install/ArchiveInstaller.java b/src/main/java/io/openliberty/tools/ant/install/ArchiveInstaller.java index 5f980ac3..e30eb061 100644 --- a/src/main/java/io/openliberty/tools/ant/install/ArchiveInstaller.java +++ b/src/main/java/io/openliberty/tools/ant/install/ArchiveInstaller.java @@ -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)); @@ -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); diff --git a/src/main/java/io/openliberty/tools/ant/install/InstallLibertyTask.java b/src/main/java/io/openliberty/tools/ant/install/InstallLibertyTask.java index f85ba303..597624f5 100644 --- a/src/main/java/io/openliberty/tools/ant/install/InstallLibertyTask.java +++ b/src/main/java/io/openliberty/tools/ant/install/InstallLibertyTask.java @@ -35,7 +35,7 @@ public class InstallLibertyTask extends AbstractTask { private String baseDir; private String cacheDir; - private boolean verbose; + private boolean verbose=true; private String licenseCode; private String version; private String type; @@ -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); } } @@ -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); diff --git a/src/main/java/io/openliberty/tools/ant/install/OpenLibertyInstaller.java b/src/main/java/io/openliberty/tools/ant/install/OpenLibertyInstaller.java index 1f98779d..787e58bc 100644 --- a/src/main/java/io/openliberty/tools/ant/install/OpenLibertyInstaller.java +++ b/src/main/java/io/openliberty/tools/ant/install/OpenLibertyInstaller.java @@ -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); @@ -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); diff --git a/src/main/java/io/openliberty/tools/ant/install/WasDevInstaller.java b/src/main/java/io/openliberty/tools/ant/install/WasDevInstaller.java index c5dda3e9..b504e7f4 100644 --- a/src/main/java/io/openliberty/tools/ant/install/WasDevInstaller.java +++ b/src/main/java/io/openliberty/tools/ant/install/WasDevInstaller.java @@ -103,7 +103,7 @@ 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)); @@ -111,7 +111,7 @@ public void install(InstallLibertyTask task) throws Exception { // 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); @@ -119,7 +119,7 @@ public void install(InstallLibertyTask task) throws Exception { // 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);