[MNG-1999] fix reporting > excludeDefaults inheritance

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@379311 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2006-02-21 02:30:32 +00:00
parent 33e508a29d
commit ad38e46b4b
2 changed files with 68 additions and 39 deletions

View File

@ -16,15 +16,6 @@ package org.apache.maven.project.inheritance;
* limitations under the License. * limitations under the License.
*/ */
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.TreeMap;
import org.apache.maven.model.Build; import org.apache.maven.model.Build;
import org.apache.maven.model.Dependency; import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement; import org.apache.maven.model.DependencyManagement;
@ -38,6 +29,15 @@ import org.apache.maven.model.Site;
import org.apache.maven.project.ModelUtils; import org.apache.maven.project.ModelUtils;
import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.TreeMap;
/** /**
* @author <a href="mailto:jason@maven.org">Jason van Zyl </a> * @author <a href="mailto:jason@maven.org">Jason van Zyl </a>
* @version $Id: DefaultModelInheritanceAssembler.java,v 1.4 2004/08/23 20:24:54 * @version $Id: DefaultModelInheritanceAssembler.java,v 1.4 2004/08/23 20:24:54
@ -275,6 +275,8 @@ public class DefaultModelInheritanceAssembler
child.setReporting( childReporting ); child.setReporting( childReporting );
} }
childReporting.setExcludeDefaults( parentReporting.isExcludeDefaults() );
if ( StringUtils.isEmpty( childReporting.getOutputDirectory() ) ) if ( StringUtils.isEmpty( childReporting.getOutputDirectory() ) )
{ {
childReporting.setOutputDirectory( parentReporting.getOutputDirectory() ); childReporting.setOutputDirectory( parentReporting.getOutputDirectory() );
@ -422,25 +424,28 @@ public class DefaultModelInheritanceAssembler
if ( StringUtils.isEmpty( childScm.getConnection() ) && !StringUtils.isEmpty( parentScm.getConnection() ) ) if ( StringUtils.isEmpty( childScm.getConnection() ) && !StringUtils.isEmpty( parentScm.getConnection() ) )
{ {
childScm.setConnection( appendPath( parentScm.getConnection(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); childScm.setConnection(
appendPath( parentScm.getConnection(), child.getArtifactId(), childPathAdjustment, appendPaths ) );
} }
if ( StringUtils.isEmpty( childScm.getDeveloperConnection() ) && if ( StringUtils.isEmpty( childScm.getDeveloperConnection() ) &&
!StringUtils.isEmpty( parentScm.getDeveloperConnection() ) ) !StringUtils.isEmpty( parentScm.getDeveloperConnection() ) )
{ {
childScm childScm
.setDeveloperConnection( .setDeveloperConnection( appendPath( parentScm.getDeveloperConnection(), child.getArtifactId(),
appendPath( parentScm.getDeveloperConnection(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); childPathAdjustment, appendPaths ) );
} }
if ( StringUtils.isEmpty( childScm.getUrl() ) && !StringUtils.isEmpty( parentScm.getUrl() ) ) if ( StringUtils.isEmpty( childScm.getUrl() ) && !StringUtils.isEmpty( parentScm.getUrl() ) )
{ {
childScm.setUrl( appendPath( parentScm.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); childScm.setUrl(
appendPath( parentScm.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) );
} }
} }
} }
private void assembleDistributionInheritence( Model child, Model parent, String childPathAdjustment, boolean appendPaths ) private void assembleDistributionInheritence( Model child, Model parent, String childPathAdjustment,
boolean appendPaths )
{ {
if ( parent.getDistributionManagement() != null ) if ( parent.getDistributionManagement() != null )
{ {
@ -471,7 +476,8 @@ public class DefaultModelInheritanceAssembler
if ( site.getUrl() != null ) if ( site.getUrl() != null )
{ {
site.setUrl( appendPath( site.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) ); site.setUrl(
appendPath( site.getUrl(), child.getArtifactId(), childPathAdjustment, appendPaths ) );
} }
} }
} }
@ -562,7 +568,7 @@ public class DefaultModelInheritanceAssembler
StringTokenizer tokens = new StringTokenizer( pathFragment, "/" ); StringTokenizer tokens = new StringTokenizer( pathFragment, "/" );
while( tokens.hasMoreTokens() ) while ( tokens.hasMoreTokens() )
{ {
lastToken = currentToken; lastToken = currentToken;
currentToken = tokens.nextToken(); currentToken = tokens.nextToken();

View File

@ -17,7 +17,6 @@ package org.apache.maven.project.inheritance;
*/ */
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.maven.model.Build; import org.apache.maven.model.Build;
import org.apache.maven.model.Model; import org.apache.maven.model.Model;
import org.apache.maven.model.Parent; import org.apache.maven.model.Parent;
@ -50,7 +49,8 @@ public class DefaultModelInheritanceAssemblerTest
String childPath = "file-management"; String childPath = "file-management";
String pathAdjustment = ".."; String pathAdjustment = "..";
String result = ((DefaultModelInheritanceAssembler) assembler).appendPath( parentPath, childPath, pathAdjustment, true ); String result =
( (DefaultModelInheritanceAssembler) assembler ).appendPath( parentPath, childPath, pathAdjustment, true );
System.out.println( "Resulting path is: \'" + result + "\'" ); System.out.println( "Resulting path is: \'" + result + "\'" );
@ -151,8 +151,8 @@ public class DefaultModelInheritanceAssemblerTest
Model artifact1_1 = makeScmModel( "artifact1-1" ); Model artifact1_1 = makeScmModel( "artifact1-1" );
Model artifact2 = makeScmModel( "artifact2", "scm:foo:/scm-root/yay-artifact2", Model artifact2 =
"scm:foo:/scm-dev-root/yay-artifact2", null ); makeScmModel( "artifact2", "scm:foo:/scm-root/yay-artifact2", "scm:foo:/scm-dev-root/yay-artifact2", null );
Model artifact2_1 = makeScmModel( "artifact2-1" ); Model artifact2_1 = makeScmModel( "artifact2-1" );
@ -426,6 +426,29 @@ public class DefaultModelInheritanceAssemblerTest
} }
} }
public void testReportingExcludeDefaultsInheritance()
{
Model parent = makeBaseModel( "parent" );
Model child = makeBaseModel( "child" );
Reporting parentBuild = new Reporting();
parentBuild.setExcludeDefaults( false );
parent.setReporting( parentBuild );
assembler.assembleModelInheritance( child, parent );
assertFalse( "Check excludeDefaults is inherited", child.getReporting().isExcludeDefaults() );
child = makeBaseModel( "child" );
parentBuild.setExcludeDefaults( true );
assembler.assembleModelInheritance( child, parent );
assertTrue( "Check excludeDefaults is inherited", child.getReporting().isExcludeDefaults() );
}
public void testReportInheritanceWhereParentReportWithoutInheritFlagAndChildHasNoReports() public void testReportInheritanceWhereParentReportWithoutInheritFlagAndChildHasNoReports()
{ {
Model parent = makeBaseModel( "parent" ); Model parent = makeBaseModel( "parent" );