KEYCLOAK-11678 Remove dummy resource. Adding keycloak-services and liquibase to jandex indexing
This commit is contained in:
parent
a9a719b88c
commit
4123b7a91e
6 changed files with 40 additions and 129 deletions
|
@ -95,69 +95,6 @@
|
|||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>extract-liquibase-for-indexing</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>unpack-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<includeGroupIds>org.liquibase</includeGroupIds>
|
||||
<outputDirectory>${project.build.directory}/liquibase-extracted</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jboss.jandex</groupId>
|
||||
<artifactId>jandex-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-index</id>
|
||||
<goals>
|
||||
<goal>jandex</goal>
|
||||
</goals>
|
||||
<phase>process-sources</phase>
|
||||
<configuration>
|
||||
<indexName>liquibase.idx</indexName>
|
||||
<processDefaultFileSet>false</processDefaultFileSet>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>${project.build.directory}/liquibase-extracted</directory>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-liquibase-index</id>
|
||||
<phase>process-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/classes/</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${project.build.directory}/liquibase-extracted</directory>
|
||||
<includes>
|
||||
<include>META-INF/liquibase.idx</include>
|
||||
</includes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package org.keycloak.quarkus.deployment;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -11,11 +9,11 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
|
||||
import org.jboss.jandex.AnnotationInstance;
|
||||
import org.jboss.jandex.ClassInfo;
|
||||
import org.jboss.jandex.DotName;
|
||||
import org.jboss.jandex.Index;
|
||||
import org.jboss.jandex.IndexReader;
|
||||
import org.jboss.jandex.IndexView;
|
||||
import org.keycloak.connections.jpa.updater.liquibase.lock.CustomInsertLockRecordGenerator;
|
||||
import org.keycloak.connections.jpa.updater.liquibase.lock.CustomLockDatabaseChangeLogGenerator;
|
||||
import org.keycloak.connections.jpa.updater.liquibase.lock.DummyLockService;
|
||||
|
@ -37,48 +35,44 @@ class LiquibaseProcessor {
|
|||
|
||||
@Record(ExecutionTime.STATIC_INIT)
|
||||
@BuildStep
|
||||
void configure(KeycloakRecorder recorder) {
|
||||
void configure(KeycloakRecorder recorder, CombinedIndexBuildItem indexBuildItem) {
|
||||
DotName liquibaseServiceName = DotName.createSimple(LiquibaseService.class.getName());
|
||||
Map<String, List<String>> services = new HashMap<>();
|
||||
|
||||
try (InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/liquibase.idx")) {
|
||||
IndexReader reader = new IndexReader(in);
|
||||
Index index = reader.read();
|
||||
for (Class<?> c : Arrays.asList(liquibase.diff.compare.DatabaseObjectComparator.class,
|
||||
liquibase.parser.NamespaceDetails.class,
|
||||
liquibase.precondition.Precondition.class,
|
||||
Database.class,
|
||||
ChangeLogParser.class,
|
||||
liquibase.change.Change.class,
|
||||
liquibase.snapshot.SnapshotGenerator.class,
|
||||
liquibase.changelog.ChangeLogHistoryService.class,
|
||||
liquibase.datatype.LiquibaseDataType.class,
|
||||
liquibase.executor.Executor.class,
|
||||
LockService.class,
|
||||
SqlGenerator.class)) {
|
||||
List<String> impls = new ArrayList<>();
|
||||
services.put(c.getName(), impls);
|
||||
Set<ClassInfo> classes = new HashSet<>();
|
||||
if (c.isInterface()) {
|
||||
classes.addAll(index.getAllKnownImplementors(DotName.createSimple(c.getName())));
|
||||
} else {
|
||||
classes.addAll(index.getAllKnownSubclasses(DotName.createSimple(c.getName())));
|
||||
IndexView index = indexBuildItem.getIndex();
|
||||
|
||||
for (Class<?> c : Arrays.asList(liquibase.diff.compare.DatabaseObjectComparator.class,
|
||||
liquibase.parser.NamespaceDetails.class,
|
||||
liquibase.precondition.Precondition.class,
|
||||
Database.class,
|
||||
ChangeLogParser.class,
|
||||
liquibase.change.Change.class,
|
||||
liquibase.snapshot.SnapshotGenerator.class,
|
||||
liquibase.changelog.ChangeLogHistoryService.class,
|
||||
liquibase.datatype.LiquibaseDataType.class,
|
||||
liquibase.executor.Executor.class,
|
||||
LockService.class,
|
||||
SqlGenerator.class)) {
|
||||
List<String> impls = new ArrayList<>();
|
||||
services.put(c.getName(), impls);
|
||||
Set<ClassInfo> classes = new HashSet<>();
|
||||
if (c.isInterface()) {
|
||||
classes.addAll(index.getAllKnownImplementors(DotName.createSimple(c.getName())));
|
||||
} else {
|
||||
classes.addAll(index.getAllKnownSubclasses(DotName.createSimple(c.getName())));
|
||||
}
|
||||
for (ClassInfo found : classes) {
|
||||
if (Modifier.isAbstract(found.flags()) ||
|
||||
Modifier.isInterface(found.flags()) ||
|
||||
!found.hasNoArgsConstructor() ||
|
||||
!Modifier.isPublic(found.flags())) {
|
||||
continue;
|
||||
}
|
||||
for (ClassInfo found : classes) {
|
||||
if (Modifier.isAbstract(found.flags()) ||
|
||||
Modifier.isInterface(found.flags()) ||
|
||||
!found.hasNoArgsConstructor() ||
|
||||
!Modifier.isPublic(found.flags())) {
|
||||
continue;
|
||||
}
|
||||
AnnotationInstance annotationInstance = found.classAnnotation(liquibaseServiceName);
|
||||
if (annotationInstance == null || !annotationInstance.value("skip").asBoolean()) {
|
||||
impls.add(found.name().toString());
|
||||
}
|
||||
AnnotationInstance annotationInstance = found.classAnnotation(liquibaseServiceName);
|
||||
if (annotationInstance == null || !annotationInstance.value("skip").asBoolean()) {
|
||||
impls.add(found.name().toString());
|
||||
}
|
||||
}
|
||||
} catch (IOException cause) {
|
||||
throw new RuntimeException("Failed to get liquibase jandex index", cause);
|
||||
}
|
||||
|
||||
services.put(Logger.class.getName(), Arrays.asList(KeycloakLogger.class.getName()));
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
package org.keycloak.services.resources;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
/**
|
||||
* Quarkus doesn't pick up the Application if there's no JAX-RS endpoints
|
||||
*/
|
||||
@Path("/dummy")
|
||||
public class Dummy {
|
||||
|
||||
@Inject
|
||||
EntityManagerFactory entityManagerFactory;
|
||||
|
||||
// ...and doesn't load Resteasy providers unless there is at least one resource method
|
||||
@GET
|
||||
public String hello() {
|
||||
return "Hello World!";
|
||||
}
|
||||
|
||||
}
|
|
@ -7,3 +7,8 @@ quarkus.package.user-providers-directory=../providers
|
|||
quarkus.http.root-path=/auth
|
||||
quarkus.application.name=Keycloak
|
||||
quarkus.banner.enabled=false
|
||||
|
||||
quarkus.index-dependency.kc-services-idx.group-id=org.keycloak
|
||||
quarkus.index-dependency.kc-services-idx.artifact-id=keycloak-services
|
||||
quarkus.index-dependency.liquibase-idx.group-id=org.liquibase
|
||||
quarkus.index-dependency.liquibase-idx.artifact-id=liquibase-core
|
||||
|
|
|
@ -37,7 +37,6 @@ import java.util.Properties;
|
|||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Provider
|
||||
public class KeycloakErrorHandler implements ExceptionMapper<Throwable> {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(KeycloakErrorHandler.class);
|
||||
|
|
|
@ -35,7 +35,6 @@ import java.util.stream.Stream;
|
|||
* @author <a href="mailto:bill@burkecentral.com">Bill Burke</a>
|
||||
* @version $Revision: 1 $
|
||||
*/
|
||||
@Provider
|
||||
public class ObjectMapperResolver implements ContextResolver<ObjectMapper> {
|
||||
protected ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
|
|
Loading…
Reference in a new issue