Setup test classes for testing of pom construction with settings. Tried to use test-jar type to reuse classes but the causes some lost dependencies in eclipse. Just duping classes for now.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@760207 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Britton Isbell 2009-03-30 22:33:11 +00:00
parent 136bac419e
commit 8a31c1a381
9 changed files with 1034 additions and 0 deletions

View File

@ -0,0 +1,332 @@
package org.apache.maven.project.harness;
/*
* 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.*;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.jxpath.JXPathContext;
import org.apache.commons.jxpath.JXPathNotFoundException;
import org.apache.commons.jxpath.ri.JXPathContextReferenceImpl;
import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.project.builder.PomClassicDomainModel;
import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.model.ModelProperty;
import org.codehaus.plexus.util.WriterFactory;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
public class PomTestWrapper
{
private PomClassicDomainModel domainModel;
private File pomFile;
private JXPathContext context;
private MavenProject mavenProject;
static
{
JXPathContextReferenceImpl.addNodePointerFactory( new Xpp3DomPointerFactory() );
}
public PomTestWrapper( PomClassicDomainModel domainModel )
throws IOException
{
this( null, domainModel );
}
public PomTestWrapper( File pomFile, PomClassicDomainModel domainModel )
throws IOException
{
if ( domainModel == null )
{
throw new IllegalArgumentException( "domainModel: null" );
}
this.domainModel = domainModel;
this.pomFile = pomFile;
try {
context = JXPathContext.newContext( new MavenXpp3Reader().read(domainModel.getInputStream()));
} catch (XmlPullParserException e) {
throw new IOException(e.getMessage());
}
}
public PomTestWrapper( File pomFile, MavenProject mavenProject )
throws IOException
{
if ( mavenProject == null )
{
throw new IllegalArgumentException( "mavenProject: null" );
}
this.mavenProject = mavenProject;
this.pomFile = pomFile;
context = JXPathContext.newContext( mavenProject.getModel() );
}
public PomTestWrapper( MavenProject mavenProject )
throws IOException
{
if ( mavenProject == null )
{
throw new IllegalArgumentException( "mavenProject: null" );
}
this.mavenProject = mavenProject;
context = JXPathContext.newContext( mavenProject.getModel() );
}
public PomTestWrapper( File file )
throws IOException
{
if ( file == null )
{
throw new IllegalArgumentException( "file: null" );
}
this.domainModel = new PomClassicDomainModel( file );
try {
context = JXPathContext.newContext( new MavenXpp3Reader().read(domainModel.getInputStream()));
} catch (XmlPullParserException e) {
throw new IOException(e.getMessage());
}
}
public MavenProject getMavenProject()
{
return mavenProject;
}
public PomClassicDomainModel getDomainModel()
{
if ( domainModel == null && mavenProject != null )
{
try
{
domainModel = convertToDomainModel( mavenProject.getModel() );
int lineageCount = 1;
for ( MavenProject parent = mavenProject.getParent(); parent != null; parent = parent.getParent() )
{
lineageCount++;
}
domainModel.setLineageCount( lineageCount );
}
catch ( IOException e )
{
}
}
return this.domainModel;
}
private PomClassicDomainModel convertToDomainModel(Model model) throws IOException
{
if ( model == null )
{
throw new IllegalArgumentException( "model: null" );
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Writer out = null;
MavenXpp3Writer writer = new MavenXpp3Writer();
try
{
out = WriterFactory.newXmlWriter( baos );
writer.write( out, model );
}
finally
{
if ( out != null )
{
out.close();
}
}
return new PomClassicDomainModel(new ByteArrayInputStream(baos.toByteArray()));
}
public File getBasedir()
{
return ( pomFile != null ) ? pomFile.getParentFile() : null;
}
public String getValueOfProjectUri( String projectUri, boolean withResolvedValue )
throws IOException
{
if ( projectUri.contains( "#collection" ) || projectUri.contains( "#set" ) )
{
throw new IllegalArgumentException( "projectUri: contains a collection or set" );
}
return asMap( withResolvedValue ).get( projectUri );
}
public void setValueOnModel( String expression, Object value )
{
context.setValue( expression, value );
}
/*
public int containerCountForUri( String uri )
throws IOException
{
if ( uri == null || uri.trim().equals( "" ) )
{
throw new IllegalArgumentException( "uri: null or empty" );
}
ModelDataSource source = new DefaultModelDataSource();
source.init( domainModel.getModelProperties(), null );
return source.queryFor( uri ).size();
}
*/
public Iterator<?> getIteratorForXPathExpression( String expression )
{
return context.iterate( expression );
}
public boolean containsXPathExpression( String expression )
{
return context.getValue( expression ) != null;
}
public Object getValue( String expression )
{
try
{
return context.getValue( expression );
}
catch ( JXPathNotFoundException e )
{
return null;
}
}
public boolean xPathExpressionEqualsValue( String expression, String value )
{
return context.getValue( expression ) != null && context.getValue( expression ).equals( value );
}
public Map<String, String> asMap( boolean withResolvedValues )
throws IOException
{
Map<String, String> map = new HashMap<String, String>();
for ( ModelProperty mp : domainModel.getModelProperties() )
{
if ( withResolvedValues )
{
map.put( mp.getUri(), mp.getResolvedValue() );
}
else
{
map.put( mp.getUri(), mp.getValue() );
}
}
return map;
}
public boolean containsModelProperty( ModelProperty modelProperty )
throws IOException
{
return domainModel.getModelProperties().contains( modelProperty );
}
public boolean containsAllModelPropertiesOf( List<ModelProperty> modelProperties )
throws IOException
{
for ( ModelProperty mp : modelProperties )
{
if ( !containsModelProperty( mp ) )
{
return false;
}
}
return true;
}
public boolean matchModelProperties( List<ModelProperty> hasProperties, List<ModelProperty> doesNotHaveProperties )
throws IOException
{
return containsAllModelPropertiesOf( hasProperties ) && containNoModelPropertiesOf( doesNotHaveProperties );
}
public boolean matchUris( List<String> hasAllUris, List<String> doesNotHaveUris )
throws IOException
{
return hasAllUris( hasAllUris ) && hasNoUris( doesNotHaveUris );
}
public boolean containNoModelPropertiesOf( List<ModelProperty> modelProperties )
throws IOException
{
for ( ModelProperty mp : modelProperties )
{
if ( containsModelProperty( mp ) )
{
return false;
}
}
return true;
}
public boolean hasUri( String uri )
throws IOException
{
for ( ModelProperty mp : domainModel.getModelProperties() )
{
if ( mp.getValue().equals( uri ) )
{
return true;
}
}
return false;
}
public boolean hasAllUris( List<String> uris )
throws IOException
{
for ( String s : uris )
{
if ( !hasUri( s ) )
{
return false;
}
}
return true;
}
public boolean hasNoUris( List<String> uris )
throws IOException
{
for ( String s : uris )
{
if ( hasUri( s ) )
{
return false;
}
}
return true;
}
}

View File

@ -0,0 +1,90 @@
package org.apache.maven.project.harness;
/*
* 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.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.jxpath.ri.QName;
import org.apache.commons.jxpath.ri.model.NodeIterator;
import org.apache.commons.jxpath.ri.model.NodePointer;
import org.codehaus.plexus.util.xml.Xpp3Dom;
/**
* An attribute iterator for JXPath to support <code>Xpp3Dom</code>.
*
* @author Benjamin Bentmann
* @version $Id: Xpp3DomAttributeIterator.java 747943 2009-02-25 22:28:48Z bentmann $
*/
class Xpp3DomAttributeIterator
implements NodeIterator
{
private NodePointer parent;
private Xpp3Dom node;
private List<Map.Entry<String, String>> attributes;
private Map.Entry<String, String> attribute;
private int position;
public Xpp3DomAttributeIterator( NodePointer parent, QName qname )
{
this.parent = parent;
this.node = (Xpp3Dom) parent.getNode();
Map<String, String> map = new LinkedHashMap<String, String>();
for ( String name : this.node.getAttributeNames() )
{
if ( name.equals( qname.getName() ) || "*".equals( qname.getName() ) )
{
String value = this.node.getAttribute( name );
map.put( name, value );
}
}
this.attributes = new ArrayList<Map.Entry<String, String>>( map.entrySet() );
}
public NodePointer getNodePointer()
{
if ( position == 0 )
{
setPosition( 1 );
}
return ( attribute == null ) ? null : new Xpp3DomAttributePointer( parent, attribute );
}
public int getPosition()
{
return position;
}
public boolean setPosition( int position )
{
this.position = position;
attribute = ( position > 0 && position <= attributes.size() ) ? attributes.get( position - 1 ) : null;
return attribute != null;
}
}

View File

@ -0,0 +1,105 @@
package org.apache.maven.project.harness;
/*
* 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.util.Map;
import org.apache.commons.jxpath.ri.QName;
import org.apache.commons.jxpath.ri.model.NodePointer;
/**
* An attribute pointer for JXPath to support <code>Xpp3Dom</code>.
*
* @author Benjamin Bentmann
*/
class Xpp3DomAttributePointer
extends NodePointer
{
private Map.Entry<String, String> attrib;
public Xpp3DomAttributePointer( NodePointer parent, Map.Entry<String, String> attrib )
{
super( parent );
this.attrib = attrib;
}
@Override
public int compareChildNodePointers( NodePointer pointer1, NodePointer pointer2 )
{
// should never happen because attributes have no children
return 0;
}
@Override
public Object getValue()
{
return attrib.getValue();
}
@Override
public Object getBaseValue()
{
return attrib;
}
@Override
public Object getImmediateNode()
{
return attrib;
}
@Override
public int getLength()
{
return 1;
}
@Override
public QName getName()
{
return new QName( null, attrib.getKey() );
}
@Override
public boolean isActual()
{
return true;
}
@Override
public boolean isCollection()
{
return false;
}
@Override
public boolean isLeaf()
{
return true;
}
@Override
public void setValue( Object value )
{
throw new UnsupportedOperationException();
}
}

View File

@ -0,0 +1,161 @@
package org.apache.maven.project.harness;
/*
* 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.util.ArrayList;
import java.util.List;
import org.apache.commons.jxpath.ri.Compiler;
import org.apache.commons.jxpath.ri.compiler.NodeNameTest;
import org.apache.commons.jxpath.ri.compiler.NodeTest;
import org.apache.commons.jxpath.ri.compiler.NodeTypeTest;
import org.apache.commons.jxpath.ri.model.NodeIterator;
import org.apache.commons.jxpath.ri.model.NodePointer;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
/**
* A node iterator for JXPath to support <code>Xpp3Dom</code>.
*
* @author Benjamin Bentmann
* @version $Id: Xpp3DomNodeIterator.java 737056 2009-01-23 15:35:43Z bentmann $
*/
class Xpp3DomNodeIterator
implements NodeIterator
{
private NodePointer parent;
private NodeTest test;
private Xpp3Dom node;
private Xpp3Dom[] children;
private List<Xpp3Dom> filteredChildren = new ArrayList<Xpp3Dom>();
private int filteredIndex;
private Xpp3Dom child;
private int position;
public Xpp3DomNodeIterator( NodePointer parent, NodeTest test, boolean reverse, NodePointer startWith )
{
this.parent = parent;
this.node = (Xpp3Dom) parent.getNode();
this.children = this.node.getChildren();
if ( startWith != null )
{
for ( ; filteredIndex < children.length; filteredIndex++ )
{
if ( startWith.equals( children[filteredIndex] ) )
{
filteredIndex++;
break;
}
}
}
this.test = test;
if ( reverse )
{
throw new UnsupportedOperationException();
}
}
public NodePointer getNodePointer()
{
if ( position == 0 )
{
setPosition( 1 );
}
return ( child == null ) ? null : new Xpp3DomNodePointer( parent, child );
}
public int getPosition()
{
return position;
}
public boolean setPosition( int position )
{
this.position = position;
filterChildren( position );
child = ( position > 0 && position <= filteredChildren.size() ) ? filteredChildren.get( position - 1 ) : null;
return child != null;
}
private void filterChildren( int position )
{
for ( ; position > filteredChildren.size() && filteredIndex < children.length; filteredIndex++ )
{
Xpp3Dom child = children[filteredIndex];
if ( testNode( child ) )
{
filteredChildren.add( child );
}
}
}
private boolean testNode( Xpp3Dom node )
{
if ( test == null )
{
return true;
}
if ( test instanceof NodeNameTest )
{
String nodeName = node.getName();
if ( StringUtils.isEmpty( nodeName ) )
{
return false;
}
NodeNameTest nodeNameTest = (NodeNameTest) test;
String namespaceURI = nodeNameTest.getNamespaceURI();
boolean wildcard = nodeNameTest.isWildcard();
String testName = nodeNameTest.getNodeName().getName();
String testPrefix = nodeNameTest.getNodeName().getPrefix();
if ( wildcard && testPrefix == null )
{
return true;
}
if ( wildcard || testName.equals( nodeName ) )
{
return StringUtils.isEmpty( namespaceURI ) || StringUtils.isEmpty( testPrefix );
}
return false;
}
if ( test instanceof NodeTypeTest )
{
switch ( ( (NodeTypeTest) test ).getNodeType() )
{
case Compiler.NODE_TYPE_NODE:
return true;
case Compiler.NODE_TYPE_TEXT:
return node.getValue() != null;
default:
return false;
}
}
return false;
}
}

View File

@ -0,0 +1,156 @@
package org.apache.maven.project.harness;
/*
* 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.util.ArrayList;
import java.util.List;
import org.apache.commons.jxpath.ri.QName;
import org.apache.commons.jxpath.ri.compiler.NodeTest;
import org.apache.commons.jxpath.ri.model.NodeIterator;
import org.apache.commons.jxpath.ri.model.NodePointer;
import org.codehaus.plexus.util.xml.Xpp3Dom;
/**
* A node pointer for JXPath to support <code>Xpp3Dom</code>.
*
* @author Benjamin Bentmann
* @version $Id: Xpp3DomNodePointer.java 747943 2009-02-25 22:28:48Z bentmann $
*/
class Xpp3DomNodePointer
extends NodePointer
{
private Xpp3Dom node;
public Xpp3DomNodePointer( Xpp3Dom node )
{
super( null );
this.node = node;
}
public Xpp3DomNodePointer( NodePointer parent, Xpp3Dom node )
{
super( parent );
this.node = node;
}
@Override
public int compareChildNodePointers( NodePointer pointer1, NodePointer pointer2 )
{
Xpp3Dom node1 = (Xpp3Dom) pointer1.getBaseValue();
Xpp3Dom node2 = (Xpp3Dom) pointer2.getBaseValue();
if ( node1 == node2 )
{
return 0;
}
for ( int i = 0; i < node.getChildCount(); i++ )
{
Xpp3Dom child = node.getChild( i );
if ( child == node1 )
{
return -1;
}
if ( child == node2 )
{
return 1;
}
}
return 0;
}
@Override
public Object getValue()
{
return getValue(node);
}
private static Object getValue( Xpp3Dom node )
{
if ( node.getValue() != null )
{
return node.getValue().trim();
}
else
{
List<Object> children = new ArrayList<Object>();
for ( int i = 0; i < node.getChildCount(); i++ )
{
children.add( getValue( node.getChild( i ) ) );
}
return children;
}
}
@Override
public Object getBaseValue()
{
return node;
}
@Override
public Object getImmediateNode()
{
return node;
}
@Override
public int getLength()
{
return 1;
}
@Override
public QName getName()
{
return new QName( null, node.getName() );
}
@Override
public boolean isCollection()
{
return false;
}
@Override
public boolean isLeaf()
{
return node.getChildCount() <= 0;
}
@Override
public void setValue( Object value )
{
throw new UnsupportedOperationException();
}
@Override
public NodeIterator childIterator( NodeTest test, boolean reverse, NodePointer startWith )
{
return new Xpp3DomNodeIterator( this, test, reverse, startWith );
}
@Override
public NodeIterator attributeIterator( QName qname )
{
return new Xpp3DomAttributeIterator( this, qname );
}
}

View File

@ -0,0 +1,62 @@
package org.apache.maven.project.harness;
/*
* 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.util.Locale;
import org.apache.commons.jxpath.ri.QName;
import org.apache.commons.jxpath.ri.model.NodePointer;
import org.apache.commons.jxpath.ri.model.NodePointerFactory;
import org.codehaus.plexus.util.xml.Xpp3Dom;
/**
* A node pointer factory for JXPath to support <code>Xpp3Dom</code>.
*
* @author Benjamin Bentmann
* @version $Id: Xpp3DomPointerFactory.java 737056 2009-01-23 15:35:43Z bentmann $
*/
class Xpp3DomPointerFactory
implements NodePointerFactory
{
public int getOrder()
{
return 200;
}
public NodePointer createNodePointer( QName name, Object object, Locale locale )
{
if ( object instanceof Xpp3Dom )
{
return new Xpp3DomNodePointer( (Xpp3Dom) object );
}
return null;
}
public NodePointer createNodePointer( NodePointer parent, QName name, Object object )
{
if ( object instanceof Xpp3Dom )
{
return new Xpp3DomNodePointer( parent, (Xpp3Dom) object );
}
return null;
}
}

View File

@ -0,0 +1,95 @@
package org.apache.maven.settings;
import java.io.File;
import java.io.IOException;
import java.io.Reader;
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
import org.apache.maven.model.Profile;
import org.apache.maven.profiles.DefaultProfileManager;
import org.apache.maven.profiles.ProfileActivationContext;
import org.apache.maven.profiles.ProfileManager;
import org.apache.maven.project.DefaultMavenProjectBuilder;
import org.apache.maven.project.DefaultProjectBuilderConfiguration;
import org.apache.maven.project.MavenProjectBuilder;
import org.apache.maven.project.ProjectBuilderConfiguration;
import org.apache.maven.project.harness.PomTestWrapper;
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.ReaderFactory;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
public class PomConstructionWithSettingsTest
extends PlexusTestCase
{
private static String BASE_DIR = "src/test";
private static String BASE_POM_DIR = BASE_DIR + "/resources-settings";
private DefaultMavenProjectBuilder mavenProjectBuilder;
private File testDirectory;
protected void setUp()
throws Exception
{
testDirectory = new File( getBasedir(), BASE_POM_DIR );
mavenProjectBuilder = (DefaultMavenProjectBuilder) lookup( MavenProjectBuilder.class );
}
public void testA() throws Exception
{
PomTestWrapper pom = buildPom( "settings-no-pom" );
System.out.println(pom.getDomainModel().asString());
}
private PomTestWrapper buildPom( String pomPath )
throws Exception
{
File pomFile = new File( testDirectory + File.separator + pomPath , "pom.xml" );
File settingsFile = new File( testDirectory + File.separator + pomPath, "settings.xml" );
Settings settings = readSettingsFile(settingsFile);
ProfileActivationContext pCtx = new ProfileActivationContext(null, true);
ProfileManager profileManager = new DefaultProfileManager(getContainer(), pCtx);
for ( org.apache.maven.settings.Profile rawProfile : settings.getProfiles() )
{
Profile profile = SettingsUtils.convertFromSettingsProfile( rawProfile );
profileManager.addProfile( profile );
}
ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
config.setLocalRepository(new DefaultArtifactRepository("default", "", new DefaultRepositoryLayout()));
config.setGlobalProfileManager(profileManager);
return new PomTestWrapper( pomFile, mavenProjectBuilder.build( pomFile, config ) );
}
private static Settings readSettingsFile(File settingsFile)
throws IOException, XmlPullParserException
{
Settings settings = null;
Reader reader = null;
try
{
reader = ReaderFactory.newXmlReader( settingsFile );
SettingsXpp3Reader modelReader = new SettingsXpp3Reader();
settings = modelReader.read( reader );
}
finally
{
IOUtil.close( reader );
}
return settings;
}
}

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng3099</groupId>
<artifactId>maven-mng3099-plugin</artifactId>
<version>1</version>
<packaging>maven-plugin</packaging>
<name>maven-mng3099-plugin</name>
<description>Tests properties injected as a result of active profiles in the user settings file.</description>
</project>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<profiles>
<profile>
<id>local-profile</id>
<properties>
<local-profile-prop>local-profile-prop-value</local-profile-prop>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>local-profile</activeProfile>
</activeProfiles>
</settings>