diff --git a/core/deployment/src/main/java/io/quarkus/deployment/logging/LoggingResourceProcessor.java b/core/deployment/src/main/java/io/quarkus/deployment/logging/LoggingResourceProcessor.java index 19b8841bcb903..a0e39ca6ad8c3 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/logging/LoggingResourceProcessor.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/logging/LoggingResourceProcessor.java @@ -33,7 +33,7 @@ import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; import io.quarkus.deployment.metrics.MetricsCapabilityBuildItem; import io.quarkus.deployment.metrics.MetricsFactoryConsumerBuildItem; -import io.quarkus.deployment.pkg.steps.NativeBuild; +import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; import io.quarkus.gizmo.AnnotationCreator; import io.quarkus.gizmo.BranchResult; import io.quarkus.gizmo.BytecodeCreator; @@ -169,7 +169,7 @@ void registerMetrics(LogMetricsHandlerRecorder recorder, LogBuildTimeConfig log, } } - @BuildStep(onlyIf = NativeBuild.class) + @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) void setUpMinLevelLogging(LogBuildTimeConfig log, final BuildProducer generatedTraceLogger) { ClassOutput output = new GeneratedClassGizmoAdaptor(generatedTraceLogger, false); diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeOrNativeSourcesBuild.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeOrNativeSourcesBuild.java new file mode 100644 index 0000000000000..dfd4a191a531c --- /dev/null +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeOrNativeSourcesBuild.java @@ -0,0 +1,24 @@ +package io.quarkus.deployment.pkg.steps; + +import java.util.function.BooleanSupplier; + +import io.quarkus.deployment.pkg.PackageConfig; + +/** + * Supplier that can be used to only run build steps in the + * native or native sources builds. + */ +public class NativeOrNativeSourcesBuild implements BooleanSupplier { + + private final PackageConfig packageConfig; + + NativeOrNativeSourcesBuild(PackageConfig packageConfig) { + this.packageConfig = packageConfig; + } + + @Override + public boolean getAsBoolean() { + return packageConfig.type.equalsIgnoreCase(PackageConfig.NATIVE) + || packageConfig.type.equalsIgnoreCase(PackageConfig.NATIVE_SOURCES); + } +} diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageConfigBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageConfigBuildStep.java index 52c90e45f1deb..f7ab42243b0d3 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageConfigBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/NativeImageConfigBuildStep.java @@ -23,7 +23,7 @@ import io.quarkus.deployment.builditem.nativeimage.NativeImageSystemPropertyBuildItem; import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem; -import io.quarkus.deployment.pkg.steps.NativeBuild; +import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; import io.quarkus.runtime.ssl.SslContextConfigurationRecorder; //TODO: this should go away, once we decide on which one of the API's we want @@ -89,7 +89,7 @@ void build(SslContextConfigurationRecorder sslContextConfigurationRecorder, } } - @BuildStep(onlyIf = NativeBuild.class) + @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) void reinitHostNameUtil(BuildProducer runtimeReInitClass) { // certain libraries like JBoss logging internally use this class to determine the hostname // of the system. This HostName class computes and stores the hostname as a static field in a class, diff --git a/extensions/amazon-lambda/common-deployment/src/main/java/io/quarkus/amazon/lambda/deployment/AmazonLambdaCommonProcessor.java b/extensions/amazon-lambda/common-deployment/src/main/java/io/quarkus/amazon/lambda/deployment/AmazonLambdaCommonProcessor.java index a500c481ac4f1..df692697ed573 100644 --- a/extensions/amazon-lambda/common-deployment/src/main/java/io/quarkus/amazon/lambda/deployment/AmazonLambdaCommonProcessor.java +++ b/extensions/amazon-lambda/common-deployment/src/main/java/io/quarkus/amazon/lambda/deployment/AmazonLambdaCommonProcessor.java @@ -14,12 +14,21 @@ import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.LaunchModeBuildItem; import io.quarkus.deployment.builditem.SystemPropertyBuildItem; +import io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem; import io.quarkus.deployment.pkg.steps.NativeBuild; +import io.quarkus.deployment.pkg.steps.NativeSourcesBuild; import io.quarkus.jackson.runtime.ObjectMapperProducer; import io.quarkus.runtime.LaunchMode; @SuppressWarnings("unchecked") public final class AmazonLambdaCommonProcessor { + + @BuildStep(onlyIf = NativeSourcesBuild.class) + void failForNativeSources(BuildProducer artifactResultProducer) { + throw new IllegalArgumentException( + "The Amazon Lambda extensions are incompatible with the 'native-sources' package type."); + } + /** * Lambda custom runtime does not like ipv6. */ diff --git a/extensions/container-image/deployment/src/main/java/io/quarkus/container/image/deployment/ContainerImageProcessor.java b/extensions/container-image/deployment/src/main/java/io/quarkus/container/image/deployment/ContainerImageProcessor.java index 49677a0c28a87..7443750fab6d7 100644 --- a/extensions/container-image/deployment/src/main/java/io/quarkus/container/image/deployment/ContainerImageProcessor.java +++ b/extensions/container-image/deployment/src/main/java/io/quarkus/container/image/deployment/ContainerImageProcessor.java @@ -11,12 +11,20 @@ import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.builditem.ApplicationInfoBuildItem; +import io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem; +import io.quarkus.deployment.pkg.steps.NativeSourcesBuild; public class ContainerImageProcessor { private static final String UNKNOWN_USER = "?"; private static final Logger log = Logger.getLogger(ContainerImageProcessor.class); + @BuildStep(onlyIf = NativeSourcesBuild.class) + void failForNativeSources(BuildProducer artifactResultProducer) { + throw new IllegalArgumentException( + "The Container Imagee extensions are incompatible with the 'native-sources' package type."); + } + @BuildStep public void publishImageInfo(ApplicationInfoBuildItem app, ContainerImageConfig containerImageConfig, Capabilities capabilities, diff --git a/extensions/google-cloud-functions/deployment/src/main/java/io/quarkus/gcp/functions/deployment/CloudFunctionDeploymentBuildStep.java b/extensions/google-cloud-functions/deployment/src/main/java/io/quarkus/gcp/functions/deployment/CloudFunctionDeploymentBuildStep.java index 5c1f0535fad7a..33a6a141652b9 100644 --- a/extensions/google-cloud-functions/deployment/src/main/java/io/quarkus/gcp/functions/deployment/CloudFunctionDeploymentBuildStep.java +++ b/extensions/google-cloud-functions/deployment/src/main/java/io/quarkus/gcp/functions/deployment/CloudFunctionDeploymentBuildStep.java @@ -7,12 +7,14 @@ import io.quarkus.builder.BuildException; import io.quarkus.deployment.IsNormal; +import io.quarkus.deployment.annotations.BuildProducer; import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.pkg.builditem.ArtifactResultBuildItem; import io.quarkus.deployment.pkg.builditem.JarBuildItem; import io.quarkus.deployment.pkg.builditem.OutputTargetBuildItem; import io.quarkus.deployment.pkg.builditem.UberJarRequiredBuildItem; import io.quarkus.deployment.pkg.steps.NativeBuild; +import io.quarkus.deployment.pkg.steps.NativeSourcesBuild; public class CloudFunctionDeploymentBuildStep { @BuildStep @@ -21,6 +23,12 @@ public UberJarRequiredBuildItem forceUberJar() { return new UberJarRequiredBuildItem(); } + @BuildStep(onlyIf = NativeSourcesBuild.class) + void failForNativeSources(BuildProducer artifactResultProducer) { + throw new IllegalArgumentException( + "The Google Cloud extensions are incompatible with the 'native-sources' package type."); + } + /** * Creates a target/deployment dir and copy the uber jar in it. * This facilitates the usage of the 'glcoud' command. diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java index 34d1b8db6c0e9..321ebc806b857 100644 --- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java +++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java @@ -104,7 +104,7 @@ import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.deployment.configuration.ConfigurationError; import io.quarkus.deployment.index.IndexingUtil; -import io.quarkus.deployment.pkg.steps.NativeBuild; +import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; import io.quarkus.deployment.recording.RecorderContext; import io.quarkus.deployment.util.IoUtil; import io.quarkus.deployment.util.ServiceUtil; @@ -611,7 +611,7 @@ public void produceLoggingCategories(HibernateOrmConfig hibernateOrmConfig, } } - @BuildStep(onlyIf = NativeBuild.class) + @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) public void registerStaticMetamodelClassesForReflection(CombinedIndexBuildItem index, BuildProducer reflective) { Collection annotationInstances = index.getIndex().getAnnotations(STATIC_METAMODEL); diff --git a/extensions/jaeger/deployment/src/main/java/io/quarkus/jaeger/deployment/JaegerProcessor.java b/extensions/jaeger/deployment/src/main/java/io/quarkus/jaeger/deployment/JaegerProcessor.java index 64f67a0c6048f..7d47218d0311b 100644 --- a/extensions/jaeger/deployment/src/main/java/io/quarkus/jaeger/deployment/JaegerProcessor.java +++ b/extensions/jaeger/deployment/src/main/java/io/quarkus/jaeger/deployment/JaegerProcessor.java @@ -14,7 +14,7 @@ import io.quarkus.deployment.builditem.FeatureBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.deployment.metrics.MetricsCapabilityBuildItem; -import io.quarkus.deployment.pkg.steps.NativeBuild; +import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; import io.quarkus.jaeger.runtime.JaegerBuildTimeConfig; import io.quarkus.jaeger.runtime.JaegerConfig; import io.quarkus.jaeger.runtime.JaegerDeploymentRecorder; @@ -23,7 +23,7 @@ public class JaegerProcessor { - @BuildStep(onlyIf = NativeBuild.class) + @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) @Record(ExecutionTime.STATIC_INIT) void setVersion(JaegerDeploymentRecorder jdr) { jdr.setJaegerVersion(JaegerTracer.getVersionFromProperties()); diff --git a/extensions/jdbc/jdbc-mysql/deployment/src/main/java/io/quarkus/jdbc/mysql/deployment/JDBCMySQLProcessor.java b/extensions/jdbc/jdbc-mysql/deployment/src/main/java/io/quarkus/jdbc/mysql/deployment/JDBCMySQLProcessor.java index d959568276e8e..a975be7edc716 100644 --- a/extensions/jdbc/jdbc-mysql/deployment/src/main/java/io/quarkus/jdbc/mysql/deployment/JDBCMySQLProcessor.java +++ b/extensions/jdbc/jdbc-mysql/deployment/src/main/java/io/quarkus/jdbc/mysql/deployment/JDBCMySQLProcessor.java @@ -38,7 +38,7 @@ import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem; import io.quarkus.deployment.builditem.nativeimage.NativeImageSystemPropertyBuildItem; import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; -import io.quarkus.deployment.pkg.steps.NativeBuild; +import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; import io.quarkus.jdbc.mysql.runtime.MySQLAgroalConnectionConfigurer; import io.quarkus.jdbc.mysql.runtime.MySQLServiceBindingConverter; @@ -87,7 +87,7 @@ NativeImageSystemPropertyBuildItem disableAbandonedConnectionCleanUpInNativeMode return new NativeImageSystemPropertyBuildItem("com.mysql.cj.disableAbandonedConnectionCleanup", "true"); } - @BuildStep(onlyIfNot = NativeBuild.class) + @BuildStep(onlyIfNot = NativeOrNativeSourcesBuild.class) SystemPropertyBuildItem disableAbandonedConnectionCleanUpInJVMMode() { return new SystemPropertyBuildItem("com.mysql.cj.disableAbandonedConnectionCleanup", "true"); } diff --git a/extensions/liquibase/deployment/src/main/java/io/quarkus/liquibase/deployment/LiquibaseProcessor.java b/extensions/liquibase/deployment/src/main/java/io/quarkus/liquibase/deployment/LiquibaseProcessor.java index d1f9bec7634fd..d24b29e05aa15 100644 --- a/extensions/liquibase/deployment/src/main/java/io/quarkus/liquibase/deployment/LiquibaseProcessor.java +++ b/extensions/liquibase/deployment/src/main/java/io/quarkus/liquibase/deployment/LiquibaseProcessor.java @@ -43,7 +43,7 @@ import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem; import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; -import io.quarkus.deployment.pkg.steps.NativeBuild; +import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; import io.quarkus.deployment.util.ServiceUtil; import io.quarkus.liquibase.LiquibaseDataSource; import io.quarkus.liquibase.LiquibaseFactory; @@ -82,7 +82,7 @@ public SystemPropertyBuildItem disableHub() { return new SystemPropertyBuildItem("liquibase.hub.mode", "off"); } - @BuildStep(onlyIf = NativeBuild.class) + @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) @Record(STATIC_INIT) void nativeImageConfiguration( LiquibaseRecorder recorder,