diff --git a/build.gradle.kts b/build.gradle.kts index ef53a790..4d728a9f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -98,6 +98,7 @@ allprojects { accessToken = githubAccessToken manualDownloadUrl = "https://github.com/weisJ/darklaf/actions?query=workflow%3A%22Build+Native+Libraries%22+is%3Asuccess+branch%3Amaster" + timeout = 50000 } } } diff --git a/buildSrc/src/main/groovy/DownloadPrebuiltBinaryFromGitHubAction.groovy b/buildSrc/src/main/groovy/DownloadPrebuiltBinaryFromGitHubAction.groovy index cf6ffe37..e45697fa 100644 --- a/buildSrc/src/main/groovy/DownloadPrebuiltBinaryFromGitHubAction.groovy +++ b/buildSrc/src/main/groovy/DownloadPrebuiltBinaryFromGitHubAction.groovy @@ -45,6 +45,7 @@ class DownloadPrebuiltBinaryFromGitHubAction extends DefaultTask { private String workflow private List branches = [] private boolean missingLibraryIsFailure + private int timeout private String githubAccessToken private String variant @@ -111,6 +112,10 @@ class DownloadPrebuiltBinaryFromGitHubAction extends DefaultTask { this.branches = branches } + void setTimeout(int timeout) { + this.timeout = timeout + } + private Map getCacheInfo() { if (cacheInfo == null) { LOCK.readLock().lock() @@ -289,6 +294,9 @@ class DownloadPrebuiltBinaryFromGitHubAction extends DefaultTask { if (isOffline()) return Optional.empty() HttpURLConnection get = new URL(url).openConnection() as HttpURLConnection get.setRequestMethod("GET") + if (timeout >= 0) { + get.setConnectTimeout(timeout) + } githubAccessToken?.with { get.setRequestProperty("Authorization", "token $it") } @@ -300,6 +308,7 @@ class DownloadPrebuiltBinaryFromGitHubAction extends DefaultTask { log("Could not fetch $url. Response code '$responseCode'.") } } catch (IOException ignored) { + error(ignored.getMessage()) } return Optional.empty() } diff --git a/buildSrc/src/main/groovy/UsePrebuiltBinariesWhenUnbuildablePlugin.groovy b/buildSrc/src/main/groovy/UsePrebuiltBinariesWhenUnbuildablePlugin.groovy index d1504dc9..888ee0f1 100644 --- a/buildSrc/src/main/groovy/UsePrebuiltBinariesWhenUnbuildablePlugin.groovy +++ b/buildSrc/src/main/groovy/UsePrebuiltBinariesWhenUnbuildablePlugin.groovy @@ -47,6 +47,7 @@ class UsePrebuiltBinariesWhenUnbuildablePlugin implements Plugin { it.manualDownloadUrl = githubArtifactExtension.manualDownloadUrl it.branches = githubArtifactExtension.branches it.missingLibraryIsFailure = prebuildExtension.missingLibraryIsFailure + it.timeout = githubArtifactExtension.timeout } var.nativeRuntimeFiles.setFrom(prebuiltBinariesTask.map { it.prebuiltBinaryFile }) var.nativeRuntimeFiles.from(new CallableLogger({ @@ -110,6 +111,7 @@ class UsePrebuiltBinariesWhenUnbuildablePlugin implements Plugin { private String workflow private String manualDownloadUrl private String accessToken + private int timeout = 0 private List branches = ["master"] String getUser() { @@ -136,6 +138,10 @@ class UsePrebuiltBinariesWhenUnbuildablePlugin implements Plugin { return branches } + int getTimeout() { + return timeout + } + void setUser(String user) { this.user = user } @@ -159,6 +165,10 @@ class UsePrebuiltBinariesWhenUnbuildablePlugin implements Plugin { void setBranches(List branches) { this.branches = branches } + + void setTimeout(int timeout) { + this.timeout = timeout + } } }