This module lets you maintain your pom.xml
files using Jamal macros.
Warning
|
This project is a Maven extension. Maven extensions run before Maven, and they are different from Maven plugins. The Jamal project supports Maven providing a plugin as well as an extension. In this documentation, we talk about the use of the extension. You can use the plugin to aid the use of the extension. The way to support the use of the extension is also documented here. The documentation clearly distinguishes the extension from the plugin. |
Create a .mvn
in your project root to use this module.
This directory will contain the file extensions.xml
with the content:
<?xml version="1.0" encoding="UTF-8"?>
<extensions>
<extension>
<groupId>com.javax0.jamal</groupId>
<artifactId>jamal-maven-extension</artifactId>
<version>2.8.2-SNAPSHOT</version>
</extension>
</extensions>
When you start Maven, it will read the pom.xml.jam
or pom.jam
file, convert it using Jamal and create the pom.xml
file.
Note
|
The actual process is the following.
When a user invokes Maven, it looks at the Maven later asks for the extension to load the project object model from this file.
The extension knows at this point that the generated
|
The created pom.xml
is saved to the directory and not removed after it was processed.
It is also available for the IDE, which may not read the macro enhanced POM file.
You can add it to your source control if you wish.
When you want to convert a project to use the Jamal maven extension you only have to
-
create the
.mvn
directory -
create the
extensions.xml
file -
rename the existing
pom.xml
files topom.jam
.
When you have a multimodule project this can be cumbersome and error-prone. To automate this, the Jamal Maven plugin can be started with the command line
mvn -Djamalize=true com.javax0.jamal:jamal-maven-plugin:2.8.2-SNAPSHOT:jamal
from the top level project directory.
The plugin will scan all the directories from the current and below and if there is only a pom.xml
in the project directory, but no pom.jam
nor pom.xml.jam
then the plugin will copy the pom.xml
to pom.jam
.
It is enough to have a single .mvn
directory at the top level in the project.
When you want to use a new version of the Jamal Maven Extension simply edit the .mvn/extensions.xml
file and replace the version number.
You can use the extension itself to maintain the extensions.xml
file.
The extension looks into the .mvn
directory of the project.
If there is an extensions.jam
or extensions.xml.jam
file in there, it will be used to generate and overwrite the extensions.xml
file.
Since the extensions.xml
is small it may be pointless to maintain it that way, but the possibility exists.
The Jamal project itself could have the following extensions.jam
file in the project’s root directory:
{@import [noCache] https://raw.githubusercontent.com/verhas/jamal/master/version.jim}
{#thinXml
extensions>
extension>
groupId>com.javax0.jamal
artifactId>jamal-maven-extension
version>{LAST_RELEASE}
}
This will always use the latest release version of the extension and keeps the extensions.xml
file up to date.
If you use {VERSION}
instead of {LAST_RELEASE}
in the extensions.jam
file, the extension will use the actual, possibly development SNAPSHOT version of the project.
When a new release is available it will update the version in the extensions.xml
and be used during the next build.
The actually running build does not restart with the newer version.
This feature does not work if the version configured in the extensions.xml
file is older than 1.10.0.
The feature was introduced in 1.10.0.
Note
|
Jamal’s actual The file ~/.jamal/cache/properties/com/githubusercontent/raw/verhas/jamal/master/version.jim is a properties file.
Adding |
Note
|
Remove the .mv directory and the Jamal source files, while keeping the generated pom.xml files.
|
It may happen that, for some reason, you want to get rid of the extension. The reasons can be various. The maintenance of the project is passed on to a team that is not knowledgeable about Jamal. A new corporate policy may exclude external tools or restrict the extensions and plugins you can use with Maven. You may run into some unforeseen complexity problem using Jamal, and you may not have time to debug your macros. It is straightforward to revert the operation to standard Maven compilation temporarily or final in any of those cases.
This extension retains the XML format as opposed to Polyglot Maven, where you use a Java, Kotlin, Yaml, etc., based DSL instead of XML.
You do not need any conversion step from DSL to XML; the pom.xml
is always there.
What you have to do to revert the operation to standard Maven and pom.xml
based compilation is to remove the .mvn
directory.
If the reverting to standard pom.xml
based compilation is final, then do not forget to remove the .mvn
directory from the source control.
If there is an error processing the Jamal file or XML formatting, the extension will give a very detailed stack trace.
Jamal can also be debugged as described in the debugger documentation.
You have to set an environment variable JAMAL_DEBUG
to be http:8080
, start Maven, and when the debugger pauses, open http://localhost:8080
.
(You can use any other port.)
The commands you will apply are:
export JAMAL_DEBUG=http:8080
mvn verify
unset JAMAL_DEBUG
The extension is compatible with the Jamal Maven plugin so that you can generate the pom.xml
file with command mvn -f genpom.xml
.
When Maven loads the Jamal Maven Extension, it recursively loads the dependencies of the artifact. The dependencies configured are the followings:
This module is the Jamal execution engine. It is needed to execute Jamal. The module does not provide macros.
This module provides snippet macros.
For further information read the documentation of the module.
This module lets you call Jamal processing some part of the code in a separate processor.
For further information read the documentation of the module.
For further information read the documentation of the module.
This module lets you convert Markdown to HTML. This module is mainly practical when you embed Jamal macros in a JavaDoc and use the Jamal doclet extension. I do not see much use here.
For further information read the documentation of the module.
For further information read the documentation of the module.
This module provides macros that can read, write and manipulate YAML data. This macro package may be handy if you use macros that build up the POM structure in memory as a YAML structure. There is a macro that can convert the built-up YAML structure as XML. Although the conversion from Yaml to XML is limited, it may be very well suited to build up POM structures. The current macros used in the Jamal projects and some other projects handle the POM structure as XML text and not as structure. Managing and building up a structure would be much more powerful. If you want to do anything like that, the in-memory Yaml structures these macros can manage are excellent for the purpose.
For further information read the documentation of the module.
This module provides macros that can read, write and manipulate JSON data.
For further information read the documentation of the module.
This module gives you assertion macros that can fail if certain conditions are not met.
For further information read the documentation of the module.
This module does not provide any macro, but it has to be on the classpath to start the debugger. A brief introduction is described above on how to start the Jamal processing when compiling a `pom.xml.jam.
For further information read the documentation of the module.
This module provides a macro to mock the behavior of built-in macros. This is mainly when debugging or testing the functionality of some macro packages.
For further information read the documentation of the module.
This module extends Jamal with a very simple "BASIC" like programming language.
For further information read the documentation of the module.
This library provides Java services that the Jamal file handling uses, so that you can use reference resources from inside maven artifacts over the network.
For further information read the documentation of the module.
This library provides Java services that the Jamal file handling uses, so that you can use resources from inside JAR files.
For further information read the documentation of the module.
The library provides macros that can load Java Built-in Macros from Maven artifacts.
For further information read the documentation of the module.
The library provides macros that can load Java Built-in Macros from Maven artifacts.
For further information read the documentation of the module.
For further information read the documentation of the module.
For further information read the documentation of the module.
For further information read the documentation of the module.