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 8, 2024
1 parent 7481022 commit bddfb7e
Show file tree
Hide file tree
Showing 253 changed files with 1,615 additions and 998 deletions.
2 changes: 1 addition & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<microprofile-lra.version>2.0</microprofile-lra.version>
<microprofile-openapi.version>3.1.1</microprofile-openapi.version>
<smallrye-common.version>2.3.0</smallrye-common.version>
<smallrye-config.version>3.6.0</smallrye-config.version>
<smallrye-config.version>3.6.1-SNAPSHOT</smallrye-config.version>
<smallrye-health.version>4.1.0</smallrye-health.version>
<smallrye-metrics.version>4.0.0</smallrye-metrics.version>
<smallrye-open-api.version>3.10.0</smallrye-open-api.version>
Expand Down
2 changes: 1 addition & 1 deletion build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@
</systemPropertyVariables>
<!-- limit the amount of memory surefire can use, 1500m should be plenty-->
<!-- set tmpdir as early as possible because surefire sets it too late for JDK16 -->
<argLine>${jacoco.agent.argLine} -Xmx1500m -XX:MaxMetaspaceSize=1500m -Djava.io.tmpdir="${project.build.directory}" ${surefire.argLine.additional}</argLine>
<argLine>${jacoco.agent.argLine} -Xmx2048m -XX:MaxMetaspaceSize=2048m -Djava.io.tmpdir="${project.build.directory}" ${surefire.argLine.additional}</argLine>
<excludedEnvironmentVariables>MAVEN_OPTS</excludedEnvironmentVariables>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,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 +35,14 @@ public void defaultJavaCommand(PackageConfig packageConfig,

Path jarPath = null;
if (legacyJarRequired.isEmpty() && (!uberJarRequired.isEmpty()
|| packageConfig.type.equalsIgnoreCase(PackageConfig.UBER_JAR))) {
|| packageConfig.jar().type() == PackageConfig.JarConfig.JarType.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() == PackageConfig.JarConfig.JarType.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 +51,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 @@ -406,6 +406,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 bddfb7e

Please sign in to comment.