Skip to content

Commit

Permalink
fix: restore system level properties for build integration. (quarkusi…
Browse files Browse the repository at this point in the history
…o#1062)

in cleaing up properties handling we missed that jbang build integration,
especially quarkus, relied on properties being in system properties.

Fix for now is to set system properties temporariliy before jbang integration
called and then restored again.

Fixes quarkusio#1058
  • Loading branch information
maxandersen committed Nov 3, 2021
1 parent 1d29306 commit 1b46fec
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/main/java/dev/jbang/cli/BaseBuildCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -89,12 +91,6 @@ static Source buildIfNeeded(Source src, RunContext ctx) throws IOException {
static Source build(ScriptSource src, RunContext ctx) throws IOException {
Source result = src;

// todo: pass properties through instead of changing system properties
/*
* for (Map.Entry<String, String> entry : ctx.getProperties().entrySet()) {
* System.setProperty(entry.getKey(), entry.getValue()); }
*/

File outjar = src.getJarFile();
boolean nativeBuildRequired = ctx.isNativeImage() && !getImageName(outjar).exists();
IntegrationResult integrationResult = new IntegrationResult(null, null, null);
Expand Down Expand Up @@ -181,10 +177,18 @@ public static IntegrationResult buildJar(ScriptSource src, RunContext ctx, File
}

ctx.setBuildJdk(JavaUtil.javaVersion(requestedJavaVersion));
// todo: setting properties to avoid loosing properties in integration call.
Properties old = System.getProperties();
Properties temporay = new Properties(System.getProperties());
for (Map.Entry<String, String> entry : ctx.getProperties().entrySet()) {
System.setProperty(entry.getKey(), entry.getValue());
}
integrationResult = IntegrationManager.runIntegration(src.getAllRepositories(),
ctx.getClassPath().getArtifacts(),
tmpJarDir.toPath(), pomPath,
src, ctx.isNativeImage());
System.setProperties(old);

if (integrationResult.mainClass != null) {
ctx.setMainClass(integrationResult.mainClass);
} else {
Expand Down

0 comments on commit 1b46fec

Please sign in to comment.