-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26965 from yrodiere/onlyif-multiple-build-steps
Support @buildsteps on buildstep classes to apply conditions to all build steps of that class
- Loading branch information
Showing
37 changed files
with
308 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
core/deployment/src/main/java/io/quarkus/deployment/annotations/BuildSteps.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.quarkus.deployment.annotations; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import java.util.function.BooleanSupplier; | ||
|
||
/** | ||
* Applies configuration to all build steps defined in the same class. | ||
* <p> | ||
* This annotation is applied at the class level, and will result in conditions ({@link #onlyIf()}/{@link #onlyIfNot()}) | ||
* being prepended to all build steps defined in that class. | ||
* <p> | ||
* This is mainly useful for "enabled"-type conditions, where all steps in a class should be enabled/disabled | ||
* based on a single condition, for example based on configuration properties. | ||
* | ||
* @see BuildStep | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
public @interface BuildSteps { | ||
|
||
/** | ||
* Only include build steps defined in this class if the given supplier class(es) return {@code true}. | ||
* | ||
* @return the supplier class array | ||
*/ | ||
Class<? extends BooleanSupplier>[] onlyIf() default {}; | ||
|
||
/** | ||
* Only include build steps defined in this class if the given supplier class(es) return {@code false}. | ||
* | ||
* @return the supplier class array | ||
*/ | ||
Class<? extends BooleanSupplier>[] onlyIfNot() default {}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...te/search/orm/elasticsearch/deployment/HibernateSearchElasticsearchDisabledProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package io.quarkus.hibernate.search.orm.elasticsearch.deployment; | ||
|
||
import static io.quarkus.hibernate.search.orm.elasticsearch.deployment.HibernateSearchElasticsearchProcessor.HIBERNATE_SEARCH_ELASTICSEARCH; | ||
|
||
import java.util.List; | ||
|
||
import io.quarkus.deployment.annotations.BuildProducer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.annotations.BuildSteps; | ||
import io.quarkus.deployment.annotations.ExecutionTime; | ||
import io.quarkus.deployment.annotations.Record; | ||
import io.quarkus.hibernate.orm.deployment.PersistenceUnitDescriptorBuildItem; | ||
import io.quarkus.hibernate.orm.deployment.integration.HibernateOrmIntegrationRuntimeConfiguredBuildItem; | ||
import io.quarkus.hibernate.orm.deployment.integration.HibernateOrmIntegrationStaticConfiguredBuildItem; | ||
import io.quarkus.hibernate.search.orm.elasticsearch.runtime.HibernateSearchElasticsearchRecorder; | ||
import io.quarkus.hibernate.search.orm.elasticsearch.runtime.HibernateSearchElasticsearchRuntimeConfig; | ||
|
||
@BuildSteps(onlyIfNot = HibernateSearchEnabled.class) | ||
class HibernateSearchElasticsearchDisabledProcessor { | ||
|
||
@BuildStep | ||
@Record(ExecutionTime.STATIC_INIT) | ||
public void disableHibernateSearchStaticInit(HibernateSearchElasticsearchRecorder recorder, | ||
List<PersistenceUnitDescriptorBuildItem> persistenceUnitDescriptorBuildItems, | ||
BuildProducer<HibernateOrmIntegrationStaticConfiguredBuildItem> staticIntegrations) { | ||
for (PersistenceUnitDescriptorBuildItem puDescriptor : persistenceUnitDescriptorBuildItems) { | ||
String puName = puDescriptor.getPersistenceUnitName(); | ||
staticIntegrations.produce(new HibernateOrmIntegrationStaticConfiguredBuildItem(HIBERNATE_SEARCH_ELASTICSEARCH, | ||
puName).setInitListener(recorder.createStaticInitInactiveListener())); | ||
} | ||
} | ||
|
||
@BuildStep | ||
@Record(ExecutionTime.RUNTIME_INIT) | ||
public void disableHibernateSearchRuntimeInit(HibernateSearchElasticsearchRecorder recorder, | ||
HibernateSearchElasticsearchRuntimeConfig runtimeConfig, | ||
List<PersistenceUnitDescriptorBuildItem> persistenceUnitDescriptorBuildItems, | ||
BuildProducer<HibernateOrmIntegrationRuntimeConfiguredBuildItem> runtimeIntegrations) { | ||
recorder.checkNoExplicitActiveTrue(runtimeConfig); | ||
for (PersistenceUnitDescriptorBuildItem puDescriptor : persistenceUnitDescriptorBuildItems) { | ||
String puName = puDescriptor.getPersistenceUnitName(); | ||
runtimeIntegrations.produce(new HibernateOrmIntegrationRuntimeConfiguredBuildItem(HIBERNATE_SEARCH_ELASTICSEARCH, | ||
puName).setInitListener(recorder.createRuntimeInitInactiveListener())); | ||
} | ||
} | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
...ate/search/orm/elasticsearch/deployment/HibernateSearchElasticsearchLoggingProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.quarkus.hibernate.search.orm.elasticsearch.deployment; | ||
|
||
import io.quarkus.deployment.annotations.BuildProducer; | ||
import io.quarkus.deployment.annotations.BuildStep; | ||
import io.quarkus.deployment.builditem.NativeImageFeatureBuildItem; | ||
import io.quarkus.deployment.logging.LogCleanupFilterBuildItem; | ||
import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; | ||
import io.quarkus.hibernate.search.orm.elasticsearch.runtime.graal.DisableLoggingFeature; | ||
|
||
// Note this is necessary even if Hibernate Search is disabled | ||
class HibernateSearchElasticsearchLoggingProcessor { | ||
|
||
@BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) | ||
NativeImageFeatureBuildItem nativeImageFeature() { | ||
return new NativeImageFeatureBuildItem(DisableLoggingFeature.class); | ||
} | ||
|
||
// Note this is necessary even if Hibernate Search is disabled | ||
@BuildStep | ||
void setupLogFilters(BuildProducer<LogCleanupFilterBuildItem> filters) { | ||
// if the category changes, please also update DisableLoggingFeature in the runtime module | ||
filters.produce(new LogCleanupFilterBuildItem( | ||
"org.hibernate.search.mapper.orm.bootstrap.impl.HibernateSearchPreIntegrationService", "HSEARCH000034")); | ||
} | ||
|
||
} |
Oops, something went wrong.