Hi!
I'm having trouble to understand how maven site descriptor interpolation
is designed to work in multi-module sites using inheritance as described
here
(https://maven.apache.org/plugins/maven-site-plugin/examples/multimodule.html).
Here (https://maven.apache.org/plugins/maven-site-plugin/migrate.html)
it is stated that interpolation is now done after inheritance and new
early interpolation feature has been added to preserve backward
compatible behavior.
Here
(https://maven.apache.org/doxia/doxia-sitetools/doxia-integration-tools/index.html)
it is stated that interpolation can be late or early. I'm not sure if
this mean that late and early are mutually exclusive or not.
As far as I can discern from source code of DefaultSiteTool class in
doxia-site-tools-1.8.1
(https://github.com/apache/maven-doxia-sitetools/blob/947289e162a08c1002e304193c448f8d4b229285/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java#L473),
implementation intention is to first do early interpolation and then
"classical" late interpolation after inheritance is done.
I have written following master pom and site descriptor to test this
behavior
https://repo1.maven.org/maven2/com/github/nruzic/commons/master/nruzic-commons-master/3.0.0-RC14/
My site descriptor contains following section to test various
interpolation options:
<breadcrumbs>
<item name="Project Site" href="${this.foo}/${foo}/${FOO}/${project.name}"/>
</breadcrumbs>
Now, try to write following child pom and run "mvn site" command on it.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.github.nruzic.commons.master</groupId>
<artifactId>nruzic-commons-master</artifactId>
<version>3.0.0-RC14</version>
<relativePath />
</parent>
<artifactId>site-descriptor-interpolation-test</artifactId>
<packaging>pom</packaging>
<name>Site Descriptor Interpolation Test</name>
<properties>
<foo>foo-from-child-project</foo>
</properties>
</project>
I'm getting following error:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-site-plugin:3.7.1:site (default-site) on
project site-descriptor-interpolation-test: Execution default-site of
goal org.apache.maven.plugins:maven-site-plugin:3.7.1:site failed:
site.xml late interpolation ${project.*} expression found in link:
'foo-from-parent-using-this/${foo}/${FOO}/${project.name}'. Use early
interpolation ${this.*} -> [Help 1]
Maven version is:
mvn -v
Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3;
2018-10-24T20:41:47+02:00)
Maven home: /opt/maven
Java version: 1.8.0_191, vendor: Oracle Corporation, runtime:
/usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.15.0-43-generic", arch: "amd64", family:
"unix"
I'm not sure why forbid "project." references in parent site descriptor?
Maybe one (like me) needs them to be be used with late interpolation.
If I remove "project." reference the problem only gets worse. Try
replace parent version in test pom with 3.0.0-RC13 version. Details
about RC13 version can be found here
https://repo1.maven.org/maven2/com/github/nruzic/commons/master/nruzic-commons-master/3.0.0-RC13/
Now I'm getting following error running "maven site" command:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-site-plugin:3.7.1:site (default-site) on
project site-descriptor-interpolation-test: Execution default-site of
goal org.apache.maven.plugins:maven-site-plugin:3.7.1:site failed:
Illegal character in path at index 28:
foo-from-parent-using-this/${foo}/${FOO}/ -> [Help 1]
Now maven fails before late interpolation is done.
I have done following change in source code of doxia-decoration-model
(basically, skip rebase if link contains unresolved placeholders):
git diff
diff --git
a/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
b/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
index fd511ae..20bf1db 100644
---
a/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
+++
b/doxia-decoration-model/src/main/java/org/apache/maven/doxia/site/decoration/inheritance/DefaultDecorationModelInheritanceAssembler.java
@@ -450,7 +450,7 @@ public class DefaultDecorationModelInheritanceAssembler
*/
public String rebaseLink( final String link )
{
- if ( link == null || getOldPath() == null )
+ if ( link == null || getOldPath() == null || link.contains(
"${" ) )
{
return link;
}
Now interpolation works as have have expected, all placeholders in
parent site descriptor are replaced.
Can someone comment given analysis please. Is this a bug in
doxia-sitetools or what?
Kind regards,
Nikola
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]