Skip to content

Commit

Permalink
Merge pull request #8001 from aloubyansky/prefer-combined-index
Browse files Browse the repository at this point in the history
Replace ApplicationIndexBuildItem with CombinedIndexBuildItem where it makes sense
  • Loading branch information
gsmet authored Mar 26, 2020
2 parents 753d8d9 + 403bf6c commit d67747f
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
* <li>{@link ValidationPhaseBuildItem}</li>
* </ol>
* These build items are especially useful if an extension needs to produce other build items within the given phase.
*
*
* @see BeanProcessor
*/
public class ArcProcessor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import io.quarkus.deployment.GeneratedClassGizmoAdaptor;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.ApplicationIndexBuildItem;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.DeploymentClassLoaderBuildItem;
import io.quarkus.deployment.builditem.GeneratedClassBuildItem;
Expand All @@ -40,7 +39,6 @@ void produceConfigPropertiesMetadata(CombinedIndexBuildItem combinedIndex, ArcCo

@BuildStep
void setup(CombinedIndexBuildItem combinedIndex,
ApplicationIndexBuildItem applicationIndex,
List<ConfigPropertiesMetadataBuildItem> configPropertiesMetadataList,
BuildProducer<GeneratedClassBuildItem> generatedClasses,
BuildProducer<GeneratedBeanBuildItem> generatedBeans,
Expand Down Expand Up @@ -89,7 +87,7 @@ void setup(CombinedIndexBuildItem combinedIndex,
boolean needsValidation = ClassConfigPropertiesUtil.addProducerMethodForClassConfigProperties(
deploymentClassLoader.getClassLoader(), classInfo, producerClassCreator,
configPropertiesMetadata.getPrefix(), configPropertiesMetadata.getNamingStrategy(),
applicationIndex.getIndex(), configProperties);
combinedIndex.getIndex(), configProperties);
if (needsValidation) {
configClassesThatNeedValidation.add(classInfo.name());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-deployment</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-elytron-security</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-elytron-security-deployment</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Set;
import java.util.stream.Stream;
Expand All @@ -34,7 +34,7 @@
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.Index;
import org.jboss.jandex.IndexView;

import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.arc.deployment.BeanContainerListenerBuildItem;
Expand All @@ -45,7 +45,7 @@
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.ApplicationArchivesBuildItem;
import io.quarkus.deployment.builditem.ApplicationIndexBuildItem;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.HotDeploymentWatchedFileBuildItem;
Expand Down Expand Up @@ -78,7 +78,7 @@ InfinispanPropertiesBuildItem setup(ApplicationArchivesBuildItem applicationArch
BuildProducer<AdditionalBeanBuildItem> additionalBeans,
BuildProducer<ExtensionSslNativeSupportBuildItem> sslNativeSupport,
BuildProducer<NativeImageConfigBuildItem> nativeImageConfig,
ApplicationIndexBuildItem applicationIndexBuildItem) throws ClassNotFoundException, IOException {
CombinedIndexBuildItem applicationIndexBuildItem) throws ClassNotFoundException, IOException {

feature.produce(new FeatureBuildItem(FeatureBuildItem.INFINISPAN_CLIENT));
additionalBeans.produce(AdditionalBeanBuildItem.unremovableOf(InfinispanClientProducer.class));
Expand Down Expand Up @@ -114,40 +114,42 @@ InfinispanPropertiesBuildItem setup(ApplicationArchivesBuildItem applicationArch

InfinispanClientProducer.replaceProperties(properties);

Index index = applicationIndexBuildItem.getIndex();
IndexView index = applicationIndexBuildItem.getIndex();

// This is always non null
Object marshaller = properties.get(ConfigurationProperties.MARSHALLER);

if (marshaller instanceof ProtoStreamMarshaller) {
ApplicationArchive applicationArchive = applicationArchivesBuildItem.getRootArchive();
// If we have properties file we may have to care about
Path metaPath = applicationArchive.getChildPath(META_INF);

if (metaPath != null) {
try (Stream<Path> dirElements = Files.list(metaPath)) {
Iterator<Path> protoFiles = dirElements
.filter(Files::isRegularFile)
.filter(p -> p.toString().endsWith(PROTO_EXTENSION))
.iterator();
// We monitor the entire meta inf directory if properties are available
if (protoFiles.hasNext()) {
// Quarkus doesn't currently support hot deployment watching directories
// hotDeployment.produce(new HotDeploymentConfigFileBuildItem(META_INF));
}

while (protoFiles.hasNext()) {
Path path = protoFiles.next();
byte[] bytes = Files.readAllBytes(path);
// This uses the default file encoding - should we enforce UTF-8?
properties.put(InfinispanClientProducer.PROTOBUF_FILE_PREFIX + path.getFileName().toString(),
new String(bytes, StandardCharsets.UTF_8));
for (ApplicationArchive applicationArchive : applicationArchivesBuildItem.getAllApplicationArchives()) {
// If we have properties file we may have to care about
Path metaPath = applicationArchive.getChildPath(META_INF);

if (metaPath != null) {
try (Stream<Path> dirElements = Files.list(metaPath)) {
Iterator<Path> protoFiles = dirElements
.filter(Files::isRegularFile)
.filter(p -> p.toString().endsWith(PROTO_EXTENSION))
.iterator();
// We monitor the entire meta inf directory if properties are available
if (protoFiles.hasNext()) {
// Quarkus doesn't currently support hot deployment watching directories
// hotDeployment.produce(new HotDeploymentConfigFileBuildItem(META_INF));
}

while (protoFiles.hasNext()) {
Path path = protoFiles.next();
System.out.println(" " + path.toAbsolutePath());
byte[] bytes = Files.readAllBytes(path);
// This uses the default file encoding - should we enforce UTF-8?
properties.put(InfinispanClientProducer.PROTOBUF_FILE_PREFIX + path.getFileName().toString(),
new String(bytes, StandardCharsets.UTF_8));
}
}
}
}

InfinispanClientProducer.handleProtoStreamRequirements(properties);
Set<ClassInfo> initializerClasses = index.getAllKnownImplementors(DotName.createSimple(
Collection<ClassInfo> initializerClasses = index.getAllKnownImplementors(DotName.createSimple(
SerializationContextInitializer.class.getName()));
Set<SerializationContextInitializer> initializers = new HashSet<>(initializerClasses.size());
for (ClassInfo ci : initializerClasses) {
Expand All @@ -168,7 +170,7 @@ InfinispanPropertiesBuildItem setup(ApplicationArchivesBuildItem applicationArch
}

// Add any user project listeners to allow reflection in native code
List<AnnotationInstance> listenerInstances = index.getAnnotations(
Collection<AnnotationInstance> listenerInstances = index.getAnnotations(
DotName.createSimple(ClientListener.class.getName()));
for (AnnotationInstance instance : listenerInstances) {
AnnotationTarget target = instance.target();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import io.quarkus.arc.deployment.UnremovableBeanBuildItem;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.ApplicationIndexBuildItem;
import io.quarkus.deployment.builditem.BytecodeTransformerBuildItem;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
Expand Down Expand Up @@ -59,7 +58,6 @@ UnremovableBeanBuildItem ensureBeanLookupAvailable() {

@BuildStep
void build(CombinedIndexBuildItem index,
ApplicationIndexBuildItem applicationIndex,
BuildProducer<BytecodeTransformerBuildItem> transformers,
HibernateEnhancersRegisteredBuildItem hibernateMarker,
BuildProducer<PanacheEntityClassesBuildItem> entityClasses) throws Exception {
Expand Down Expand Up @@ -109,7 +107,7 @@ void build(CombinedIndexBuildItem index,
MetamodelInfo<EntityModel<EntityField>> modelInfo = modelEnhancer.getModelInfo();
if (modelInfo.hasEntities()) {
PanacheFieldAccessEnhancer panacheFieldAccessEnhancer = new PanacheFieldAccessEnhancer(modelInfo);
for (ClassInfo classInfo : applicationIndex.getIndex().getKnownClasses()) {
for (ClassInfo classInfo : index.getIndex().getKnownClasses()) {
String className = classInfo.name().toString();
if (!modelClasses.contains(className)) {
transformers.produce(new BytecodeTransformerBuildItem(className, panacheFieldAccessEnhancer));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import io.quarkus.deployment.GeneratedClassGizmoAdaptor;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.ApplicationIndexBuildItem;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.GeneratedClassBuildItem;
import io.quarkus.gizmo.BytecodeCreator;
Expand Down Expand Up @@ -77,7 +77,7 @@ void registerSecurityInterceptors(BuildProducer<InterceptorBindingRegistrarBuild
}

@BuildStep
void addSpringSecuredSecurityCheck(ApplicationIndexBuildItem index,
void addSpringSecuredSecurityCheck(CombinedIndexBuildItem index,
BuildProducer<AdditionalSecurityCheckBuildItem> additionalSecurityCheckBuildItems) {

Set<MethodInfo> methodsWithSecurityAnnotation = new HashSet<>();
Expand Down Expand Up @@ -175,7 +175,7 @@ private boolean isPublicNonStaticNonConstructor(MethodInfo methodInfo) {

@BuildStep
void locatePreAuthorizedInstances(
ApplicationIndexBuildItem index,
CombinedIndexBuildItem index,
BuildProducer<SpringPreAuthorizeAnnotatedMethodBuildItem> springPreAuthorizeAnnotatedMethods,
BuildProducer<AnnotationsTransformerBuildItem> annotationsTransformer) {
Map<MethodInfo, AnnotationInstance> result = new HashMap<>();
Expand Down Expand Up @@ -268,7 +268,7 @@ public void transform(TransformationContext transformationContext) {
* The generation needs to be done in it's own build step otherwise we can end up with build cycle errors
*/
@BuildStep
void generateNecessarySupportClasses(ApplicationIndexBuildItem index,
void generateNecessarySupportClasses(CombinedIndexBuildItem index,
SpringPreAuthorizeAnnotatedMethodBuildItem springPreAuthorizeAnnotatedMethods,
BuildProducer<GeneratedBeanBuildItem> generatedBeans,
BuildProducer<UnremovableBeanBuildItem> unremovableBeans) {
Expand Down Expand Up @@ -343,7 +343,7 @@ void generateNecessarySupportClasses(ApplicationIndexBuildItem index,
}

@BuildStep
void addSpringPreAuthorizeSecurityCheck(ApplicationIndexBuildItem index,
void addSpringPreAuthorizeSecurityCheck(CombinedIndexBuildItem index,
SpringPreAuthorizeAnnotatedMethodBuildItem springPreAuthorizeAnnotatedMethods,
SpringBeanNameToDotNameBuildItem springBeanNames,
BuildProducer<AdditionalSecurityCheckBuildItem> additionalSecurityChecks,
Expand Down

0 comments on commit d67747f

Please sign in to comment.