[MNG-6059] renamed attributes to get more flexibility for scm urls

This commit is contained in:
Hervé Boutemy 2018-11-01 23:58:22 +01:00
parent 114a0e9c7a
commit db462ae0b3
6 changed files with 114 additions and 44 deletions

View File

@ -53,7 +53,6 @@
*
* @author Benjamin Bentmann
*/
@SuppressWarnings( { "checkstyle:methodname" } )
public class MavenModelMerger
extends ModelMerger
{
@ -103,14 +102,14 @@ protected void mergeModel_Url( Model target, Model source, boolean sourceDominan
}
else if ( target.getUrl() == null )
{
target.setUrl( extrapolateChildUrl( src, source.isChildInheritAppendPath(), context ) );
target.setUrl( extrapolateChildUrl( src, source.isChildProjectUrlInheritAppendPath(), context ) );
target.setLocation( "url", source.getLocation( "url" ) );
}
}
}
/*
* TODO Whether the merge continues recursively into an existing node or not could be an option for the generated
* TODO: Whether the merge continues recursively into an existing node or not could be an option for the generated
* merger
*/
@Override
@ -267,7 +266,7 @@ protected void mergeModelBase_Modules( ModelBase target, ModelBase source, boole
}
/*
* TODO The order of the merged list could be controlled by an attribute in the model association: target-first,
* TODO: The order of the merged list could be controlled by an attribute in the model association: target-first,
* source-first, dominant-first, recessive-first
*/
@Override
@ -353,7 +352,7 @@ protected void mergeModelBase_PluginRepositories( ModelBase target, ModelBase so
}
/*
* TODO Whether duplicates should be removed looks like an option for the generated merger.
* TODO: Whether duplicates should be removed looks like an option for the generated merger.
*/
@Override
protected void mergeBuildBase_Filters( BuildBase target, BuildBase source, boolean sourceDominant,
@ -467,7 +466,7 @@ protected void mergeSite_Url( Site target, Site source, boolean sourceDominant,
}
else if ( target.getUrl() == null )
{
target.setUrl( extrapolateChildUrl( src, source.isChildInheritAppendPath(), context ) );
target.setUrl( extrapolateChildUrl( src, source.isChildSiteUrlInheritAppendPath(), context ) );
target.setLocation( "url", source.getLocation( "url" ) );
}
}
@ -486,7 +485,7 @@ protected void mergeScm_Url( Scm target, Scm source, boolean sourceDominant, Map
}
else if ( target.getUrl() == null )
{
target.setUrl( extrapolateChildUrl( src, source.isChildInheritAppendPath(), context ) );
target.setUrl( extrapolateChildUrl( src, source.isChildScmUrlInheritAppendPath(), context ) );
target.setLocation( "url", source.getLocation( "url" ) );
}
}
@ -505,7 +504,8 @@ protected void mergeScm_Connection( Scm target, Scm source, boolean sourceDomina
}
else if ( target.getConnection() == null )
{
target.setConnection( extrapolateChildUrl( src, source.isChildInheritAppendPath(), context ) );
target.setConnection( extrapolateChildUrl( src, source.isChildScmConnectionInheritAppendPath(),
context ) );
target.setLocation( "connection", source.getLocation( "connection" ) );
}
}
@ -525,7 +525,8 @@ protected void mergeScm_DeveloperConnection( Scm target, Scm source, boolean sou
}
else if ( target.getDeveloperConnection() == null )
{
target.setDeveloperConnection( extrapolateChildUrl( src, source.isChildInheritAppendPath(), context ) );
String e = extrapolateChildUrl( src, source.isChildScmDeveloperConnectionInheritAppendPath(), context );
target.setDeveloperConnection( e );
target.setLocation( "developerConnection", source.getLocation( "developerConnection" ) );
}
}

View File

@ -132,6 +132,14 @@ Maven Model Builder
property is not inherited from a POM to its child: childs POM will use child artifact id if property is not
set.
** since Maven 3.6.1, inheritance can avoid appending any path to parent value by setting model attribute value to
<<<false>>> for each url:
<<<project/@child.project.url.inherit.append.path>>>,
<<<project/distributionManagement/site/@child.site.url.inherit.append.path>>>,
<<<project/scm/@child.scm.connection.inherit.append.path>>>,
<<<project/scm/@child.scm.developerConnection.inherit.append.path>>> and
<<<project/scm/@child.scm.url.inherit.append.path>>>.
[]
* Model Interpolation

View File

@ -94,7 +94,7 @@ public void testFlatUrls()
}
/**
* MNG-5951 child.inherit.append.path="false" test
* MNG-5951 MNG-6059 child.x.y.inherit.append.path="false" test
* @throws Exception
*/
public void testNoAppendUrls()

View File

@ -33,7 +33,7 @@ under the License.
<artifactId>inheritance</artifactId>
<version>11-SNAPSHOT</version>
<name>Model urls inheritance test child</name>
<description>MNG-5951 child.inherit.append.path="false" for each url to avoid automatic path addition when inheriting</description>
<description>MNG-5951 MNG-6059 child.x.y.inherit.append.path="false" for each url to avoid automatic path addition when inheriting</description>
<!-- 5 inherited urls without anything added to parent -->
<url>http://www.apache.org/path/to/parent/</url>

View File

@ -21,7 +21,7 @@ under the License.
<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"
child.inherit.append.path="false">
child.project.url.inherit.append.path="false">
<modelVersion>4.0.0</modelVersion>
<groupId>inheritance</groupId>
@ -29,7 +29,7 @@ under the License.
<version>11-SNAPSHOT</version>
<name>Model urls inheritance test parent</name>
<description>MNG-5951 child.inherit.append.path="false" for each url to avoid automatic path addition when inheriting</description>
<description>MNG-5951 MNG-6059 child.x.y.inherit.append.path="false" for each url to avoid automatic path addition when inheriting</description>
<modules>
<module>../inheritance</module>
@ -37,13 +37,15 @@ under the License.
<!-- 5 urls in the pom to configure for not adding path -->
<url>http://www.apache.org/path/to/parent/</url>
<scm child.inherit.append.path="false">
<scm child.scm.connection.inherit.append.path="false"
child.scm.developerConnection.inherit.append.path="false"
child.scm.url.inherit.append.path="false">
<connection>scm:my-scm:http://domain.org/base</connection>
<developerConnection>scm:my-scm:https://domain.org/base/</developerConnection>
<url>https://domain.org/base</url>
</scm>
<distributionManagement>
<site child.inherit.append.path="false">
<site child.site.url.inherit.append.path="false">
<url>scp://scp.domain.org/base/</url>
</site>
</distributionManagement>

View File

@ -184,21 +184,22 @@
<description>
<![CDATA[
The URL to the project's homepage.
<br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or <code>project.directory</code> property), or just parent value if
<code>child.urls.inherit.append.path="false"</code>
<br /><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
project's <code>child.project.url.inherit.append.path="false"</code>
]]>
</description>
<type>String</type>
</field>
<field xml.attribute="true" xml.tagName="child.inherit.append.path">
<name>childInheritAppendPath</name>
<field xml.attribute="true" xml.tagName="child.project.url.inherit.append.path">
<name>childProjectUrlInheritAppendPath</name>
<version>4.0.0+</version>
<description>
<![CDATA[
When childs inherit from urls, append path or not?. Note: While the type
When childs inherit from project's url, append path or not? Note: While the type
of this field is <code>String</code> for technical reasons, the semantic type is actually
<code>Boolean</code>
<br /><b>Default value is</b>: <code>true</code>
<br /><b>Since</b>: Maven 3.6.1
]]>
</description>
<type>String</type>
@ -422,15 +423,17 @@
<version>4.0.0+</version>
<code>
<![CDATA[
public boolean isChildInheritAppendPath()
public boolean isChildProjectUrlInheritAppendPath()
{
return ( childInheritAppendPath != null ) ? Boolean.parseBoolean( childInheritAppendPath ) : true;
return ( childProjectUrlInheritAppendPath != null ) ? Boolean.parseBoolean( childProjectUrlInheritAppendPath ) : true;
}
public void setChildInheritAppendPath( boolean childInheritAppendPath )
public void setChildProjectUrlInheritAppendPath( boolean childProjectUrlInheritAppendPath )
{
this.childInheritAppendPath = String.valueOf( childInheritAppendPath );
this.childProjectUrlInheritAppendPath = String.valueOf( childProjectUrlInheritAppendPath );
}
]]>
</code>
</codeSegment>
@ -1613,7 +1616,8 @@
<a href="https://maven.apache.org/scm/scm-url-format.html">URL format</a>
and <a href="https://maven.apache.org/scm/scms-overview.html">list of supported SCMs</a>.
This connection is read-only.
<br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or <code>project.directory</code> property)
<br /><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
scm's <code>child.scm.connection.inherit.append.path="false"</code>
]]>
</description>
<type>String</type>
@ -1625,7 +1629,8 @@
<![CDATA[
Just like <code>connection</code>, but for developers, i.e. this scm connection
will not be read only.
<br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or <code>project.directory</code> property)
<br /><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
scm's <code>child.scm.developerConnection.inherit.append.path="false"</code>
]]>
</description>
<type>String</type>
@ -1643,21 +1648,50 @@
<description>
<![CDATA[
The URL to the project's browsable SCM repository, such as ViewVC or Fisheye.
<br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or <code>project.directory</code> property), or just parent value if
<code>child.urls.inherit.append.path="false"</code>
<br /><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
scm's <code>child.scm.url.inherit.append.path="false"</code>
]]>
</description>
<type>String</type>
</field>
<field xml.attribute="true" xml.tagName="child.inherit.append.path">
<name>childInheritAppendPath</name>
<field xml.attribute="true" xml.tagName="child.scm.connection.inherit.append.path">
<name>childScmConnectionInheritAppendPath</name>
<version>4.0.0+</version>
<description>
<![CDATA[
When childs inherit from urls, append path or not?. Note: While the type
When childs inherit from scm connection, append path or not? Note: While the type
of this field is <code>String</code> for technical reasons, the semantic type is actually
<code>Boolean</code>
<br /><b>Default value is</b>: <code>true</code>
<br /><b>Since</b>: Maven 3.6.1
]]>
</description>
<type>String</type>
</field>
<field xml.attribute="true" xml.tagName="child.scm.developerConnection.inherit.append.path">
<name>childScmDeveloperConnectionInheritAppendPath</name>
<version>4.0.0+</version>
<description>
<![CDATA[
When childs inherit from scm developer connection, append path or not? Note: While the type
of this field is <code>String</code> for technical reasons, the semantic type is actually
<code>Boolean</code>
<br /><b>Default value is</b>: <code>true</code>
<br /><b>Since</b>: Maven 3.6.1
]]>
</description>
<type>String</type>
</field>
<field xml.attribute="true" xml.tagName="child.scm.url.inherit.append.path">
<name>childScmUrlInheritAppendPath</name>
<version>4.0.0+</version>
<description>
<![CDATA[
When childs inherit from scm url, append path or not? Note: While the type
of this field is <code>String</code> for technical reasons, the semantic type is actually
<code>Boolean</code>
<br /><b>Default value is</b>: <code>true</code>
<br /><b>Since</b>: Maven 3.6.1
]]>
</description>
<type>String</type>
@ -1668,15 +1702,37 @@
<version>4.0.0+</version>
<code>
<![CDATA[
public boolean isChildInheritAppendPath()
public boolean isChildScmConnectionInheritAppendPath()
{
return ( childInheritAppendPath != null ) ? Boolean.parseBoolean( childInheritAppendPath ) : true;
return ( childScmConnectionInheritAppendPath != null ) ? Boolean.parseBoolean( childScmConnectionInheritAppendPath ) : true;
}
public void setChildInheritAppendPath( boolean childInheritAppendPath )
public void setChildScmConnectionInheritAppendPath( boolean childScmConnectionInheritAppendPath )
{
this.childInheritAppendPath = String.valueOf( childInheritAppendPath );
this.childScmConnectionInheritAppendPath = String.valueOf( childScmConnectionInheritAppendPath );
}
public boolean isChildScmDeveloperConnectionInheritAppendPath()
{
return ( childScmDeveloperConnectionInheritAppendPath != null ) ? Boolean.parseBoolean( childScmDeveloperConnectionInheritAppendPath ) : true;
}
public void setChildScmDeveloperConnectionInheritAppendPath( boolean childScmDeveloperConnectionInheritAppendPath )
{
this.childScmDeveloperConnectionInheritAppendPath = String.valueOf( childScmDeveloperConnectionInheritAppendPath );
}
public boolean isChildScmUrlInheritAppendPath()
{
return ( childScmUrlInheritAppendPath != null ) ? Boolean.parseBoolean( childScmUrlInheritAppendPath ) : true;
}
public void setChildScmUrlInheritAppendPath( boolean childScmUrlInheritAppendPath )
{
this.childScmUrlInheritAppendPath = String.valueOf( childScmUrlInheritAppendPath );
}
]]>
</code>
</codeSegment>
@ -2000,21 +2056,22 @@
<description>
<![CDATA[
The url of the location where website is deployed, in the form <code>protocol://hostname/path</code>.
<br><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or <code>project.directory</code> property), or just parent value if
<code>child.urls.inherit.append.path="false"</code>
<br /><b>Default value is</b>: parent value [+ path adjustment] + (artifactId or project.directory property), or just parent value if
site's <code>child.site.url.inherit.append.path="false"</code>
]]>
</description>
<type>String</type>
</field>
<field xml.attribute="true" xml.tagName="child.inherit.append.path">
<name>childInheritAppendPath</name>
<field xml.attribute="true" xml.tagName="child.site.url.inherit.append.path">
<name>childSiteUrlInheritAppendPath</name>
<version>4.0.0+</version>
<description>
<![CDATA[
When childs inherit from urls, append path or not?. Note: While the type
When childs inherit from distribution management site url, append path or not? Note: While the type
of this field is <code>String</code> for technical reasons, the semantic type is actually
<code>Boolean</code>
<br /><b>Default value is</b>: <code>true</code>
<br /><b>Since</b>: Maven 3.6.1
]]>
</description>
<type>String</type>
@ -2025,15 +2082,17 @@
<version>4.0.0+</version>
<code>
<![CDATA[
public boolean isChildInheritAppendPath()
public boolean isChildSiteUrlInheritAppendPath()
{
return ( childInheritAppendPath != null ) ? Boolean.parseBoolean( childInheritAppendPath ) : true;
return ( childSiteUrlInheritAppendPath != null ) ? Boolean.parseBoolean( childSiteUrlInheritAppendPath ) : true;
}
public void setChildInheritAppendPath( boolean childInheritAppendPath )
public void setChildSiteUrlInheritAppendPath( boolean childSiteUrlInheritAppendPath )
{
this.childInheritAppendPath = String.valueOf( childInheritAppendPath );
this.childSiteUrlInheritAppendPath = String.valueOf( childSiteUrlInheritAppendPath );
}
]]>
</code>
</codeSegment>