mirror of
https://github.com/apple/pkl.git
synced 2026-04-25 01:38:34 +02:00
Add support for HTTP rewrites (#1062)
This adds a new configuration option for the HTTP client to replace URI prefixes when making outbound calls. Follows the design of https://github.com/apple/pkl-evolution/pull/17
This commit is contained in:
@@ -473,6 +473,7 @@ public class PklPlugin implements Plugin<Project> {
|
||||
task.getTestPort().set(spec.getTestPort());
|
||||
task.getHttpProxy().set(spec.getHttpProxy());
|
||||
task.getHttpNoProxy().set(spec.getHttpNoProxy());
|
||||
task.getHttpRewrites().set(spec.getHttpRewrites());
|
||||
}
|
||||
|
||||
private List<File> getTransitiveModules(AnalyzeImportsTask analyzeTask) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
* Copyright © 2024-2025 Apple Inc. and the Pkl project authors. All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,4 +57,6 @@ public interface BasePklSpec {
|
||||
Property<URI> getHttpProxy();
|
||||
|
||||
ListProperty<String> getHttpNoProxy();
|
||||
|
||||
MapProperty<URI, URI> getHttpRewrites();
|
||||
}
|
||||
|
||||
@@ -142,6 +142,10 @@ public abstract class BasePklTask extends DefaultTask {
|
||||
@Optional
|
||||
public abstract ListProperty<String> getHttpNoProxy();
|
||||
|
||||
@Input
|
||||
@Optional
|
||||
public abstract MapProperty<URI, URI> getHttpRewrites();
|
||||
|
||||
/**
|
||||
* There are issues with using native libraries in Gradle plugins. As a workaround for now, make
|
||||
* Truffle use an un-optimized runtime.
|
||||
@@ -195,6 +199,7 @@ public abstract class BasePklTask extends DefaultTask {
|
||||
Collections.emptyList(),
|
||||
getHttpProxy().getOrNull(),
|
||||
getHttpNoProxy().getOrElse(List.of()),
|
||||
getHttpRewrites().getOrNull(),
|
||||
Map.of(),
|
||||
Map.of());
|
||||
}
|
||||
|
||||
@@ -163,6 +163,7 @@ public abstract class ModulesTask extends BasePklTask {
|
||||
Collections.emptyList(),
|
||||
null,
|
||||
List.of(),
|
||||
getHttpRewrites().getOrNull(),
|
||||
Map.of(),
|
||||
Map.of());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user