Skip to content

Commit

Permalink
Do not redownload files that content does not change (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
cherylking authored Oct 17, 2023
1 parent 327838e commit 364087e
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 28 deletions.
37 changes: 20 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,30 +80,33 @@
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>install</goal>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
</configuration>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>install</goal>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
Expand Down
2 changes: 1 addition & 1 deletion src/it/tests/deploy-eba-it/windows/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<wlp:server ref="testServer" operation="stop" />

<wlp:clean ref="testServer" apps="true" dropins="true" />
<wlp:clean ref="testServer" apps="true" dropins="true" logs="false" workarea="false" />

</target>

Expand Down
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,15 @@ 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);
}
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 364087e

Please sign in to comment.