Skip to content

Commit

Permalink
Move package config to an interface
Browse files Browse the repository at this point in the history
* Change `PackageConfig` to an interface
* Move JAR-specific configuration to `JarConfig` group
* Replace package type with combination of JAR type and JAR/native enable flags
* Introduce compatibility interceptors for complex remappings
* Update all build steps, tests, and POMs to use the new properties
  • Loading branch information
dmlloyd committed Mar 20, 2024
1 parent 7eb8479 commit 095feab
Show file tree
Hide file tree
Showing 251 changed files with 1,679 additions and 1,069 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.deployment.cmd;

import static io.quarkus.deployment.pkg.PackageConfig.JarConfig.JarType.*;
import static io.quarkus.deployment.pkg.steps.JarResultBuildStep.DEFAULT_FAST_JAR_DIRECTORY_NAME;
import static io.quarkus.deployment.pkg.steps.JarResultBuildStep.QUARKUS_RUN_JAR;

Expand All @@ -25,6 +26,7 @@ public RunCommandActionResultBuildItem commands(List<RunCommandActionBuildItem>
return new RunCommandActionResultBuildItem(cmds);
}

@SuppressWarnings("deprecation") // legacy jar
@BuildStep
public void defaultJavaCommand(PackageConfig packageConfig,
OutputTargetBuildItem jar,
Expand All @@ -34,13 +36,14 @@ public void defaultJavaCommand(PackageConfig packageConfig,

Path jarPath = null;
if (legacyJarRequired.isEmpty() && (!uberJarRequired.isEmpty()
|| packageConfig.type.equalsIgnoreCase(PackageConfig.UBER_JAR))) {
|| packageConfig.jar().type() == UBER_JAR)) {
jarPath = jar.getOutputDirectory()
.resolve(jar.getBaseName() + packageConfig.getRunnerSuffix() + ".jar");
} else if (!legacyJarRequired.isEmpty() || packageConfig.isLegacyJar()
|| packageConfig.type.equalsIgnoreCase(PackageConfig.LEGACY)) {
.resolve(jar.getBaseName() + packageConfig.computedRunnerSuffix() + ".jar");
} else if (!legacyJarRequired.isEmpty()
|| packageConfig.jar().type() == LEGACY_JAR) {
// todo: legacy JAR should be using runnerSuffix()
jarPath = jar.getOutputDirectory()
.resolve(jar.getBaseName() + packageConfig.getRunnerSuffix() + ".jar");
.resolve(jar.getBaseName() + packageConfig.computedRunnerSuffix() + ".jar");
} else {
jarPath = jar.getOutputDirectory().resolve(DEFAULT_FAST_JAR_DIRECTORY_NAME).resolve(QUARKUS_RUN_JAR);

Expand All @@ -49,7 +52,7 @@ public void defaultJavaCommand(PackageConfig packageConfig,
List<String> args = new ArrayList<>();
args.add(determineJavaPath());

for (Map.Entry e : System.getProperties().entrySet()) {
for (Map.Entry<?, ?> e : System.getProperties().entrySet()) {
args.add("-D" + e.getKey().toString() + "=" + e.getValue().toString());
}
args.add("-jar");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ public SmallRyeConfig initConfiguration(LaunchMode launchMode, Properties buildS
}

builder.withInterceptors(buildConfigTracker);
builder.withInterceptors(ConfigCompatibility.FrontEnd.instance(), ConfigCompatibility.BackEnd.instance());
var config = builder.build();
buildConfigTracker.configure(config);
return config;
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import io.quarkus.deployment.dev.remote.RemoteDevClient;
import io.quarkus.deployment.dev.remote.RemoteDevClientProvider;
import io.quarkus.deployment.mutability.DevModeTask;
import io.quarkus.deployment.pkg.PackageConfig;
import io.quarkus.deployment.pkg.steps.JarResultBuildStep;
import io.quarkus.deployment.steps.ClassTransformingBuildStep;
import io.quarkus.dev.spi.DeploymentFailedStartHandler;
Expand Down Expand Up @@ -90,7 +89,7 @@ private synchronized JarResult generateApplication() {
//ok, we have resolved all the deps
try {
AugmentResult start = augmentAction.createProductionApplication();
if (!start.getJar().getType().equalsIgnoreCase(PackageConfig.BuiltInType.MUTABLE_JAR.getValue())) {
if (!start.getJar().mutable()) {
throw new RuntimeException(
"remote-dev can only be used with mutable applications i.e. " +
"using the mutable-jar package type");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ public void accept(BuildChainBuilder builder) {
builder.addFinal(GeneratedResourceBuildItem.class);
builder.addFinal(TransformedClassesBuildItem.class);
builder.addFinal(DeploymentResultBuildItem.class);
boolean nativeRequested = "native".equals(System.getProperty("quarkus.package.type"));
// note: quarkus.package.type is deprecated
boolean nativeRequested = "native".equals(System.getProperty("quarkus.package.type"))
|| "true".equals(System.getProperty("quarkus.native.enabled"));
boolean containerBuildRequested = Boolean.getBoolean("quarkus.container-image.build");
if (nativeRequested) {
builder.addFinal(NativeImageBuildItem.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static void main(Path appRoot) throws Exception {
List<AdditionalDependency> additional = new ArrayList<>();

if (appModel.getUserProvidersDirectory() != null) {
System.setProperty("quarkus.package.user-providers-directory", appModel.getUserProvidersDirectory()); //bit of a hack, but keeps things simple
System.setProperty("quarkus.package.jar.user-providers-directory", appModel.getUserProvidersDirectory()); //bit of a hack, but keeps things simple
try (Stream<Path> files = Files.list(appRoot.resolve(appModel.getUserProvidersDirectory()))) {
files.forEach(new Consumer<Path>() {
@Override
Expand All @@ -54,7 +54,7 @@ public void accept(Path path) {
}

final ApplicationModel existingModel = appModel.getAppModel(appRoot);
System.setProperty("quarkus.package.type", "mutable-jar");
System.setProperty("quarkus.package.jar.type", "mutable-jar");
try (CuratedApplication bootstrap = QuarkusBootstrap.builder()
.setAppArtifact(existingModel.getAppArtifact())
.setExistingModel(existingModel)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ public interface NativeConfig {
String DEFAULT_GRAALVM_BUILDER_IMAGE = "quay.io/quarkus/ubi-quarkus-graalvmce-builder-image:jdk-21";
String DEFAULT_MANDREL_BUILDER_IMAGE = "quay.io/quarkus/ubi-quarkus-mandrel-builder-image:jdk-21";

/**
* Set to enable native-image building using GraalVM.
*/
@WithDefault("false")
boolean enabled();

/**
* Set to prevent the native-image process from actually building the native image.
*/
@WithDefault("false")
boolean sourcesOnly();

/**
* Comma-separated, additional arguments to pass to the build process.
* If an argument includes the {@code ,} symbol, it needs to be escaped, e.g. {@code \\,}
Expand Down
Loading

0 comments on commit 095feab

Please sign in to comment.