mirror of https://github.com/apache/maven.git
added plugin configuration inheritance test, particularly combine.children and combine.self attributes
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1161299 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
403d12c51c
commit
04f26a7ac8
|
@ -41,11 +41,18 @@
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-model</artifactId>
|
<artifactId>maven-model</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.sonatype.sisu</groupId>
|
<groupId>org.sonatype.sisu</groupId>
|
||||||
<artifactId>sisu-inject-plexus</artifactId>
|
<artifactId>sisu-inject-plexus</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>xmlunit</groupId>
|
||||||
|
<artifactId>xmlunit</artifactId>
|
||||||
|
<version>1.3</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -0,0 +1,108 @@
|
||||||
|
package org.apache.maven.model.inheritance;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.Reader;
|
||||||
|
|
||||||
|
import org.apache.maven.model.Model;
|
||||||
|
import org.apache.maven.model.building.SimpleProblemCollector;
|
||||||
|
import org.apache.maven.model.io.ModelParseException;
|
||||||
|
import org.apache.maven.model.io.ModelReader;
|
||||||
|
import org.apache.maven.model.io.ModelWriter;
|
||||||
|
import org.codehaus.plexus.PlexusTestCase;
|
||||||
|
import org.codehaus.plexus.util.IOUtil;
|
||||||
|
import org.custommonkey.xmlunit.XMLAssert;
|
||||||
|
import org.custommonkey.xmlunit.XMLUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Hervé Boutemy
|
||||||
|
*/
|
||||||
|
public class DefaultInheritanceAssemblerTest
|
||||||
|
extends PlexusTestCase
|
||||||
|
{
|
||||||
|
private ModelReader reader;
|
||||||
|
|
||||||
|
private ModelWriter writer;
|
||||||
|
|
||||||
|
private InheritanceAssembler assembler;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void setUp()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
super.setUp();
|
||||||
|
|
||||||
|
reader = lookup( ModelReader.class );
|
||||||
|
writer = lookup( ModelWriter.class );
|
||||||
|
assembler = lookup( InheritanceAssembler.class );
|
||||||
|
}
|
||||||
|
|
||||||
|
private File getPom( String name )
|
||||||
|
{
|
||||||
|
return getTestFile( "src/test/resources/poms/inheritance/" + name + ".xml" );
|
||||||
|
}
|
||||||
|
|
||||||
|
private Model getModel( String name )
|
||||||
|
throws ModelParseException, IOException
|
||||||
|
{
|
||||||
|
return reader.read( getPom( name ), null );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testPluginConfiguration()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
Model parent = getModel( "plugin-configuration-parent" );
|
||||||
|
|
||||||
|
Model child = getModel( "plugin-configuration-child" );
|
||||||
|
|
||||||
|
SimpleProblemCollector problems = new SimpleProblemCollector();
|
||||||
|
|
||||||
|
assembler.assembleModelInheritance( child, parent, null, problems );
|
||||||
|
|
||||||
|
File actual = getTestFile( "target/test-classes/poms/inheritance/plugin-configuration-actual.xml" );
|
||||||
|
|
||||||
|
writer.write( actual, null, child );
|
||||||
|
|
||||||
|
// check with getPom( "plugin-configuration-effective" )
|
||||||
|
Reader control = null;
|
||||||
|
Reader test = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File expected = getPom( "plugin-configuration-expected" );
|
||||||
|
control = new InputStreamReader( new FileInputStream( expected ), "UTF-8" );
|
||||||
|
|
||||||
|
test = new InputStreamReader( new FileInputStream( actual ), "UTF-8" );
|
||||||
|
|
||||||
|
XMLUnit.setIgnoreComments( true );
|
||||||
|
XMLUnit.setIgnoreWhitespace( true );
|
||||||
|
XMLAssert.assertXMLEqual( control, test );
|
||||||
|
}
|
||||||
|
catch ( IOException ioe )
|
||||||
|
{
|
||||||
|
IOUtil.close( control );
|
||||||
|
IOUtil.close( test );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>child</artifactId>
|
||||||
|
<version>12-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>inheritance.configuration</groupId>
|
||||||
|
<artifactId>default</artifactId>
|
||||||
|
<version>3.0</version>
|
||||||
|
<configuration>
|
||||||
|
<defaults>
|
||||||
|
<parent>child</parent>
|
||||||
|
<child>child</child>
|
||||||
|
</defaults>
|
||||||
|
<appends combine.children="append">
|
||||||
|
<parent>child</parent>
|
||||||
|
<child>child</child>
|
||||||
|
</appends>
|
||||||
|
<overrides combine.self="override">
|
||||||
|
<parent>child</parent>
|
||||||
|
<child>child</child>
|
||||||
|
</overrides>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,61 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>inheritance</groupId>
|
||||||
|
<artifactId>child</artifactId>
|
||||||
|
<version>12-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<!-- name is not inherited, but description is -->
|
||||||
|
<description>Model inheritance description</description>
|
||||||
|
<url>http://www.apache.org/child/</url><!-- child's artifactId added to parent url -->
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>inheritance.configuration</groupId>
|
||||||
|
<artifactId>default</artifactId>
|
||||||
|
<version>3.0</version>
|
||||||
|
<configuration>
|
||||||
|
<defaults><!-- equivalent to combine.children="merge" combine.self="merge" -->
|
||||||
|
<!-- merge the content of the configuration element according to element name -->
|
||||||
|
<parent>child</parent>
|
||||||
|
<child>child</child>
|
||||||
|
<parent-only>parent</parent-only>
|
||||||
|
</defaults>
|
||||||
|
<appends combine.children="append">
|
||||||
|
<parent-only>parent</parent-only>
|
||||||
|
<parent>parent</parent>
|
||||||
|
<parent>child</parent>
|
||||||
|
<child>child</child>
|
||||||
|
</appends>
|
||||||
|
<overrides combine.self="override">
|
||||||
|
<parent>child</parent>
|
||||||
|
<child>child</child>
|
||||||
|
</overrides>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>inheritance</groupId>
|
||||||
|
<artifactId>parent</artifactId>
|
||||||
|
<version>11-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<name>Model inheritance test</name>
|
||||||
|
<description>Model inheritance description</description>
|
||||||
|
<url>http://www.apache.org/</url>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>inheritance.configuration</groupId>
|
||||||
|
<artifactId>default</artifactId>
|
||||||
|
<version>2.0</version>
|
||||||
|
<configuration>
|
||||||
|
<defaults>
|
||||||
|
<parent-only>parent</parent-only>
|
||||||
|
<parent>parent</parent>
|
||||||
|
</defaults>
|
||||||
|
<appends>
|
||||||
|
<parent-only>parent</parent-only>
|
||||||
|
<parent>parent</parent>
|
||||||
|
</appends>
|
||||||
|
<overrides>
|
||||||
|
<parent-only>parent</parent-only>
|
||||||
|
<parent>parent</parent>
|
||||||
|
</overrides>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
Loading…
Reference in New Issue