How can I use maven properties in site APT files? For example I want to use ${project.version} in the index.apt so I can always refer to the latest version without manually changing the index.apt file before deploying the site.
Asked
Active
Viewed 1,955 times
2 Answers
13
Found it. Just had to rename the apt files to *.apt.vm. Maven then pipes the files through Velocity which can process the properties.

kayahr
- 20,913
- 29
- 99
- 147
6
My download.apt.vm looks like this:
Download
{{${sitePublishUrl}}}
where the pom.xml contains
<properties>
<sitePublishBase>http://artifactory.foo.com/mvn/libs-release-local</sitePublishBase>
<sitePublishUrl>${sitePublishBase}/${project.groupId}/${project.artifactId}/${project.version}</sitePublishUrl>
</properties>
Note: custom properties containing a dot (e.g. ${my.repository}
) will not work. This is a limitation of Velocity. Instead use something like ${myRepository}
.
See also http://maven.apache.org/plugins/maven-site-plugin/examples/creating-content.html#Filtering

leo
- 3,528
- 3
- 20
- 19
-
Append something to the link and add text: {{{${gh-url}/examples/java-examples}Blub}}. – Jotschi Nov 19 '14 at 12:03
-
1Dotted properties do not work directly, but you can still ask for them from context: `$context.get('my.repository')` – Mrkvozrout Nov 09 '17 at 13:18