Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add hints for native build (CP: 24.5) #1076

Merged
merged 1 commit into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.page.AppShellConfigurator;
import com.vaadin.flow.di.LookupInitializer;
import com.vaadin.flow.router.AccessDeniedException;
import com.vaadin.flow.router.HasErrorParameter;
import com.vaadin.flow.router.HasUrlParameter;
import com.vaadin.flow.router.Layout;
import com.vaadin.flow.router.Menu;
import com.vaadin.flow.router.MenuData;
import com.vaadin.flow.router.NotFoundException;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.router.RouteAlias;
import com.vaadin.flow.router.RouterLayout;
Expand All @@ -44,6 +46,8 @@
import com.vaadin.hilla.BrowserCallable;
import com.vaadin.hilla.Endpoint;
import com.vaadin.hilla.EndpointExposed;
import com.vaadin.hilla.crud.filter.Filter;
import com.vaadin.hilla.endpointransfermapper.EndpointTransferMapper;
import com.vaadin.hilla.push.PushEndpoint;
import io.quarkus.arc.deployment.ExcludedTypeBuildItem;
import io.quarkus.bootstrap.classloading.QuarkusClassLoader;
Expand Down Expand Up @@ -98,6 +102,7 @@
import org.jboss.jandex.DotName;
import org.jboss.jandex.IndexView;
import org.objectweb.asm.Opcodes;
import org.springframework.data.domain.Pageable;

import com.github.mcollovati.quarkus.hilla.graal.AtmosphereDeferredInitializerRecorder;
import com.github.mcollovati.quarkus.hilla.graal.DelayedSchedulerExecutorsFactory;
Expand Down Expand Up @@ -221,17 +226,37 @@ void hillaNativeSupport(

IndexView index = combinedIndex.getComputingIndex();
Set<ClassInfo> classes = new HashSet<>();
classes.addAll(index.getAllKnownImplementors(EndpointTransferMapper.Mapper.class));
classes.addAll(getAnnotatedClasses(index, DotName.createSimple(BrowserCallable.class)));
classes.addAll(getAnnotatedClasses(index, DotName.createSimple(Endpoint.class)));
classes.addAll(getAnnotatedClasses(index, DotName.createSimple(EndpointExposed.class)));
classes.add(index.getClassByName(PushEndpoint.class));
classes.add(index.getClassByName(Filter.class));
classes.add(index.getClassByName(Pageable.class));
classes.addAll(getJsonClasses(index));
classes.addAll(index.getAllKnownImplementors(EndpointTransferMapper.Mapper.class));
classes.addAll(index.getClassesInPackage("com.vaadin.hilla.mappedtypes"));
classes.addAll(index.getClassesInPackage("com.vaadin.hilla.runtime.transfertypes"));

if (capabilities.isPresent(QuarkusHillaExtensionProcessor.SPRING_DATA_SUPPORT)) {
classes.add(index.getClassByName("org.springframework.data.repository.Repository"));
classes.add(index.getClassByName("org.springframework.data.repository.CrudRepository"));
classes.add(index.getClassByName("org.springframework.data.domain.Pageable"));
classes.add(index.getClassByName("org.springframework.data.domain.Specification"));
// explicitly register classes not present in the index
reflectiveClass.produce(ReflectiveClassBuildItem.builder(
com.github.mcollovati.quarkus.hilla.crud.spring.CrudRepositoryService.class,
com.github.mcollovati.quarkus.hilla.crud.spring.ListRepositoryService.class)
.constructors()
.methods()
.build());
}
if (capabilities.isPresent(QuarkusHillaExtensionProcessor.PANACHE_SUPPORT)) {
reflectiveClass.produce(ReflectiveClassBuildItem.builder(
com.github.mcollovati.quarkus.hilla.crud.panache.CrudRepositoryService.class,
com.github.mcollovati.quarkus.hilla.crud.panache.ListRepositoryService.class)
.constructors()
.methods()
.build());
}

reflectiveClass.produce(ReflectiveClassBuildItem.builder(classes.stream()
Expand Down Expand Up @@ -283,6 +308,8 @@ void vaadinNativeSupport(
.build());

Set<ClassInfo> classes = new HashSet<>();
classes.add(index.getClassByName(AccessDeniedException.class));
classes.add(index.getClassByName(NotFoundException.class));
classes.addAll(getAnnotatedClasses(index, DotName.createSimple(Route.class)));
classes.addAll(getAnnotatedClasses(index, DotName.createSimple(RouteAlias.class)));
classes.addAll(getAnnotatedClasses(index, DotName.createSimple(Layout.class)));
Expand All @@ -299,6 +326,9 @@ void vaadinNativeSupport(
reflectiveClass.produce(ReflectiveClassBuildItem.builder(classes.stream()
.map(classInfo -> classInfo.name().toString())
.toArray(String[]::new))
.constructors()
.methods()
.fields()
.build());

registerAtmosphereClasses(reflectiveClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
import com.vaadin.hilla.signals.core.registry.SecureSignalsRegistry;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.builditem.BytecodeTransformerBuildItem;
import io.quarkus.gizmo.ClassTransformer;
import io.quarkus.gizmo.MethodDescriptor;
import org.springframework.data.domain.Sort;

import com.github.mcollovati.quarkus.hilla.SpringReplacements;

Expand Down Expand Up @@ -95,6 +98,15 @@ public static void addClassVisitors(BuildProducer<BytecodeTransformerBuildItem>
producer.produce(new BytecodeTransformerBuildItem(
ConfigList.Processor.class.getName(),
(s, classVisitor) -> new NonnullPluginConfigProcessorClassVisitor(classVisitor)));

// Remove sort method that references a type that is not in the shaded deps jar
producer.produce(new BytecodeTransformerBuildItem(Sort.class.getName(), (className, classVisitor) -> {
ClassTransformer transformer = new ClassTransformer(className);
MethodDescriptor sortMethod =
MethodDescriptor.ofMethod(className, "sort", className + "$TypedSort", "java.lang.Class");
transformer.removeMethod(sortMethod);
return transformer.applyTo(classVisitor);
}));
}

@SafeVarargs
Expand Down
1 change: 1 addition & 0 deletions hilla-shaded-deps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@
<include>org/springframework/data/domain/AbstractPageRequest.class</include>
<include>org/springframework/data/domain/Chunk.class</include>
<include>org/springframework/data/domain/KeysetScrollPosition.class</include>
<include>org/springframework/data/domain/Limit**.class</include>
<include>org/springframework/data/domain/OffsetScrollPosition.class</include>
<include>org/springframework/data/domain/ScrollPosition.class</include>
<include>org/springframework/data/domain/ScrollPosition$Direction.class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
import java.util.Set;

import com.vaadin.hilla.Nonnull;
import io.quarkus.runtime.annotations.RegisterForReflection;
import io.quarkus.security.identity.SecurityIdentity;

@RegisterForReflection
public class UserInfo {

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*/
package com.example.application.entities;

import io.quarkus.runtime.annotations.RegisterForReflection;

@RegisterForReflection
public class UserPOJO {

private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
import java.util.Set;

import com.vaadin.hilla.Nonnull;
import io.quarkus.runtime.annotations.RegisterForReflection;
import io.quarkus.security.identity.SecurityIdentity;

@RegisterForReflection
public class UserInfo {

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*/
package com.example.application.entities;

import io.quarkus.runtime.annotations.RegisterForReflection;

@RegisterForReflection
public class UserPOJO {

private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

import java.util.UUID;

import io.quarkus.runtime.annotations.RegisterForReflection;

@RegisterForReflection
public class UserPOJO {

private String id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
import java.util.Set;

import com.vaadin.hilla.Nonnull;
import io.quarkus.runtime.annotations.RegisterForReflection;
import io.quarkus.security.identity.SecurityIdentity;

@RegisterForReflection
public class UserInfo {

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

import java.util.UUID;

import io.quarkus.runtime.annotations.RegisterForReflection;

@RegisterForReflection
public class UserPOJO {

private String id;
Expand Down
Loading