Le jeudi 24 mars 2016 11:14:04 Robert Scholte a écrit :
> 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.
Yes, this is what we expect from the new "early interpolation" feature.
This doesn't explain why CLI overriding should be avoided in early 
interpolation: even with CLI overriding, the parent lock down feature is here

When I see MSITE-769, I imagine setting property value from CLI is an expected 
use case

> 
> We have to be very careful with the order of this.*
> 
> 1. this = ${project}
> 2. this = ${project.properties} (just for user friendliness)
yes, order is important
http://maven.apache.org/ref/3-LATEST/maven-model-builder/#Model_Interpolation

Notice that I just had a look at 
DefaultSiteTool.getInterpolatedSiteDescriptorContent() implementation and 
found that env vars are interpolated first: I will fix it (even if I suppose 
env vars are not so much used)
And CLI doesn't look to be supported at the moment: I knew I had to create 
mmore unit tests...

> 
> if there's a property called 'name', you must use ${this.properties.name},
> otherwise ${project.name} is used.
yes, ${this.properties.*} will avoid any clash by naming convention
but pom.xml classical "late" interpolation doesn't avoid these clashes: 
interpolation order just makes POM element interpolation happen before 
properties
Then, as users, we're already used to avoid defining a property if its name 
already exists in POM: we know it is useless (or anybody who doesn't know will 
discover this edge case :) )
I'm not convinced we should treat it differently in early interpolation


Then we have to make 2 choices:

1. properties early interpolation syntax
properties classical "late" interpolation has ${*} syntax
we need a different syntax for properties new early interpolation
I don't see any issue with ${this.*} since POM structure interpolation will 
happen before properties interpolation (like classical pom.xml late 
interpolation)
And this is consistent with the idea that changing a classical (late) 
interpolation to a new early interpolation just requires adding "this." 
prefix: easy and consistent

(notice: before you proposed ${this.*} syntax for early interpolation, I had 
thought about $[*]. But I didn't like it because it was not easy to figure out 
the difference between {} and []. That's why I like ${this.*}: when yhou see 
it, you figure out what it means. 

2. enable or disable CLI overriding of a property for early interpolation?
I think some use cases will require CLI use
And I don't see any strong drawback: CLI use is usual and won't break the lock 
down in parent scenario


Regards,

Hervé

> 
> 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/o
> >> r
> >> 
> >> > g/apache/maven/doxia/tools/DefaultSiteTool.java URL:
> >> http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-inte
> >> g
> >> 
> >> ration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.j
> >> a
> >> 
> >> > va?rev=1736261&r1=1736260&r2=1736261&view=diff
> >> 
> >> =========================================================================
> >> 
> >> > ===== ---
> >> 
> >> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/o
> >> r
> >> 
> >> > g/apache/maven/doxia/tools/DefaultSiteTool.java (original)
> >> > +++
> >> 
> >> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/o
> >> r
> >> 
> >> > 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/o
> >> r
> >> 
> >> > g/apache/maven/doxia/tools/SiteToolTest.java URL:
> >> http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-inte
> >> g
> >> 
> >> 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/o
> >> r
> >> 
> >> > g/apache/maven/doxia/tools/SiteToolTest.java (original)
> >> > +++
> >> 
> >> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/o
> >> r
> >> 
> >> > 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/o
> >> r
> >> 
> >> > g/apache/maven/doxia/tools/stubs/SiteToolMavenProjectStub.java URL:
> >> http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-inte
> >> g
> >> 
> >> ration-tools/src/test/java/org/apache/maven/doxia/tools/stubs/SiteToolMav
> >> e
> >> 
> >> > nProjectStub.java?rev=1736261&r1=1736260&r2=1736261&view=diff
> >> 
> >> =========================================================================
> >> 
> >> > ===== ---
> >> 
> >> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/o
> >> r
> >> 
> >> > g/apache/maven/doxia/tools/stubs/SiteToolMavenProjectStub.java
> >> 
> >> (original)
> >> 
> >> > +++
> >> 
> >> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/o
> >> r
> >> 
> >> > 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/resour
> >> c
> >> 
> >> > es/unit/interpolation-child-test/pom.xml URL:
> >> http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-inte
> >> g
> >> 
> >> 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/resour
> >> c
> >> 
> >> > es/unit/interpolation-child-test/pom.xml (original)
> >> > +++
> >> 
> >> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resour
> >> c
> >> 
> >> > 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/resour
> >> c
> >> 
> >> > es/unit/interpolation-parent-test/pom.xml URL:
> >> http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-inte
> >> g
> >> 
> >> ration-tools/src/test/resources/unit/interpolation-parent-test/pom.xml?re
> >> v
> >> 
> >> > =1736261&r1=1736260&r2=1736261&view=diff
> >> 
> >> =========================================================================
> >> 
> >> > ===== ---
> >> 
> >> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resour
> >> c
> >> 
> >> > es/unit/interpolation-parent-test/pom.xml (original)
> >> > +++
> >> 
> >> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resour
> >> c
> >> 
> >> > 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/resour
> >> c
> >> 
> >> > es/unit/interpolation-parent-test/src/site/site.xml URL:
> >> http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-inte
> >> g
> >> 
> >> ration-tools/src/test/resources/unit/interpolation-parent-test/src/site/s
> >> i
> >> 
> >> > te.xml?rev=1736261&r1=1736260&r2=1736261&view=diff
> >> 
> >> =========================================================================
> >> 
> >> > ===== ---
> >> 
> >> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resour
> >> c
> >> 
> >> > es/unit/interpolation-parent-test/src/site/site.xml (original)
> >> > +++
> >> 
> >> maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/resour
> >> c
> >> 
> >> > 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]


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

Reply via email to