Skip to content

Commit

Permalink
Merge pull request #22938 from gsmet/resource-bundle-warning
Browse files Browse the repository at this point in the history
Fix remaining HV/RESTEasy warnings when Kotlin around
  • Loading branch information
gsmet authored Jan 17, 2022
2 parents f4ff3ab + 1cd2dd2 commit 3089ef9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
import io.quarkus.arc.processor.BeanInfo;
import io.quarkus.arc.processor.BuiltinScope;
import io.quarkus.arc.processor.DotNames;
import io.quarkus.bootstrap.classloading.ClassPathElement;
import io.quarkus.bootstrap.classloading.QuarkusClassLoader;
import io.quarkus.deployment.Capabilities;
import io.quarkus.deployment.Capability;
import io.quarkus.deployment.Feature;
Expand All @@ -66,7 +68,7 @@
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.HotDeploymentWatchedFileBuildItem;
import io.quarkus.deployment.builditem.ShutdownContextBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageConfigBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBundleBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveFieldBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveMethodBuildItem;
Expand Down Expand Up @@ -345,29 +347,20 @@ public void build(HibernateValidatorRecorder recorder, RecorderContext recorderC
}

@BuildStep
NativeImageConfigBuildItem nativeImageConfig() {
List<String> potentialHibernateValidatorResourceBundles = List.of(
void optionalResouceBundles(BuildProducer<NativeImageResourceBundleBuildItem> resourceBundles) {
String[] potentialHibernateValidatorResourceBundles = {
AbstractMessageInterpolator.DEFAULT_VALIDATION_MESSAGES,
AbstractMessageInterpolator.USER_VALIDATION_MESSAGES,
AbstractMessageInterpolator.CONTRIBUTOR_VALIDATION_MESSAGES);
List<String> userDefinedHibernateValidatorResourceBundles = new ArrayList<>();
AbstractMessageInterpolator.CONTRIBUTOR_VALIDATION_MESSAGES };

for (String potentialHibernateValidatorResourceBundle : potentialHibernateValidatorResourceBundles) {
if (Thread.currentThread().getContextClassLoader().getResource(potentialHibernateValidatorResourceBundle) != null) {
userDefinedHibernateValidatorResourceBundles.add(potentialHibernateValidatorResourceBundle);
for (ClassPathElement cpe : QuarkusClassLoader.getElements(potentialHibernateValidatorResourceBundle, false)) {
if (cpe.isRuntime()) {
resourceBundles.produce(new NativeImageResourceBundleBuildItem(potentialHibernateValidatorResourceBundle));
break;
}
}
}

if (userDefinedHibernateValidatorResourceBundles.isEmpty()) {
return null;
}

NativeImageConfigBuildItem.Builder builder = NativeImageConfigBuildItem.builder();
for (String hibernateValidatorResourceBundle : userDefinedHibernateValidatorResourceBundles) {
builder.addResourceBundle(hibernateValidatorResourceBundle);
}

return builder.build();
}

@BuildStep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,14 @@
import io.quarkus.arc.processor.BuiltinScope;
import io.quarkus.arc.processor.DotNames;
import io.quarkus.arc.processor.Transformation;
import io.quarkus.bootstrap.classloading.ClassPathElement;
import io.quarkus.bootstrap.classloading.QuarkusClassLoader;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.BytecodeTransformerBuildItem;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageConfigBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBundleBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyBuildItem;
import io.quarkus.deployment.util.JandexUtil;
Expand Down Expand Up @@ -181,14 +183,14 @@ static final class ResteasyConfig {
}

@BuildStep
NativeImageConfigBuildItem config() {
if (Thread.currentThread().getContextClassLoader().getResource(MESSAGES_RESOURCE_BUNDLE) == null) {
return null;
NativeImageResourceBundleBuildItem optionalResourceBundle() {
for (ClassPathElement cpe : QuarkusClassLoader.getElements(MESSAGES_RESOURCE_BUNDLE, false)) {
if (cpe.isRuntime()) {
return new NativeImageResourceBundleBuildItem(MESSAGES_RESOURCE_BUNDLE);
}
}

return NativeImageConfigBuildItem.builder()
.addResourceBundle(MESSAGES_RESOURCE_BUNDLE)
.build();
return null;
}

@BuildStep
Expand Down

0 comments on commit 3089ef9

Please sign in to comment.