mirror of https://github.com/apache/maven.git
o pom-level profiles are working now
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@189464 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
db347aab21
commit
29878afcc6
|
@ -67,6 +67,9 @@ it0019: Test that a version is managed by pluginManagement in the super POM
|
|||
|
||||
it0020: Test beanshell mojo support.
|
||||
|
||||
it0021: Test pom-level profile inclusion (this one is activated by system
|
||||
property).
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- generated sources
|
||||
|
|
|
@ -19,3 +19,4 @@ it0017
|
|||
it0018
|
||||
it0019
|
||||
it0020
|
||||
it0021
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
${artifact:org.apache.maven:maven-core-it-support:1.0:jar}
|
|
@ -0,0 +1 @@
|
|||
compile
|
|
@ -0,0 +1,28 @@
|
|||
<model>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-it0021-plugin</artifactId>
|
||||
<packaging>maven-plugin</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>test-profile</id>
|
||||
|
||||
<activation>
|
||||
<property>
|
||||
<name>includeProfile</name>
|
||||
</property>
|
||||
</activation>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-core-it-support</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
</model>
|
|
@ -0,0 +1 @@
|
|||
rm ${artifact:org.apache.maven:maven-core-it-support:1.0:jar}
|
|
@ -0,0 +1,16 @@
|
|||
package org.apache.maven.it0021;
|
||||
|
||||
public class Person
|
||||
{
|
||||
private String name;
|
||||
|
||||
public void setName( String name )
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
includeProfile=true
|
|
@ -2342,10 +2342,36 @@
|
|||
<field>
|
||||
<name>property</name>
|
||||
<version>4.0.0</version>
|
||||
<type>String</type>
|
||||
<description><![CDATA[
|
||||
Specifies that this profile will be activated when this System property is specified.
|
||||
]]></description>
|
||||
<association>
|
||||
<type>ActivationProperty</type>
|
||||
</association>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
<class>
|
||||
<name>ActivationProperty</name>
|
||||
<version>4.0.0</version>
|
||||
<description><![CDATA[
|
||||
This is the property specification used to activate a profile. If the value field is empty,
|
||||
then the existence of the named property will activate the profile, otherwise it does a case-sensitive
|
||||
match against the property value as well.
|
||||
]]></description>
|
||||
<fields>
|
||||
<field>
|
||||
<name>name</name>
|
||||
<version>4.0.0</version>
|
||||
<type>String</type>
|
||||
<required>true</required>
|
||||
<description>The name of the property to be used to activate a profile</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>value</name>
|
||||
<version>4.0.0</version>
|
||||
<type>String</type>
|
||||
<description>The value of the property to be used to activate a profile</description>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
|
|
|
@ -119,10 +119,12 @@
|
|||
<field>
|
||||
<name>property</name>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<description><![CDATA[
|
||||
Specifies that this profile will be activated when this System property is specified.
|
||||
]]></description>
|
||||
<association>
|
||||
<type>ActivationProperty</type>
|
||||
</association>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
|
@ -197,5 +199,29 @@
|
|||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
<class>
|
||||
<name>ActivationProperty</name>
|
||||
<version>1.0.0</version>
|
||||
<description><![CDATA[
|
||||
This is the property specification used to activate a profile. If the value field is empty,
|
||||
then the existence of the named property will activate the profile, otherwise it does a case-sensitive
|
||||
match against the property value as well.
|
||||
]]></description>
|
||||
<fields>
|
||||
<field>
|
||||
<name>name</name>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<required>true</required>
|
||||
<description>The name of the property to be used to activate a profile</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>value</name>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<description>The value of the property to be used to activate a profile</description>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
</classes>
|
||||
</model>
|
|
@ -0,0 +1,28 @@
|
|||
package org.apache.maven.profile.activation;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
public final class ActivationConstants
|
||||
{
|
||||
|
||||
public static final String ACTIVE_PROFILE_IDS = "org.apache.maven.ActiveProfileIds";
|
||||
|
||||
private ActivationConstants()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package org.apache.maven.profile.activation;
|
||||
|
||||
import org.apache.maven.model.Profile;
|
||||
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
public class ExplicitListingProfileActivator
|
||||
implements ProfileActivator
|
||||
{
|
||||
|
||||
public boolean canDetermineActivation( Profile profile )
|
||||
{
|
||||
return profile.getActivation() == null;
|
||||
}
|
||||
|
||||
public boolean isActive( Profile profile )
|
||||
{
|
||||
String activeProfiles = System.getProperty( ActivationConstants.ACTIVE_PROFILE_IDS );
|
||||
|
||||
if ( activeProfiles != null )
|
||||
{
|
||||
String profileId = profile.getId();
|
||||
|
||||
StringTokenizer profileTokens = new StringTokenizer( activeProfiles, "," );
|
||||
|
||||
while ( profileTokens.hasMoreTokens() )
|
||||
{
|
||||
String currentToken = profileTokens.nextToken().trim();
|
||||
|
||||
if ( profileId.equals( currentToken ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package org.apache.maven.profile.activation;
|
||||
|
||||
import org.apache.maven.model.Activation;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
public class JdkPrefixProfileActivator
|
||||
implements ProfileActivator
|
||||
{
|
||||
|
||||
private static final String JDK_VERSION = System.getProperty( "java.version" );
|
||||
|
||||
public boolean isActive( Profile profile )
|
||||
{
|
||||
Activation activation = profile.getActivation();
|
||||
|
||||
String jdk = activation.getJdk();
|
||||
|
||||
// null case is covered by canDetermineActivation(), so we can do a straight startsWith() here.
|
||||
return JDK_VERSION.startsWith( jdk );
|
||||
}
|
||||
|
||||
public boolean canDetermineActivation( Profile profile )
|
||||
{
|
||||
return profile.getActivation() != null && StringUtils.isNotEmpty( profile.getActivation().getJdk() );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
package org.apache.maven.profile.activation;
|
||||
|
||||
import org.apache.maven.model.Activation;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.codehaus.plexus.PlexusConstants;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
import org.codehaus.plexus.context.Context;
|
||||
import org.codehaus.plexus.context.ContextException;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
public class ProfileActivationCalculator
|
||||
extends AbstractLogEnabled
|
||||
implements Contextualizable
|
||||
{
|
||||
|
||||
public static final String ROLE = ProfileActivationCalculator.class.getName();
|
||||
|
||||
private PlexusContainer container;
|
||||
|
||||
public List calculateActiveProfiles( List profiles )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
List activators = null;
|
||||
try
|
||||
{
|
||||
activators = container.lookupList( ProfileActivator.ROLE );
|
||||
|
||||
List active = new ArrayList( profiles.size() );
|
||||
|
||||
for ( Iterator it = profiles.iterator(); it.hasNext(); )
|
||||
{
|
||||
Profile profile = (Profile) it.next();
|
||||
|
||||
boolean isActive = true;
|
||||
|
||||
Activation activation = profile.getActivation();
|
||||
|
||||
activatorLoop: for ( Iterator activatorIterator = activators.iterator(); activatorIterator.hasNext(); )
|
||||
{
|
||||
ProfileActivator activator = (ProfileActivator) activatorIterator.next();
|
||||
|
||||
if ( activator.canDetermineActivation( profile ) )
|
||||
{
|
||||
if ( activator.isActive( profile ) )
|
||||
{
|
||||
active.add( profile );
|
||||
}
|
||||
else
|
||||
{
|
||||
break activatorLoop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return active;
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
throw new ProjectBuildingException( "Cannot retrieve list of profile activators.", e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
container.releaseAll( activators );
|
||||
}
|
||||
catch ( ComponentLifecycleException e )
|
||||
{
|
||||
getLogger().debug( "Error releasing profile activators - ignoring.", e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void contextualize( Context context )
|
||||
throws ContextException
|
||||
{
|
||||
this.container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package org.apache.maven.profile.activation;
|
||||
|
||||
import org.apache.maven.model.Profile;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
public interface ProfileActivator
|
||||
{
|
||||
|
||||
static final String ROLE = ProfileActivator.class.getName();
|
||||
|
||||
boolean canDetermineActivation( Profile profile );
|
||||
|
||||
boolean isActive( Profile profile );
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package org.apache.maven.profile.activation;
|
||||
|
||||
import org.apache.maven.model.Activation;
|
||||
import org.apache.maven.model.ActivationProperty;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
public class SystemPropertyProfileActivator
|
||||
implements ProfileActivator
|
||||
{
|
||||
|
||||
public boolean canDetermineActivation( Profile profile )
|
||||
{
|
||||
return profile.getActivation() != null && profile.getActivation().getProperty() != null;
|
||||
}
|
||||
|
||||
public boolean isActive( Profile profile )
|
||||
{
|
||||
Activation activation = profile.getActivation();
|
||||
|
||||
ActivationProperty property = activation.getProperty();
|
||||
|
||||
if ( property != null )
|
||||
{
|
||||
String sysValue = System.getProperty( property.getName() );
|
||||
|
||||
String propValue = property.getValue();
|
||||
if ( StringUtils.isNotEmpty( propValue ) )
|
||||
{
|
||||
// we have a value, so it has to match the system value...
|
||||
return propValue.equals( sysValue );
|
||||
}
|
||||
else
|
||||
{
|
||||
return StringUtils.isNotEmpty( sysValue );
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -27,13 +27,14 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
|||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||
import org.apache.maven.artifact.transform.ReleaseArtifactTransformation;
|
||||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.DistributionManagement;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Parent;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.apache.maven.model.Repository;
|
||||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
||||
import org.apache.maven.profile.activation.ProfileActivationCalculator;
|
||||
import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
|
||||
import org.apache.maven.project.injection.ModelDefaultsInjector;
|
||||
import org.apache.maven.project.interpolation.ModelInterpolationException;
|
||||
|
@ -98,6 +99,8 @@ public class DefaultMavenProjectBuilder
|
|||
private ModelInterpolator modelInterpolator;
|
||||
|
||||
private ArtifactRepositoryFactory artifactRepositoryFactory;
|
||||
|
||||
private ProfileActivationCalculator profileActivationCalculator;
|
||||
|
||||
private final Map modelCache = new HashMap();
|
||||
|
||||
|
@ -263,6 +266,15 @@ public class DefaultMavenProjectBuilder
|
|||
{
|
||||
modelCache.put( key, model );
|
||||
}
|
||||
|
||||
// TODO: Add profiles support here?
|
||||
List activePomProfiles = profileActivationCalculator.calculateActiveProfiles( model.getProfiles() );
|
||||
for ( Iterator it = activePomProfiles.iterator(); it.hasNext(); )
|
||||
{
|
||||
Profile profile = (Profile) it.next();
|
||||
|
||||
modelInheritanceAssembler.mergeProfileWithModel( cachedModel, profile );
|
||||
}
|
||||
|
||||
model = modelInterpolator.interpolate( model );
|
||||
|
||||
|
|
|
@ -17,11 +17,14 @@ package org.apache.maven.project.inheritance;
|
|||
*/
|
||||
|
||||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.BuildBase;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.DependencyManagement;
|
||||
import org.apache.maven.model.DistributionManagement;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.ModelBase;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.apache.maven.model.Repository;
|
||||
import org.apache.maven.model.Scm;
|
||||
import org.apache.maven.model.Site;
|
||||
|
@ -44,6 +47,12 @@ public class DefaultModelInheritanceAssembler
|
|||
{
|
||||
public void assembleModelInheritance( Model child, Model parent )
|
||||
{
|
||||
// cannot inherit from null parent.
|
||||
if ( parent == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Group id
|
||||
if ( child.getGroupId() == null )
|
||||
{
|
||||
|
@ -56,7 +65,7 @@ public class DefaultModelInheritanceAssembler
|
|||
{
|
||||
// The parent version may have resolved to something different, so we take what we asked for...
|
||||
// instead of - child.setVersion( parent.getVersion() );
|
||||
|
||||
|
||||
if ( child.getParent() != null )
|
||||
{
|
||||
child.setVersion( child.getParent().getVersion() );
|
||||
|
@ -134,8 +143,24 @@ public class DefaultModelInheritanceAssembler
|
|||
}
|
||||
|
||||
// Build
|
||||
assembleBuildInheritance( child, parent );
|
||||
assembleBuildInheritance( child, parent.getBuild() );
|
||||
|
||||
assembleModelBaseInheritance( child, parent );
|
||||
}
|
||||
|
||||
public void mergeProfileWithModel( Model model, Profile profile )
|
||||
{
|
||||
assembleModelBaseInheritance( model, profile );
|
||||
|
||||
Build modelBuild = model.getBuild();
|
||||
|
||||
BuildBase profileBuild = profile.getBuild();
|
||||
|
||||
assembleBuildBaseInheritance( modelBuild, profileBuild );
|
||||
}
|
||||
|
||||
private void assembleModelBaseInheritance( ModelBase child, ModelBase parent )
|
||||
{
|
||||
// Dependencies :: aggregate
|
||||
List dependencies = parent.getDependencies();
|
||||
|
||||
|
@ -175,7 +200,7 @@ public class DefaultModelInheritanceAssembler
|
|||
child.addPluginRepository( repository );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Reports :: aggregate
|
||||
if ( child.getReports() != null && parent.getReports() != null )
|
||||
{
|
||||
|
@ -201,8 +226,8 @@ public class DefaultModelInheritanceAssembler
|
|||
|
||||
assembleDependencyManagementInheritance( child, parent );
|
||||
}
|
||||
|
||||
private void assembleDependencyManagementInheritance( Model child, Model parent )
|
||||
|
||||
private void assembleDependencyManagementInheritance( ModelBase child, ModelBase parent )
|
||||
{
|
||||
DependencyManagement parentDepMgmt = parent.getDependencyManagement();
|
||||
|
||||
|
@ -237,10 +262,15 @@ public class DefaultModelInheritanceAssembler
|
|||
}
|
||||
}
|
||||
|
||||
private void assembleBuildInheritance( Model child, Model parent )
|
||||
private void assembleBuildInheritance( Model child, Build parentBuild )
|
||||
{
|
||||
// cannot inherit from null parent...
|
||||
if ( parentBuild == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Build childBuild = child.getBuild();
|
||||
Build parentBuild = parent.getBuild();
|
||||
|
||||
if ( parentBuild != null )
|
||||
{
|
||||
|
@ -253,11 +283,6 @@ public class DefaultModelInheritanceAssembler
|
|||
// values
|
||||
// that have not been set by the child.
|
||||
|
||||
if ( childBuild.getDefaultGoal() == null )
|
||||
{
|
||||
childBuild.setDefaultGoal( parentBuild.getDefaultGoal() );
|
||||
}
|
||||
|
||||
if ( childBuild.getDirectory() == null )
|
||||
{
|
||||
childBuild.setDirectory( parentBuild.getDirectory() );
|
||||
|
@ -288,31 +313,47 @@ public class DefaultModelInheritanceAssembler
|
|||
childBuild.setTestOutputDirectory( parentBuild.getTestOutputDirectory() );
|
||||
}
|
||||
|
||||
if ( childBuild.getFinalName() == null )
|
||||
{
|
||||
childBuild.setFinalName( parentBuild.getFinalName() );
|
||||
}
|
||||
assembleBuildBaseInheritance( childBuild, parentBuild );
|
||||
}
|
||||
}
|
||||
|
||||
List resources = childBuild.getResources();
|
||||
if ( resources == null || resources.isEmpty() )
|
||||
{
|
||||
childBuild.setResources( parentBuild.getResources() );
|
||||
}
|
||||
private void assembleBuildBaseInheritance( BuildBase childBuild, BuildBase parentBuild )
|
||||
{
|
||||
// if the parent build is null, obviously we cannot inherit from it...
|
||||
if ( parentBuild == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
resources = childBuild.getTestResources();
|
||||
if ( resources == null || resources.isEmpty() )
|
||||
{
|
||||
childBuild.setTestResources( parentBuild.getTestResources() );
|
||||
}
|
||||
if ( childBuild.getDefaultGoal() == null )
|
||||
{
|
||||
childBuild.setDefaultGoal( parentBuild.getDefaultGoal() );
|
||||
}
|
||||
|
||||
// Plugins are aggregated if Plugin.inherit != false
|
||||
ModelUtils.mergePluginLists( childBuild, parentBuild, true );
|
||||
|
||||
// Plugin management :: aggregate
|
||||
if( childBuild != null && parentBuild != null )
|
||||
{
|
||||
ModelUtils.mergePluginLists( childBuild.getPluginManagement(), parentBuild.getPluginManagement(), false );
|
||||
}
|
||||
if ( childBuild.getFinalName() == null )
|
||||
{
|
||||
childBuild.setFinalName( parentBuild.getFinalName() );
|
||||
}
|
||||
|
||||
List resources = childBuild.getResources();
|
||||
if ( resources == null || resources.isEmpty() )
|
||||
{
|
||||
childBuild.setResources( parentBuild.getResources() );
|
||||
}
|
||||
|
||||
resources = childBuild.getTestResources();
|
||||
if ( resources == null || resources.isEmpty() )
|
||||
{
|
||||
childBuild.setTestResources( parentBuild.getTestResources() );
|
||||
}
|
||||
|
||||
// Plugins are aggregated if Plugin.inherit != false
|
||||
ModelUtils.mergePluginLists( childBuild, parentBuild, true );
|
||||
|
||||
// Plugin management :: aggregate
|
||||
if ( childBuild != null && parentBuild != null )
|
||||
{
|
||||
ModelUtils.mergePluginLists( childBuild.getPluginManagement(), parentBuild.getPluginManagement(), false );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -336,10 +377,11 @@ public class DefaultModelInheritanceAssembler
|
|||
childScm.setConnection( appendPath( parentScm.getConnection(), child.getArtifactId() ) );
|
||||
}
|
||||
|
||||
if ( StringUtils.isEmpty( childScm.getDeveloperConnection() ) &&
|
||||
!StringUtils.isEmpty( parentScm.getDeveloperConnection() ) )
|
||||
if ( StringUtils.isEmpty( childScm.getDeveloperConnection() )
|
||||
&& !StringUtils.isEmpty( parentScm.getDeveloperConnection() ) )
|
||||
{
|
||||
childScm.setDeveloperConnection( appendPath( parentScm.getDeveloperConnection(), child.getArtifactId() ) );
|
||||
childScm
|
||||
.setDeveloperConnection( appendPath( parentScm.getDeveloperConnection(), child.getArtifactId() ) );
|
||||
}
|
||||
|
||||
if ( StringUtils.isEmpty( childScm.getUrl() ) && !StringUtils.isEmpty( parentScm.getUrl() ) )
|
||||
|
|
|
@ -17,6 +17,7 @@ package org.apache.maven.project.inheritance;
|
|||
*/
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Profile;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||
|
@ -27,4 +28,6 @@ public interface ModelInheritanceAssembler
|
|||
String ROLE = ModelInheritanceAssembler.class.getName();
|
||||
|
||||
void assembleModelInheritance( Model child, Model parent );
|
||||
|
||||
void mergeProfileWithModel( Model model, Profile profile );
|
||||
}
|
||||
|
|
|
@ -51,8 +51,50 @@
|
|||
<requirement>
|
||||
<role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.profile.activation.ProfileActivationCalculator</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
<!--
|
||||
|
|
||||
|
|
||||
|
|
||||
-->
|
||||
<component>
|
||||
<role>org.apache.maven.profile.activation.ProfileActivationCalculator</role>
|
||||
<implementation>org.apache.maven.profile.activation.ProfileActivationCalculator</implementation>
|
||||
</component>
|
||||
<!--
|
||||
|
|
||||
|
|
||||
|
|
||||
-->
|
||||
<component>
|
||||
<role>org.apache.maven.profile.activation.ProfileActivator</role>
|
||||
<role-hint>jdk-prefix</role-hint>
|
||||
<implementation>org.apache.maven.profile.activation.JdkPrefixProfileActivator</implementation>
|
||||
</component>
|
||||
<!--
|
||||
|
|
||||
|
|
||||
|
|
||||
-->
|
||||
<component>
|
||||
<role>org.apache.maven.profile.activation.ProfileActivator</role>
|
||||
<role-hint>system-property</role-hint>
|
||||
<implementation>org.apache.maven.profile.activation.SystemPropertyProfileActivator</implementation>
|
||||
</component>
|
||||
<!--
|
||||
|
|
||||
|
|
||||
|
|
||||
-->
|
||||
<component>
|
||||
<role>org.apache.maven.profile.activation.ProfileActivator</role>
|
||||
<role-hint>explicit-listing</role-hint>
|
||||
<implementation>org.apache.maven.profile.activation.ExplicitListingProfileActivator</implementation>
|
||||
</component>
|
||||
<!--
|
||||
|
|
||||
|
|
||||
|
|
|
@ -438,10 +438,12 @@
|
|||
<field>
|
||||
<name>property</name>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<description><![CDATA[
|
||||
Specifies that this profile will be activated when this System property is specified.
|
||||
]]></description>
|
||||
<association>
|
||||
<type>ActivationProperty</type>
|
||||
</association>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
|
@ -516,6 +518,30 @@
|
|||
</codeSegment>
|
||||
</codeSegments>
|
||||
</class>
|
||||
<class>
|
||||
<name>ActivationProperty</name>
|
||||
<version>1.0.0</version>
|
||||
<description><![CDATA[
|
||||
This is the property specification used to activate a profile. If the value field is empty,
|
||||
then the existence of the named property will activate the profile, otherwise it does a case-sensitive
|
||||
match against the property value as well.
|
||||
]]></description>
|
||||
<fields>
|
||||
<field>
|
||||
<name>name</name>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<required>true</required>
|
||||
<description>The name of the property to be used to activate a profile</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>value</name>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<description>The value of the property to be used to activate a profile</description>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
<!-- /BuildProfile support -->
|
||||
</classes>
|
||||
</model>
|
Loading…
Reference in New Issue