Adding a directory can be done via the extension:
```gradle
rife2 {
templateDirectories.from(file("my-template-dir"))
}
```
By default the template directories include both `src/main/templates`
and `src/main/resources/templates`. If you want to ignore those,
then you need to clear the default:
```gradle
rife2 {
templateDirectories.from.clear()
templateDirectories.from(file("my-template-dir"))
}
```
By default, the template was using `src/main/templates` as the source directory
for templates. This has the benefit of properly isolating the templates from
the application classpath: the framework is then responsible for injecting them
to the app runtime in whatever suitable form: either untouched as sources (in
development mode), or precompiled (for production).
With this change, it is also possible to use `src/main/resources/templates` as
a source directory. It _may_ feel more natural to users (although I would disagree),
but it has the drawback that the jars have to be configured to _exclude_ those
resources, because by default whatever is in `src/main/resources` MUST be included
in a jar (independently of the run mode).
It is also possible for the user to configure additional source directories should
they want to.
This commit fixes how templates were reloaded. There was a bug in
the plugin which used the output of the precompiled templates for
development only dependencies, instead of the templates directory.
This caused the templates to be always compiled and added as a
resource on runtime classpath, when we only wanted the raw templates.
This commit also adds functional tests to the build logic, which
can be executed by running `./gradlew build-logic:test`.
This commit adds compatibility with the Maven publish plugin, by
making sure that if the application is published, then the uber
jar is published as a classified artifact (`-uber`) in addition
to the regular jar.
A sample publishing configuration was added to the `app`, with
a "local" publishing repository in <rootproject>/build/repo.
For example, calling `./gradlew pAPTBR` will create the
`build/repo` directory with the corresponding Maven repository
structure after publishing.
The `run` task is considered a development mode, where the templates
should be reloaded live. This means that the `run` task will not
use the precompiled templates, but the source templates instead.
The `test` task will also use precompiled templates, while the
`jar` and `uberJar` tasks will also make sure to bundle precompiled
templates and not the source ones.
This commit introduces a _convention plugin_ for RIFE2 support.
It provides a number of advantages:
- the build logic is clearly separated from the build script,
which now only contains user-specific configuration, like the
framework version or how to configure test logging
- it fixes a number of issues like hardcoded dependencies
(`dependsOn` is in general a mistake)
- it removes the need to resolve the agent path eagerly
- it makes the agent configurable
- it clearly separates the user classpath from the RIFE
classpath (both for precompiling templates and for the agent)
- template compilation is cached
- it avoids the abuse of `src/main/resources` to put
templates and uses a dedicated directory instead, which
removes the need for exclusions
In addition, this should make it relatively straightforward
to convert the convention plugin into a proper RIFE2 plugin,
by extracting the code in `build-logic` into its own
repository then publishing to the Gradle plugin portal.