On Thu, 24 Mar 2016 07:49:38 +0100, Hervé BOUTEMY <[email protected]> wrote:

glad you like it :)

yes, this interpolation and inheritance separation during site.xml model
building gives us an opportunity (or even forces us) to test your MNG-5900
idea immediately, without taking any risk at pom.xml level

and I have already learned one corner case: properties
${myproperty} takes its value from ${project.properties.myproperty} and can be
overridden with CLI -Dmyproperty=

but how to write the "this" equivalent, while still supporting the CLI
override?
should we support ${this.myproperty}? (and tweak CLI -Dmyproperty= to override
the result of this expression)?

IMHO I don't think you should be able to override this.myproperty via commandline. For example: with ${this.springVersion} it is possible to lock the version of dependencies in the parent, modules overriding this value has no effect on these dependencies, unless they explicitly set the value in the dependency again. This has been one frustration of me: using a property to keep versions of dependencies in sync (when a bom is not available), because now it has become a variable instead of a constant.

We have to be very careful with the order of this.*

1. this = ${project}
2. this = ${project.properties} (just for user friendliness)

if there's a property called 'name', you must use ${this.properties.name}, otherwise ${project.name} is used.

my 2 cents,
Robert

That's my current thinking, I'll implement it shortly if nobody objects or has
any other idea

Regards,

Hervé

Le mercredi 23 mars 2016 20:44:29 Robert Scholte a écrit :
Cool!

On Wed, 23 Mar 2016 00:56:13 +0100, <[email protected]> wrote:
> Author: hboutemy
> Date: Tue Mar 22 23:56:13 2016
> New Revision: 1736261
>
> URL: http://svn.apache.org/viewvc?rev=1736261&view=rev
> Log:
> [DOXIASITETOOLS-158] added support for ${this.*} as expression in
> site.xml interpolation
>
> Modified:
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/jav
>     a/org/apache/maven/doxia/tools/DefaultSiteTool.java
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/ja
>     va/org/apache/maven/doxia/tools/SiteToolTest.java
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/ja > va/org/apache/maven/doxia/tools/stubs/SiteToolMavenProjectStub.java > maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/re
>     sources/unit/interpolation-child-test/pom.xml
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/re
>     sources/unit/interpolation-parent-test/pom.xml
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/re
>     sources/unit/interpolation-parent-test/src/site/site.xml>
> Modified:
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/or
> g/apache/maven/doxia/tools/DefaultSiteTool.java URL:
> http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-integ > ration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.ja
> va?rev=1736261&r1=1736260&r2=1736261&view=diff
> =========================================================================
> ===== ---
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/or
> g/apache/maven/doxia/tools/DefaultSiteTool.java (original)
> +++
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/or > g/apache/maven/doxia/tools/DefaultSiteTool.java Tue Mar 22 23:56:13 2016
> @@ -468,7 +468,7 @@ public class DefaultSiteTool
>
> // DecorationModel back to String to interpolate, then go back
>
> to DecorationModel
>
>          String siteDescriptorContent = decorationModelToString(
>
> decorationModel );
> -        siteDescriptorContent = getInterpolatedSiteDescriptorContent(
> project, siteDescriptorContent );
> +        siteDescriptorContent = getInterpolatedSiteDescriptorContent(
> project, siteDescriptorContent, "project" );
>
> decorationModel = readDecorationModel( siteDescriptorContent );
>
> @@ -497,11 +497,11 @@ public class DefaultSiteTool
>
>      {
>
>          checkNotNull( "props", props );
>
> -        return getInterpolatedSiteDescriptorContent( aProject,
> siteDescriptorContent );
> +        return getInterpolatedSiteDescriptorContent( aProject,
> siteDescriptorContent, "project" );
>
>      }
>
>     private String getInterpolatedSiteDescriptorContent( MavenProject
>
> aProject,
> -                                                        String
> siteDescriptorContent )
> +                                                        String
> siteDescriptorContent, String prefix )
>
>          throws SiteToolException
>
>      {
>
>          checkNotNull( "aProject", aProject );
>
> @@ -527,7 +527,7 @@ public class DefaultSiteTool
>
>          try
>          {
>
> // FIXME: this does not escape xml entities, see MSITE-226,
>
> PLXCOMP-118
> -            return interpolator.interpolate( siteDescriptorContent,
> "project" );
> +            return interpolator.interpolate( siteDescriptorContent,
> prefix );
>
>          }
>          catch ( InterpolationException e )
>          {
>
> @@ -1116,6 +1116,9 @@ public class DefaultSiteTool
>
>                 String siteDescriptorContent = readSiteDescriptor(
>
> siteDescriptorReader, project.getId() );
> +                // interpolate ${this.*}
> +                siteDescriptorContent =
> getInterpolatedSiteDescriptorContent( project, siteDescriptorContent,
> "this" );
> +
>
> decoration = readDecorationModel( siteDescriptorContent
>
> );
>
>                  decoration.setLastModified(
>
> siteDescriptor.lastModified() );
>
>              }
>
> Modified:
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/or
> g/apache/maven/doxia/tools/SiteToolTest.java URL:
> http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-integ > ration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java?
> rev=1736261&r1=1736260&r2=1736261&view=diff
> =========================================================================
> ===== ---
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/or
> g/apache/maven/doxia/tools/SiteToolTest.java (original)
> +++
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/or
> g/apache/maven/doxia/tools/SiteToolTest.java Tue Mar 22 23:56:13 2016
> @@ -35,6 +35,8 @@ import org.apache.maven.artifact.reposit
>
>  import org.apache.maven.doxia.site.decoration.DecorationModel;
>  import org.apache.maven.doxia.site.decoration.Skin;
>  import org.apache.maven.doxia.tools.stubs.SiteToolMavenProjectStub;
>
> +import org.apache.maven.model.DistributionManagement;
> +import org.apache.maven.model.Site;
>
>  import org.apache.maven.project.MavenProject;
>
> import org.codehaus.plexus.PlexusTestCase;
> @@ -346,17 +348,11 @@ public class SiteToolTest
>
>          assertNotNull( tool );
>
>         SiteToolMavenProjectStub parentProject = new
>
> SiteToolMavenProjectStub( "interpolation-parent-test" );
> -        parentProject.setGroupId( "org.apache.maven.shared.its" );
> -        parentProject.setArtifactId( "mshared-217-parent" );
> -        parentProject.setVersion( "1.0-SNAPSHOT" );
> -        parentProject.setName( "MSHARED-217 Parent" );
> +        parentProject.setDistgributionManagementSiteUrl(
> "dav:https://davs.codehaus.org/site"; );
>
>         SiteToolMavenProjectStub childProject = new
>
> SiteToolMavenProjectStub( "interpolation-child-test" );
>
>          childProject.setParent( parentProject );
>
> -        childProject.setGroupId( "org.apache.maven.shared.its" );
> -        childProject.setArtifactId( "mshared-217-child" );
> -        childProject.setVersion( "1.0-SNAPSHOT" );
> -        childProject.setName( "MSHARED-217 Child" );
> +        childProject.setDistgributionManagementSiteUrl(
> "dav:https://davs.codehaus.org/site/child"; );
>
>         List<MavenProject> reactorProjects =
>
> Collections.<MavenProject>singletonList( parentProject );
>
> Modified:
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/or
> g/apache/maven/doxia/tools/stubs/SiteToolMavenProjectStub.java URL:
> http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-integ > ration-tools/src/test/java/org/apache/maven/doxia/tools/stubs/SiteToolMave
> nProjectStub.java?rev=1736261&r1=1736260&r2=1736261&view=diff
> =========================================================================
> ===== ---
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/or > g/apache/maven/doxia/tools/stubs/SiteToolMavenProjectStub.java (original)
> +++
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/or > g/apache/maven/doxia/tools/stubs/SiteToolMavenProjectStub.java Tue Mar 22
> 23:56:13 2016
> @@ -29,7 +29,9 @@ import org.apache.maven.artifact.reposit
>
> import org.apache.maven.artifact.repository.DefaultArtifactRepository;
>  import
>
> org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
>
>  import org.apache.maven.model.Build;
>
> +import org.apache.maven.model.DistributionManagement;
>
>  import org.apache.maven.model.Model;
>
> +import org.apache.maven.model.Site;
>
>  import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
>  import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
>
> @@ -44,6 +46,8 @@ public class SiteToolMavenProjectStub
>
>     private File basedir;
>
> +    private DistributionManagement distributionManagement;
> +
>
>      public SiteToolMavenProjectStub( String projectName )
>      {
>
>          basedir = new File( super.getBasedir() +
>
> "/src/test/resources/unit/" + projectName );
> @@ -115,4 +119,17 @@ public class SiteToolMavenProjectStub
>
>         return Collections.singletonList( repository );
>
>      }
>
> +
> +    public void setDistgributionManagementSiteUrl( String url )
> +    {
> +        Site site = new Site();
> +        site.setUrl( url );
> +        distributionManagement = new DistributionManagement();
> +        distributionManagement.setSite( site );
> +    }
> +
> +    public DistributionManagement getDistributionManagement()
> +    {
> +        return distributionManagement;
> +    }
>
>  }
>
> Modified:
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resourc
> es/unit/interpolation-child-test/pom.xml URL:
> http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-integ > ration-tools/src/test/resources/unit/interpolation-child-test/pom.xml?rev=
> 1736261&r1=1736260&r2=1736261&view=diff
> =========================================================================
> ===== ---
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resourc
> es/unit/interpolation-child-test/pom.xml (original)
> +++
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resourc
> es/unit/interpolation-child-test/pom.xml Tue Mar 22 23:56:13 2016
> @@ -23,7 +23,10 @@ under the License.
>
>    <modelVersion>4.0.0</modelVersion>
>
>   <groupId>org.apache.maven.shared.its</groupId>
>
> -  <artifactId>mshared-217-parent</artifactId>
> +  <artifactId>mshared-217-child</artifactId>
>
>    <version>1.0-SNAPSHOT</version>
>
> +  <name>MSHARED-217 Child</name>
> +  <url>http://maven.apache.org/mshared-217/child</url>
> +
>
>  </project>
>
> Modified:
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resourc
> es/unit/interpolation-parent-test/pom.xml URL:
> http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-integ > ration-tools/src/test/resources/unit/interpolation-parent-test/pom.xml?rev
> =1736261&r1=1736260&r2=1736261&view=diff
> =========================================================================
> ===== ---
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resourc
> es/unit/interpolation-parent-test/pom.xml (original)
> +++
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resourc
> es/unit/interpolation-parent-test/pom.xml Tue Mar 22 23:56:13 2016
> @@ -23,7 +23,10 @@ under the License.
>
>    <modelVersion>4.0.0</modelVersion>
>
>   <groupId>org.apache.maven.shared.its</groupId>
>
> -  <artifactId>mshared-217-child</artifactId>
> +  <artifactId>mshared-217-parent</artifactId>
>
>    <version>1.0-SNAPSHOT</version>
>
> +  <name>MSHARED-217 Parent</name>
> +  <url>http://maven.apache.org/mshared-217</url>
> +
>
>  </project>
>
> Modified:
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resourc
> es/unit/interpolation-parent-test/src/site/site.xml URL:
> http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-integ > ration-tools/src/test/resources/unit/interpolation-parent-test/src/site/si
> te.xml?rev=1736261&r1=1736260&r2=1736261&view=diff
> =========================================================================
> ===== ---
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resourc
> es/unit/interpolation-parent-test/src/site/site.xml (original)
> +++
> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resourc > es/unit/interpolation-parent-test/src/site/site.xml Tue Mar 22 23:56:13
> 2016
> @@ -27,8 +27,12 @@ under the License.
>
>    </bannerLeft>
>
>   <body>
>
> +    <links>
> +      <item name="${this.name}" href="${this.url}" />
> +    </links>
>
>      <breadcrumbs>
>
> <item name="Maven" href="http://maven.apache.org/index.html"; />
>
> +      <item name="${this.name}" href="${this.url}" />
>
>      </breadcrumbs>
>
>    </body>
>
>  </project>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to