mirror of
https://github.com/ethauvin/rife2-hello.git
synced 2025-04-24 23:17:13 -07:00
Made "src/main/resources/templates" the only default template dir.
Made the template excludes adapt to the template types that are pre-compiled and use a more restrictive pattern.
This commit is contained in:
parent
b51e36ee73
commit
a3a5c7c380
5 changed files with 7 additions and 16 deletions
|
@ -6,7 +6,6 @@ public class App extends Site {
|
||||||
public void setup() {
|
public void setup() {
|
||||||
var hello = get("/hello", c -> c.print(c.template("hello")));
|
var hello = get("/hello", c -> c.print(c.template("hello")));
|
||||||
get("/", c -> c.redirect(hello));
|
get("/", c -> c.redirect(hello));
|
||||||
get("/world", c -> c.print(c.template("world")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title><!--v title-->Hello<!--/v--></title>
|
|
||||||
<link rel="stylesheet" href="{{v webapp:rootUrl/}}css/style.css?{{v context:paramRandom/}}">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<p>Hello World from src/main/resources/templates</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
|
@ -45,7 +45,7 @@ import java.util.Locale;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class Rife2Plugin implements Plugin<Project> {
|
public class Rife2Plugin implements Plugin<Project> {
|
||||||
public static final List<String> DEFAULT_TEMPLATES_DIRS = List.of("src/main/resources/templates", "src/main/templates");
|
public static final List<String> 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 DEFAULT_GENERATED_RIFE2_CLASSES_DIR = "generated/classes/rife2";
|
||||||
public static final String RIFE2_GROUP = "rife2";
|
public static final String RIFE2_GROUP = "rife2";
|
||||||
public static final String WEBAPP_SRCDIR = "src/main/webapp";
|
public static final String WEBAPP_SRCDIR = "src/main/webapp";
|
||||||
|
@ -71,7 +71,7 @@ public class Rife2Plugin implements Plugin<Project> {
|
||||||
exposePrecompiledTemplatesToTestTask(project, configurations, dependencyHandler, precompileTemplates);
|
exposePrecompiledTemplatesToTestTask(project, configurations, dependencyHandler, precompileTemplates);
|
||||||
configureAgent(project, plugins, rife2Extension, rife2AgentClasspath);
|
configureAgent(project, plugins, rife2Extension, rife2AgentClasspath);
|
||||||
TaskProvider<Jar> uberJarTask = registerUberJarTask(project, plugins, javaPluginExtension, rife2Extension, tasks, precompileTemplates);
|
TaskProvider<Jar> uberJarTask = registerUberJarTask(project, plugins, javaPluginExtension, rife2Extension, tasks, precompileTemplates);
|
||||||
bundlePrecompiledTemplatesIntoJarFile(tasks, precompileTemplates);
|
bundlePrecompiledTemplatesIntoJarFile(tasks, precompileTemplates, rife2Extension);
|
||||||
|
|
||||||
configureMavenPublishing(project, plugins, configurations, uberJarTask);
|
configureMavenPublishing(project, plugins, configurations, uberJarTask);
|
||||||
}
|
}
|
||||||
|
@ -117,14 +117,16 @@ public class Rife2Plugin implements Plugin<Project> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void bundlePrecompiledTemplatesIntoJarFile(TaskContainer tasks,
|
private static void bundlePrecompiledTemplatesIntoJarFile(TaskContainer tasks,
|
||||||
TaskProvider<PrecompileTemplates> precompileTemplatesTask) {
|
TaskProvider<PrecompileTemplates> precompileTemplatesTask,
|
||||||
|
Rife2Extension rife2Extension) {
|
||||||
tasks.named("jar", Jar.class, jar -> {
|
tasks.named("jar", Jar.class, jar -> {
|
||||||
jar.from(precompileTemplatesTask);
|
jar.from(precompileTemplatesTask);
|
||||||
// This isn't great because it needs to be hardcoded, in order to avoid the templates
|
// 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.
|
// 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
|
// 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.
|
// something else, it will be excluded from the jar file.
|
||||||
jar.exclude("templates");
|
rife2Extension.getPrecompiledTemplateTypes().get().forEach(templateType -> jar.exclude("/templates/**." + templateType.identifier().toLowerCase())
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ rife2 {
|
||||||
version = "1.4.0"
|
version = "1.4.0"
|
||||||
useAgent = true
|
useAgent = true
|
||||||
precompiledTemplateTypes.add(TemplateType.HTML)
|
precompiledTemplateTypes.add(TemplateType.HTML)
|
||||||
|
templateDirectories.from(file("src/main/templates"))
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue