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: check for Vaadin native process (#1297) (CP: 24.6) #1360

Merged
merged 1 commit into from
Mar 4, 2025
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
4 changes: 2 additions & 2 deletions .github/workflows/validation-native.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
id: set-matrix
run: |
test_modules=$(find integration-tests -maxdepth 1 -mindepth 1 -type d -name "*-tests")
test_modules=$(while IFS= read -r mod; do grep -q "%test-security." $mod/src/main/resources/application.properties; echo "{\"name\": \"${mod/integration-tests\//}\", \"path\": \"$mod\", \"security\": $? }"; done <<< "${test_modules}" | jq -s -c '.')
test_modules=$(while IFS= read -r mod; do test -f $mod/src/main/resources/application.properties && grep -q "%test-security." $mod/src/main/resources/application.properties; echo "{\"name\": \"${mod/integration-tests\//}\", \"path\": \"$mod\", \"security\": $? }"; done <<< "${test_modules}" | jq -s -c '.')
echo "modules=${test_modules}" >> "$GITHUB_OUTPUT"
build-and-test-native:
name: Native tests
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:
set -x -e -o pipefail
mvn -V -e -B -ntp verify -am -DtrimStackTrace=false -Dselenide.browserBinary=${{ steps.setup-chrome.outputs.chrome-path }} -Pit-tests,production -Dnative -pl ${{ matrix.module.path }}
- name: Native Security Test
if: ${{ matrix.module.security == 1 }}
if: ${{ matrix.module.security == 0 }}
run: |
set -x -e -o pipefail
mvn -V -e -B -ntp verify -am -DtrimStackTrace=false -Dselenide.browserBinary=${{ steps.setup-chrome.outputs.chrome-path }} -Pit-tests,production -Dnative -Dquarkus.profile=test-security -pl ${{ matrix.module.path }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@

public class QuarkusHillaNativeProcessor {

@BuildStep(onlyIf = IsNativeBuild.class)
@BuildStep(onlyIf = IsNativeBuild.class, onlyIfNot = IsVaadinNativeProcessorAvailable.class)
void patchAtmosphere(CombinedIndexBuildItem index, BuildProducer<BytecodeTransformerBuildItem> producer) {
AtmospherePatches patcher = new AtmospherePatches(index.getComputingIndex());
patcher.apply(producer);
}

@BuildStep(onlyIf = IsNativeBuild.class)
@BuildStep(onlyIf = IsNativeBuild.class, onlyIfNot = IsVaadinNativeProcessorAvailable.class)
@Record(ExecutionTime.RUNTIME_INIT)
@Produce(DefaultRouteBuildItem.class)
void deferAtmosphereInit(
Expand Down Expand Up @@ -156,7 +156,7 @@ void removeHillaSpringBasedClasses(Capabilities capabilities, BuildProducer<Remo
* application is build with subscription key and the license-checker is not
* configured as explicit project dependency.
*/
@BuildStep(onlyIf = IsNativeBuild.class)
@BuildStep(onlyIf = IsNativeBuild.class, onlyIfNot = IsVaadinNativeProcessorAvailable.class)
void generateDummyDauClassesIfLicenseCheckerIsNotPresent(
BuildProducer<GeneratedNativeImageClassBuildItem> producer) {
String dauIntegration = "com.vaadin.pro.licensechecker.dau.DauIntegration";
Expand Down Expand Up @@ -223,6 +223,7 @@ void hillaNativeSupport(
nativeImageResource.produce(NativeImageResourcePatternsBuildItem.builder()
.includePatterns("hilla-openapi\\.json", "hilla-engine-configuration\\.json", "file-routes\\.json")
.includePatterns("META-INF/microprofile-config\\.properties")
.includePatterns("META-INF/maven/com.github.mcollovati/quarkus-hilla-commons/pom\\.properties")
.build());

IndexView index = combinedIndex.getComputingIndex();
Expand Down Expand Up @@ -286,7 +287,7 @@ private Set<ClassInfo> getJsonClasses(IndexView index) {
return classes;
}

@BuildStep
@BuildStep(onlyIfNot = IsVaadinNativeProcessorAvailable.class)
void vaadinNativeSupport(
CombinedIndexBuildItem combinedIndex,
BuildProducer<RuntimeInitializedPackageBuildItem> runtimeInitializedPackage,
Expand All @@ -298,7 +299,7 @@ void vaadinNativeSupport(
nativeImageResource.produce(NativeImageResourcePatternsBuildItem.builder()
.includeGlobs("META-INF/VAADIN/**", "com/vaadin/**", "vaadin-i18n/**")
.includePatterns("org/atmosphere/util/version\\.properties")
.includePatterns("META-INF/maven/com.github.mcollovati/quarkus-hilla-commons/pom\\.properties")
.includePatterns("META-INF/maven/com.vaadin/vaadin-core/pom\\.properties")
.build());

runtimeInitializedPackage.produce(new RuntimeInitializedPackageBuildItem("org.atmosphere.util.analytics"));
Expand Down Expand Up @@ -440,4 +441,20 @@ public boolean getAsBoolean() {
return nativeConfig.enabled();
}
}

public static class IsVaadinNativeProcessorAvailable implements BooleanSupplier {

@Override
public boolean getAsBoolean() {
try {
Class.forName(
"com.vaadin.quarkus.deployment.VaadinQuarkusNativeProcessor",
false,
Thread.currentThread().getContextClassLoader());
return true;
} catch (ClassNotFoundException e) {
return false;
}
}
}
}