use of io.quarkus.liquibase.runtime.LiquibaseRecorder in project quarkus by quarkusio.
the class LiquibaseProcessor method nativeImageConfiguration.
@BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
@Record(STATIC_INIT)
void nativeImageConfiguration(LiquibaseRecorder recorder, LiquibaseBuildTimeConfig liquibaseBuildConfig, List<JdbcDataSourceBuildItem> jdbcDataSourceBuildItems, CombinedIndexBuildItem combinedIndex, BuildProducer<ReflectiveClassBuildItem> reflective, BuildProducer<NativeImageResourceBuildItem> resource, BuildProducer<ServiceProviderBuildItem> services, BuildProducer<RuntimeInitializedClassBuildItem> runtimeInitialized, BuildProducer<RuntimeReinitializedClassBuildItem> runtimeReInitialized, BuildProducer<NativeImageResourceBundleBuildItem> resourceBundle) {
runtimeInitialized.produce(new RuntimeInitializedClassBuildItem(liquibase.diff.compare.CompareControl.class.getName()));
reflective.produce(new ReflectiveClassBuildItem(false, true, false, liquibase.change.AbstractSQLChange.class.getName(), liquibase.database.jvm.JdbcConnection.class.getName()));
reflective.produce(new ReflectiveClassBuildItem(true, false, false, "liquibase.command.LiquibaseCommandFactory", liquibase.command.CommandFactory.class.getName()));
reflective.produce(new ReflectiveClassBuildItem(true, true, true, liquibase.parser.ChangeLogParserCofiguration.class.getName(), liquibase.hub.HubServiceFactory.class.getName(), liquibase.logging.core.DefaultLoggerConfiguration.class.getName(), liquibase.configuration.GlobalConfiguration.class.getName(), com.datical.liquibase.ext.config.LiquibaseProConfiguration.class.getName(), liquibase.license.LicenseServiceFactory.class.getName(), liquibase.executor.ExecutorService.class.getName(), liquibase.change.ChangeFactory.class.getName(), liquibase.logging.core.LogServiceFactory.class.getName(), liquibase.logging.LogFactory.class.getName(), liquibase.change.ColumnConfig.class.getName(), liquibase.change.AddColumnConfig.class.getName(), liquibase.change.core.LoadDataColumnConfig.class.getName(), liquibase.sql.visitor.PrependSqlVisitor.class.getName(), liquibase.sql.visitor.ReplaceSqlVisitor.class.getName(), liquibase.sql.visitor.AppendSqlVisitor.class.getName(), liquibase.sql.visitor.RegExpReplaceSqlVisitor.class.getName()));
reflective.produce(new ReflectiveClassBuildItem(false, false, true, liquibase.change.ConstraintsConfig.class.getName()));
// register classes marked with @DatabaseChangeProperty for reflection
Set<String> classesMarkedWithDatabaseChangeProperty = new HashSet<>();
for (AnnotationInstance databaseChangePropertyInstance : combinedIndex.getIndex().getAnnotations(DATABASE_CHANGE_PROPERTY)) {
// the annotation is only supported on methods but let's be safe
AnnotationTarget annotationTarget = databaseChangePropertyInstance.target();
if (annotationTarget.kind() == AnnotationTarget.Kind.METHOD) {
classesMarkedWithDatabaseChangeProperty.add(annotationTarget.asMethod().declaringClass().name().toString());
}
}
reflective.produce(new ReflectiveClassBuildItem(true, true, true, classesMarkedWithDatabaseChangeProperty.toArray(new String[0])));
Collection<String> dataSourceNames = jdbcDataSourceBuildItems.stream().map(i -> i.getName()).collect(Collectors.toSet());
resource.produce(new NativeImageResourceBuildItem(getChangeLogs(dataSourceNames, liquibaseBuildConfig).toArray(new String[0])));
Stream.of(liquibase.change.Change.class, liquibase.changelog.ChangeLogHistoryService.class, liquibase.command.LiquibaseCommand.class, liquibase.database.Database.class, liquibase.database.DatabaseConnection.class, liquibase.datatype.LiquibaseDataType.class, liquibase.diff.compare.DatabaseObjectComparator.class, liquibase.diff.DiffGenerator.class, liquibase.diff.output.changelog.ChangeGenerator.class, liquibase.executor.Executor.class, liquibase.license.LicenseService.class, liquibase.lockservice.LockService.class, liquibase.logging.LogService.class, liquibase.parser.ChangeLogParser.class, liquibase.parser.NamespaceDetails.class, liquibase.parser.SnapshotParser.class, liquibase.precondition.Precondition.class, liquibase.serializer.ChangeLogSerializer.class, liquibase.serializer.SnapshotSerializer.class, liquibase.servicelocator.ServiceLocator.class, liquibase.snapshot.SnapshotGenerator.class, liquibase.sqlgenerator.SqlGenerator.class, liquibase.structure.DatabaseObject.class, liquibase.hub.HubService.class).forEach(t -> consumeService(t, (serviceClass, implementations) -> {
services.produce(new ServiceProviderBuildItem(serviceClass.getName(), implementations.toArray(new String[0])));
reflective.produce(new ReflectiveClassBuildItem(true, true, false, implementations.toArray(new String[0])));
}));
// Register Precondition services, and the implementation class for reflection while also registering fields for reflection
consumeService(liquibase.precondition.Precondition.class, (serviceClass, implementations) -> {
services.produce(new ServiceProviderBuildItem(serviceClass.getName(), implementations.toArray(new String[0])));
reflective.produce(new ReflectiveClassBuildItem(true, true, true, implementations.toArray(new String[0])));
});
// CommandStep implementations are needed
consumeService(liquibase.command.CommandStep.class, (serviceClass, implementations) -> {
services.produce(new ServiceProviderBuildItem(serviceClass.getName(), implementations.toArray(new String[0])));
reflective.produce(new ReflectiveClassBuildItem(true, false, false, implementations.toArray(new String[0])));
for (String implementation : implementations) {
runtimeInitialized.produce(new RuntimeInitializedClassBuildItem(implementation));
}
});
// liquibase XSD
resource.produce(new NativeImageResourceBuildItem("www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd", "www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd", "www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.7.xsd", "www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd", "www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.9.xsd", "www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.10.xsd", "www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.0.xsd", "www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd", "www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.2.xsd", "www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.3.xsd", "www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.4.xsd", "www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.5.xsd", "www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.6.xsd", "www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.7.xsd", "www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.8.xsd", "www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.9.xsd", "www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd", "www.liquibase.org/xml/ns/pro/liquibase-pro-3.8.xsd", "www.liquibase.org/xml/ns/pro/liquibase-pro-3.9.xsd", "www.liquibase.org/xml/ns/pro/liquibase-pro-3.10.xsd", "www.liquibase.org/xml/ns/pro/liquibase-pro-4.0.xsd", "www.liquibase.org/xml/ns/pro/liquibase-pro-4.1.xsd", "www.liquibase.org/xml/ns/pro/liquibase-pro-4.2.xsd", "www.liquibase.org/xml/ns/pro/liquibase-pro-4.3.xsd", "www.liquibase.org/xml/ns/pro/liquibase-pro-4.4.xsd", "www.liquibase.org/xml/ns/pro/liquibase-pro-4.5.xsd", "www.liquibase.org/xml/ns/pro/liquibase-pro-4.6.xsd", "www.liquibase.org/xml/ns/pro/liquibase-pro-4.7.xsd", "www.liquibase.org/xml/ns/pro/liquibase-pro-4.8.xsd", "www.liquibase.org/xml/ns/pro/liquibase-pro-4.9.xsd", "liquibase.build.properties"));
// liquibase resource bundles
resourceBundle.produce(new NativeImageResourceBundleBuildItem("liquibase/i18n/liquibase-core"));
}
Aggregations