Skip to content

Commit

Permalink
Add exponential backoff to Maven plugin too
Browse files Browse the repository at this point in the history
  • Loading branch information
melix committed May 21, 2024
1 parent 076c6cc commit 2937a24
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions docs/src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ If you are using alternative build systems, see <<alternative-build-systems.adoc

- Add retries when downloading the metadata repository when using a URL directly

==== Maven plugin

- Add retries when downloading the metadata repository when using a URL directly

=== Release 0.10.1

- Mark additional JUnit 5 types for build-time initialization for compatibility with Native Image's `--strict-image-heap` option.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import org.eclipse.aether.resolution.DependencyResult;
import org.graalvm.buildtools.VersionInfo;
import org.graalvm.buildtools.maven.config.MetadataRepositoryConfiguration;
import org.graalvm.buildtools.utils.ExponentialBackoff;
import org.graalvm.buildtools.utils.FileUtils;
import org.graalvm.reachability.DirectoryConfiguration;
import org.graalvm.reachability.GraalVMReachabilityMetadataRepository;
Expand All @@ -73,6 +74,7 @@
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.time.Duration;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;
Expand Down Expand Up @@ -104,6 +106,12 @@ public abstract class AbstractNativeMojo extends AbstractMojo {
@Parameter(alias = "metadataRepository")
protected MetadataRepositoryConfiguration metadataRepositoryConfiguration;

@Parameter(defaultValue = "3")
protected int metadataRepositoryMaxRetries;

@Parameter(defaultValue = "100")
protected int metadataRepositoryInitialBackoffMillis;

protected final Set<DirectoryConfiguration> metadataRepositoryConfigurations;

protected GraalVMReachabilityMetadataRepository metadataRepository;
Expand Down Expand Up @@ -207,7 +215,11 @@ private Path getRepo(Path destinationRoot) {
}
}

return downloadMetadataRepo(destinationRoot, targetUrl);
URL finalTargetUrl = targetUrl;
return ExponentialBackoff.get()
.withMaxRetries(metadataRepositoryMaxRetries)
.withInitialWaitPeriod(Duration.ofMillis(metadataRepositoryInitialBackoffMillis))
.supply(() -> downloadMetadataRepo(destinationRoot, finalTargetUrl));
}
}

Expand Down

0 comments on commit 2937a24

Please sign in to comment.