Skip to content

Commit

Permalink
Add support for resource bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Nov 20, 2019
1 parent a94abc6 commit 2641c9a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyBuildItem;
import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.RuntimeReinitializedClassBuildItem;
import io.quarkus.runtime.annotations.RegisterForReflection;
import io.quarkus.runtime.annotations.RegisterProxy;
import io.quarkus.runtime.annotations.RegisterResourceBundle;
import io.quarkus.runtime.annotations.RuntimeInitialized;
import io.quarkus.runtime.annotations.RuntimeReinitialized;

Expand All @@ -45,6 +47,9 @@ public class NativeAnnotationBuildStep {
@Inject
BuildProducer<NativeImageProxyDefinitionBuildItem> proxyDefinition;

@Inject
BuildProducer<NativeImageResourceBuildItem> resourceBundle;

@BuildStep
public void build() throws Exception {
//reflection
Expand Down Expand Up @@ -106,6 +111,14 @@ public void build() throws Exception {
registerProxy(j);
}
}

//resource bundle

for (AnnotationInstance i : combinedIndexBuildItem.getIndex()
.getAnnotations(DotName.createSimple(RegisterResourceBundle.class.getName()))) {
String[] bundles = i.value().asStringArray();
resourceBundle.produce(new NativeImageResourceBuildItem(Arrays.asList(bundles)));
}
}

private void registerProxy(AnnotationInstance i) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.quarkus.runtime.annotations;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Annotation that can be used to register a resource bundle for native mode
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface RegisterResourceBundle {

/**
* The bundles to register
*/
String[] value();
}
6 changes: 6 additions & 0 deletions docs/src/main/asciidoc/writing-native-applications-tips.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,12 @@ proxies for. Note that order is important, so the order of the annotation values
are passed into the proxy create method. This is a repeatable annotation so multiple proxies can be declared on the same
class.

=== Resource Bundles

By default native images do not include resource bundles. You can select the bundles to include with the
`@io.quarkus.runtime.annotations.RegisterResourceBundle` annotation.


[[native-in-extension]]
== Supporting native in a Quarkus extension

Expand Down

0 comments on commit 2641c9a

Please sign in to comment.