diff --git a/app/src/main/java/hello/App.java b/app/src/main/java/hello/App.java
index f83ec43..43a1870 100644
--- a/app/src/main/java/hello/App.java
+++ b/app/src/main/java/hello/App.java
@@ -6,7 +6,6 @@ public class App extends Site {
public void setup() {
var hello = get("/hello", c -> c.print(c.template("hello")));
get("/", c -> c.redirect(hello));
- get("/world", c -> c.print(c.template("world")));
}
public static void main(String[] args) {
diff --git a/app/src/main/templates/hello.html b/app/src/main/resources/templates/hello.html
similarity index 100%
rename from app/src/main/templates/hello.html
rename to app/src/main/resources/templates/hello.html
diff --git a/app/src/main/resources/templates/world.html b/app/src/main/resources/templates/world.html
deleted file mode 100644
index 92637b1..0000000
--- a/app/src/main/resources/templates/world.html
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
- Hello
-
-
-
-
Hello World from src/main/resources/templates
-
-
diff --git a/build-logic/src/main/java/com/uwyn/rife2/gradle/Rife2Plugin.java b/build-logic/src/main/java/com/uwyn/rife2/gradle/Rife2Plugin.java
index aa527b2..985e06f 100644
--- a/build-logic/src/main/java/com/uwyn/rife2/gradle/Rife2Plugin.java
+++ b/build-logic/src/main/java/com/uwyn/rife2/gradle/Rife2Plugin.java
@@ -45,7 +45,7 @@ import java.util.Locale;
import java.util.stream.Collectors;
public class Rife2Plugin implements Plugin {
- public static final List DEFAULT_TEMPLATES_DIRS = List.of("src/main/resources/templates", "src/main/templates");
+ public static final List DEFAULT_TEMPLATES_DIRS = List.of("src/main/resources/templates");
public static final String DEFAULT_GENERATED_RIFE2_CLASSES_DIR = "generated/classes/rife2";
public static final String RIFE2_GROUP = "rife2";
public static final String WEBAPP_SRCDIR = "src/main/webapp";
@@ -71,7 +71,7 @@ public class Rife2Plugin implements Plugin {
exposePrecompiledTemplatesToTestTask(project, configurations, dependencyHandler, precompileTemplates);
configureAgent(project, plugins, rife2Extension, rife2AgentClasspath);
TaskProvider uberJarTask = registerUberJarTask(project, plugins, javaPluginExtension, rife2Extension, tasks, precompileTemplates);
- bundlePrecompiledTemplatesIntoJarFile(tasks, precompileTemplates);
+ bundlePrecompiledTemplatesIntoJarFile(tasks, precompileTemplates, rife2Extension);
configureMavenPublishing(project, plugins, configurations, uberJarTask);
}
@@ -117,14 +117,16 @@ public class Rife2Plugin implements Plugin {
}
private static void bundlePrecompiledTemplatesIntoJarFile(TaskContainer tasks,
- TaskProvider precompileTemplatesTask) {
+ TaskProvider precompileTemplatesTask,
+ Rife2Extension rife2Extension) {
tasks.named("jar", Jar.class, jar -> {
jar.from(precompileTemplatesTask);
// This isn't great because it needs to be hardcoded, in order to avoid the templates
// declared in `src/main/resources/templates` to be included in the jar file.
// which means that if for whatever reason the user also uses the same directory for
// something else, it will be excluded from the jar file.
- jar.exclude("templates");
+ rife2Extension.getPrecompiledTemplateTypes().get().forEach(templateType -> jar.exclude("/templates/**." + templateType.identifier().toLowerCase())
+ );
});
}
diff --git a/build-logic/src/test-projects/minimal/build.gradle b/build-logic/src/test-projects/minimal/build.gradle
index 5bc074f..2212c0f 100644
--- a/build-logic/src/test-projects/minimal/build.gradle
+++ b/build-logic/src/test-projects/minimal/build.gradle
@@ -29,6 +29,7 @@ rife2 {
version = "1.4.0"
useAgent = true
precompiledTemplateTypes.add(TemplateType.HTML)
+ templateDirectories.from(file("src/main/templates"))
}
dependencies {