Skip to content

Commit

Permalink
Qute: add correct NativeImageResourceBuildItem for custom template root
Browse files Browse the repository at this point in the history
  • Loading branch information
mkouba committed Mar 8, 2024
1 parent 5738ebf commit 9b337c1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2194,7 +2194,7 @@ private void scanPath(Path rootPath, Path path, QuteConfig config, TemplateRoots
Path relativePath = rootPath.relativize(file);
if (templateRoots.isRoot(relativePath)) {
LOGGER.debugf("Found templates dir: %s", file);
scan(file, file, file.getFileName() + "/", watchedPaths, templatePaths,
scan(file, file, relativePath.toString() + File.separatorChar, watchedPaths, templatePaths,
nativeImageResources,
config);
} else if (templateRoots.maybeRoot(relativePath)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import jakarta.inject.Inject;

Expand All @@ -13,6 +15,8 @@
import io.quarkus.builder.BuildChainBuilder;
import io.quarkus.builder.BuildContext;
import io.quarkus.builder.BuildStep;
import io.quarkus.deployment.builditem.ServiceStartBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem;
import io.quarkus.qute.Engine;
import io.quarkus.qute.Template;
import io.quarkus.qute.deployment.TemplateRootBuildItem;
Expand All @@ -38,6 +42,27 @@ public void execute(BuildContext context) {
}
}).produces(TemplateRootBuildItem.class)
.build();

builder.addBuildStep(new BuildStep() {
@Override
public void execute(BuildContext context) {
int found = 0;
List<NativeImageResourceBuildItem> items = context.consumeMulti(NativeImageResourceBuildItem.class);
for (NativeImageResourceBuildItem item : items) {
if (item.getResources().contains("web/public/hello.txt")
|| item.getResources().contains("templates/hi.txt")) {
found++;
}
}
if (found != 2) {
throw new IllegalStateException(items.stream().flatMap(i -> i.getResources().stream())
.collect(Collectors.toList()).toString());

Check failure on line 59 in extensions/qute/deployment/src/test/java/io/quarkus/qute/deployment/templateroot/AdditionalTemplateRootTest.java

View workflow job for this annotation

GitHub Actions / Build summary for 9b337c11c52e8faa4d246c8cab21c50b34ad5fb3

JVM Tests - JDK 17 Windows

java.lang.RuntimeException: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors [error]: Build step io.quarkus.qute.deployment.templateroot.AdditionalTemplateRootTest$1$2@77041ea threw an exception: java.lang.IllegalStateException: [META-INF/services/org.jboss.logmanager.MDCProvider, templates\hi.txt, web\public\hello.txt]
Raw output
java.lang.RuntimeException: 
java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.qute.deployment.templateroot.AdditionalTemplateRootTest$1$2@77041ea threw an exception: java.lang.IllegalStateException: [META-INF/services/org.jboss.logmanager.MDCProvider, templates\hi.txt, web\public\hello.txt]
	at io.quarkus.qute.deployment.templateroot.AdditionalTemplateRootTest$1$2.execute(AdditionalTemplateRootTest.java:59)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
	at java.base/java.lang.Thread.run(Thread.java:840)
	at org.jboss.threads.JBossThread.run(JBossThread.java:501)

	at io.quarkus.test.QuarkusUnitTest.beforeAll(QuarkusUnitTest.java:709)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Caused by: java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.qute.deployment.templateroot.AdditionalTemplateRootTest$1$2@77041ea threw an exception: java.lang.IllegalStateException: [META-INF/services/org.jboss.logmanager.MDCProvider, templates\hi.txt, web\public\hello.txt]
	at io.quarkus.qute.deployment.templateroot.AdditionalTemplateRootTest$1$2.execute(AdditionalTemplateRootTest.java:59)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
	at java.base/java.lang.Thread.run(Thread.java:840)
	at org.jboss.threads.JBossThread.run(JBossThread.java:501)

	at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:334)
	at io.quarkus.runner.bootstrap.AugmentActionImpl.createInitialRuntimeApplication(AugmentActionImpl.java:251)
	at io.quarkus.test.QuarkusUnitTest.beforeAll(QuarkusUnitTest.java:655)
	... 1 more
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
	[error]: Build step io.quarkus.qute.deployment.templateroot.AdditionalTemplateRootTest$1$2@77041ea threw an exception: java.lang.IllegalStateException: [META-INF/services/org.jboss.logmanager.MDCProvider, templates\hi.txt, web\public\hello.txt]
	at io.quarkus.qute.deployment.templateroot.AdditionalTemplateRootTest$1$2.execute(AdditionalTemplateRootTest.java:59)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
	at java.base/java.lang.Thread.run(Thread.java:840)
	at org.jboss.threads.JBossThread.run(JBossThread.java:501)

	at io.quarkus.builder.Execution.run(Execution.java:123)
	at io.quarkus.builder.BuildExecutionBuilder.execute(BuildExecutionBuilder.java:79)
	at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:160)
	at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:330)
	... 3 more
Caused by: java.lang.IllegalStateException: [META-INF/services/org.jboss.logmanager.MDCProvider, templates\hi.txt, web\public\hello.txt]
	at io.quarkus.qute.deployment.templateroot.AdditionalTemplateRootTest$1$2.execute(AdditionalTemplateRootTest.java:59)
	at io.quarkus.builder.BuildContext.run(BuildContext.java:256)
	at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
	at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2513)
	at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1538)
	at java.base/java.lang.Thread.run(Thread.java:840)
	at org.jboss.threads.JBossThread.run(JBossThread.java:501)
}
context.produce(new ServiceStartBuildItem("foo"));
}
}).produces(ServiceStartBuildItem.class)
.consumes(NativeImageResourceBuildItem.class)
.build();
}
};
}
Expand Down

0 comments on commit 9b337c1

Please sign in to comment.