From 0072ec932940d43c3ea97adb74f9440c12a4f424 Mon Sep 17 00:00:00 2001 From: sciencewhiz Date: Sat, 24 Aug 2024 19:24:24 -0700 Subject: [PATCH] Update Download plugin version for parallel downloads Allows parallel builds which is useful for installer, and installer version and native-utils version need to be API compatible for toolchain installation Update version to 2026.0.0 since downstream tools need to update the download plugin also --- ToolchainPlugin/build.gradle | 2 +- .../first/toolchain/DefaultToolchainInstaller.java | 8 +++++++- .../toolchain/opensdk/OpenSdkToolchainBase.java | 8 +++++--- build.gradle | 2 +- .../nativeutils/vendordeps/VendorDepTask.java | 14 ++++++++++---- testing/cpp/build.gradle | 2 +- 6 files changed, 25 insertions(+), 11 deletions(-) diff --git a/ToolchainPlugin/build.gradle b/ToolchainPlugin/build.gradle index 93989bdd..aab40c3c 100644 --- a/ToolchainPlugin/build.gradle +++ b/ToolchainPlugin/build.gradle @@ -18,7 +18,7 @@ dependencies { // For some utility classes. We don't actually apply DeployUtils to the FRCToolchain, // but we do in GradleRIO api 'edu.wpi.first:DeployUtils:2025.2.0' - api 'de.undercouch:gradle-download-task:4.0.1' + api 'de.undercouch:gradle-download-task:5.6.0' testImplementation('org.spockframework:spock-core:2.0-M4-groovy-3.0') { exclude group: 'org.codehaus.groovy' diff --git a/ToolchainPlugin/src/main/java/edu/wpi/first/toolchain/DefaultToolchainInstaller.java b/ToolchainPlugin/src/main/java/edu/wpi/first/toolchain/DefaultToolchainInstaller.java index 1983e02c..a358026a 100644 --- a/ToolchainPlugin/src/main/java/edu/wpi/first/toolchain/DefaultToolchainInstaller.java +++ b/ToolchainPlugin/src/main/java/edu/wpi/first/toolchain/DefaultToolchainInstaller.java @@ -11,6 +11,7 @@ import java.io.File; import java.io.IOException; import java.net.URL; +import java.util.concurrent.ExecutionException; public class DefaultToolchainInstaller extends AbstractToolchainInstaller { @@ -39,9 +40,14 @@ public void install(Project project) { action.src(source); action.dest(dst); action.overwrite(false); - action.execute(); + action.retries(1); + action.execute().get(); } catch (IOException e) { throw new GradleException("Could not download toolchain", e); + } catch (InterruptedException e) { + throw new GradleException("Could not download toolchain, interrupted", e); + } catch (ExecutionException e) { + throw new GradleException("Could not download toolchain, failed", e); } if (action.isUpToDate()) { diff --git a/ToolchainPlugin/src/main/java/edu/wpi/first/toolchain/opensdk/OpenSdkToolchainBase.java b/ToolchainPlugin/src/main/java/edu/wpi/first/toolchain/opensdk/OpenSdkToolchainBase.java index f438038a..51381630 100644 --- a/ToolchainPlugin/src/main/java/edu/wpi/first/toolchain/opensdk/OpenSdkToolchainBase.java +++ b/ToolchainPlugin/src/main/java/edu/wpi/first/toolchain/opensdk/OpenSdkToolchainBase.java @@ -2,6 +2,8 @@ import java.io.File; import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import org.gradle.api.GradleException; @@ -69,9 +71,9 @@ private String toolchainRemoteFile() { public URL toolchainDownloadUrl() { String file = toolchainRemoteFile(); try { - return new URL("https://github.com/wpilibsuite/opensdk/releases/download/" + tcExt.getToolchainTag().get() - + "/" + file); - } catch (MalformedURLException e) { + return new URI("https://github.com/wpilibsuite/opensdk/releases/download/" + tcExt.getToolchainTag().get() + + "/" + file).toURL(); + } catch (MalformedURLException | URISyntaxException e) { throw new RuntimeException(e); } } diff --git a/build.gradle b/build.gradle index cd50e164..6250baf8 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ java { allprojects { group = "edu.wpi.first" - version = "2025.12.3" + version = "2026.0.0" if (project.hasProperty('publishVersion')) { version = project.publishVersion diff --git a/src/main/java/edu/wpi/first/nativeutils/vendordeps/VendorDepTask.java b/src/main/java/edu/wpi/first/nativeutils/vendordeps/VendorDepTask.java index c0a1efa7..c0e8ffa0 100644 --- a/src/main/java/edu/wpi/first/nativeutils/vendordeps/VendorDepTask.java +++ b/src/main/java/edu/wpi/first/nativeutils/vendordeps/VendorDepTask.java @@ -6,6 +6,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardCopyOption; +import java.util.concurrent.ExecutionException; import org.gradle.api.DefaultTask; import org.gradle.api.file.Directory; @@ -39,10 +40,12 @@ public void update() { /** * Installs the JSON file - * @throws java.io.IOException throws on ioexception + * @throws ExecutionException if completed exceptionally + * @throws InterruptedException if cancelled + * @throws IOException if the download fails */ @TaskAction - public void install() throws IOException { + public void install() throws IOException, InterruptedException, ExecutionException { if (update) { Gson gson = new GsonBuilder().create(); Object property = getProject().findProperty(WPIVendorDepsExtension.NATIVEUTILS_VENDOR_FOLDER_PROPERTY); @@ -167,10 +170,13 @@ private void copyLocal(String filename, Path dest) { /** * Download a vendor JSON file from a URL * @param dest the destination file + * @throws ExecutionException if completed exceptionally + * @throws InterruptedException if cancelled + * @throws IOException if the download fails */ - private void downloadRemote(Path dest) throws IOException { + private void downloadRemote(Path dest) throws IOException, InterruptedException, ExecutionException { downloadAction.src(url); downloadAction.dest(dest.toFile()); - downloadAction.execute(); + downloadAction.execute().get(); } } diff --git a/testing/cpp/build.gradle b/testing/cpp/build.gradle index 5511578e..22b25c02 100644 --- a/testing/cpp/build.gradle +++ b/testing/cpp/build.gradle @@ -3,7 +3,7 @@ import edu.wpi.first.nativeutils.vendordeps.WPIVendorDepsPlugin plugins { id "cpp" - id "edu.wpi.first.NativeUtils" version "2025.12.3" + id "edu.wpi.first.NativeUtils" version "2026.0.0" } nativeUtils.addWpiNativeUtils()