You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/06/01 14:17:53 UTC
svn commit: r780627 [2/2] - in /maven/components/trunk:
maven-compat/src/main/java/org/apache/maven/profiles/
maven-core/src/main/java/org/apache/maven/project/
maven-core/src/test/java/org/apache/maven/project/
maven-model-builder/src/main/java/org/ap...
Added: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingRequest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingRequest.java?rev=780627&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingRequest.java (added)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingRequest.java Mon Jun 1 12:17:53 2009
@@ -0,0 +1,138 @@
+package org.apache.maven.model;
+
+/*
+ * 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.List;
+import java.util.Properties;
+
+import org.apache.maven.model.profile.ProfileActivationContext;
+
+/**
+ * Collects settings that control building of effective models.
+ *
+ * @author Benjamin Bentmann
+ */
+public interface ModelBuildingRequest
+{
+
+ /**
+ * Gets the level of validation to perform on processed models.
+ *
+ * @return {@code true} if lenient validation is enabled and only the dependency information is to be validated,
+ * {@code false} if strict validation is enabled and the entire model is validated.
+ */
+ boolean istLenientValidation();
+
+ /**
+ * Sets the level of validation to perform on processed models. By default, models are validated in strict mode.
+ *
+ * @param lenientValidation A flag whether validation should be lenient instead of strict. For building of projects,
+ * strict validation should be used to ensure proper building. For the mere retrievel of dependencies
+ * during artifact resolution, lenient validation should be used to account for models of poor quality.
+ * @return This request, never {@code null}.
+ */
+ ModelBuildingRequest setLenientValidation( boolean lenientValidation );
+
+ /**
+ * Indicates whether plugin executions and configurations should be processed. If enabled, lifecycle-induced plugin
+ * executions will be injected into the model and common plugin configuration will be propagated to individual
+ * executions.
+ *
+ * @return {@code true} if plugins should be processed, {@code false} otherwise.
+ */
+ boolean isProcessPlugins();
+
+ /**
+ * Controls the processing of plugin executions and configurations.
+ *
+ * @param processPlugins {@code true} to enable plugin processing, {@code false} otherwise.
+ * @return This request, never {@code null}.
+ */
+ ModelBuildingRequest setProcessPlugins( boolean processPlugins );
+
+ /**
+ * Gets the external profiles that should be considered for model building.
+ *
+ * @return The external profiles that should be considered for model building, never {@code null}.
+ */
+ List<Profile> getProfiles();
+
+ /**
+ * Sets the external profiles that should be considered for model building.
+ *
+ * @param profiles The external profiles that should be considered for model building, may be {@code null}.
+ * @return This request, never {@code null}.
+ */
+ ModelBuildingRequest setProfiles( List<Profile> profiles );
+
+ /**
+ * Gets the identifiers of those profiles that should be activated by explicit demand.
+ *
+ * @return The identifiers of those profiles to activate, never {@code null}.
+ */
+ List<String> getActiveProfileIds();
+
+ /**
+ * Sets the identifiers of those profiles that should be activated by explicit demand.
+ *
+ * @param activeProfileIds The identifiers of those profiles to activate, may be {@code null}.
+ * @return This request, never {@code null}.
+ */
+ ModelBuildingRequest setActiveProfileIds( List<String> activeProfileIds );
+
+ /**
+ * Gets the identifiers of those profiles that should be deactivated by explicit demand.
+ *
+ * @return The identifiers of those profiles to deactivate, never {@code null}.
+ */
+ List<String> getInactiveProfileIds();
+
+ /**
+ * Sets the identifiers of those profiles that should be deactivated by explicit demand.
+ *
+ * @param inactiveProfileIds The identifiers of those profiles to deactivate, may be {@code null}.
+ * @return This request, never {@code null}.
+ */
+ ModelBuildingRequest setInactiveProfileIds( List<String> inactiveProfileIds );
+
+ /**
+ * Gets the execution properties.
+ *
+ * @return The execution properties, never {@code null}.
+ */
+ Properties getExecutionProperties();
+
+ /**
+ * Sets the execution properties.
+ *
+ * @param executionProperties The execution properties, may be {@code null}.
+ * @return This request, never {@code null}.
+ */
+ ModelBuildingRequest setExecutionProperties( Properties executionProperties );
+
+ /**
+ * Gets the profile activation context for this request. The activation context is basically a view on a subset of
+ * settings from this request, manipulations to the request are reflected by the activation context and vice versa.
+ *
+ * @return The profile activation context for this request, never {@code null}.
+ */
+ ProfileActivationContext getProfileActivationContext();
+
+}
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingRequest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingRequest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingResult.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingResult.java?rev=780627&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingResult.java (added)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingResult.java Mon Jun 1 12:17:53 2009
@@ -0,0 +1,40 @@
+package org.apache.maven.model;
+
+/*
+ * 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.List;
+
+/**
+ * Collects the output of the model builder.
+ *
+ * @author Benjamin Bentmann
+ */
+public interface ModelBuildingResult
+{
+
+ Model getEffectiveModel();
+
+ Model getRawModel();
+
+ List<Model> getRawModels();
+
+ List<Profile> getActiveProfiles( Model rawModel );
+
+}
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingResult.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelBuildingResult.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelSource.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelSource.java?rev=780627&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelSource.java (added)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelSource.java Mon Jun 1 12:17:53 2009
@@ -0,0 +1,49 @@
+package org.apache.maven.model;
+
+/*
+ * 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.IOException;
+import java.io.InputStream;
+
+/**
+ * Provides access to the contents of a POM independently of the backing store (e.g. file system, database, memory).
+ *
+ * @author Benjamin Bentmann
+ */
+public interface ModelSource
+{
+
+ /**
+ * Gets a byte stream to the POM contents. Closing the returned stream is the responsibility of the caller.
+ *
+ * @return A byte stream to the POM contents, never {@code null}.
+ */
+ InputStream getInputStream()
+ throws IOException;
+
+ /**
+ * Provides a human-readable hint about the location of the POM. This could be a local file path, a URI or just an
+ * empty string. The intention is to assist users during error reporting.
+ *
+ * @return A human-readable hint about the location of the POM, never {@code null}.
+ */
+ String getLocation();
+
+}
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelSource.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelSource.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Copied: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelUtils.java (from r779760, maven/components/branches/maven-2.2.x/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java)
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelUtils.java?p2=maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelUtils.java&p1=maven/components/branches/maven-2.2.x/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java&r1=779760&r2=780627&rev=780627&view=diff
==============================================================================
--- maven/components/branches/maven-2.2.x/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java (original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/ModelUtils.java Mon Jun 1 12:17:53 2009
@@ -1,4 +1,4 @@
-package org.apache.maven.project;
+package org.apache.maven.model;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -20,13 +20,9 @@
*/
import java.util.ArrayList;
-import java.util.Enumeration;
import java.util.Iterator;
-import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
import java.util.Properties;
-import java.util.TreeMap;
import org.apache.maven.model.Activation;
import org.apache.maven.model.ActivationFile;
@@ -52,7 +48,6 @@
import org.apache.maven.model.Organization;
import org.apache.maven.model.Parent;
import org.apache.maven.model.Plugin;
-import org.apache.maven.model.PluginContainer;
import org.apache.maven.model.PluginExecution;
import org.apache.maven.model.PluginManagement;
import org.apache.maven.model.Prerequisites;
@@ -69,179 +64,130 @@
import org.apache.maven.model.Site;
import org.codehaus.plexus.util.xml.Xpp3Dom;
-public final class ModelUtils
+final class ModelUtils
{
- private static final ModelPartCloner DEPENDENCY_CLONER = new ModelPartCloner()
- {
- public Object cloneModelPart( Object src )
- {
- return ModelUtils.cloneDependency( (Dependency) src );
- }
- };
+ // TODO: Replace this with MODELLO-191
- private static final ModelPartCloner PLUGIN_CLONER = new ModelPartCloner()
+ private static final ModelPartCloner<Dependency> DEPENDENCY_CLONER = new ModelPartCloner<Dependency>()
{
- public Object cloneModelPart( Object src )
+ public Dependency cloneModelPart( Dependency src )
{
- return ModelUtils.clonePlugin( (Plugin) src );
+ return ModelUtils.cloneDependency( src );
}
};
- private static final ModelPartCloner EXTENSION_CLONER = new ModelPartCloner()
+ private static final ModelPartCloner<Plugin> PLUGIN_CLONER = new ModelPartCloner<Plugin>()
{
- public Object cloneModelPart( Object src )
+ public Plugin cloneModelPart( Plugin src )
{
- return ModelUtils.cloneExtension( (Extension) src );
+ return ModelUtils.clonePlugin( src );
}
};
- private static final ModelPartCloner RESOURCE_CLONER = new ModelPartCloner()
+ private static final ModelPartCloner<Extension> EXTENSION_CLONER = new ModelPartCloner<Extension>()
{
- public Object cloneModelPart( Object src )
+ public Extension cloneModelPart( Extension src )
{
- return ModelUtils.cloneResource( (Resource) src );
+ return ModelUtils.cloneExtension( src );
}
};
- private static final ModelPartCloner NOTIFIER_CLONER = new ModelPartCloner()
+ private static final ModelPartCloner<Resource> RESOURCE_CLONER = new ModelPartCloner<Resource>()
{
- public Object cloneModelPart( Object src )
+ public Resource cloneModelPart( Resource src )
{
- return ModelUtils.cloneNotifier( (Notifier) src );
+ return ModelUtils.cloneResource( src );
}
};
- private static final ModelPartCloner CONTRIBUTOR_CLONER = new ModelPartCloner()
+ private static final ModelPartCloner<Notifier> NOTIFIER_CLONER = new ModelPartCloner<Notifier>()
{
- public Object cloneModelPart( Object src )
+ public Notifier cloneModelPart( Notifier src )
{
- return ModelUtils.cloneContributor( (Contributor) src );
+ return ModelUtils.cloneNotifier( src );
}
};
- private static final ModelPartCloner DEVELOPER_CLONER = new ModelPartCloner()
+ private static final ModelPartCloner<Contributor> CONTRIBUTOR_CLONER = new ModelPartCloner<Contributor>()
{
- public Object cloneModelPart( Object src )
+ public Contributor cloneModelPart( Contributor src )
{
- return ModelUtils.cloneDeveloper( (Developer) src );
+ return ModelUtils.cloneContributor( src );
}
};
- private static final ModelPartCloner LICENSE_CLONER = new ModelPartCloner()
+ private static final ModelPartCloner<Developer> DEVELOPER_CLONER = new ModelPartCloner<Developer>()
{
- public Object cloneModelPart( Object src )
+ public Developer cloneModelPart( Developer src )
{
- return ModelUtils.cloneLicense( (License) src );
+ return ModelUtils.cloneDeveloper( src );
}
};
- private static final ModelPartCloner MAILING_LIST_CLONER = new ModelPartCloner()
+ private static final ModelPartCloner<License> LICENSE_CLONER = new ModelPartCloner<License>()
{
- public Object cloneModelPart( Object src )
+ public License cloneModelPart( License src )
{
- return ModelUtils.cloneMailingList( (MailingList) src );
+ return ModelUtils.cloneLicense( src );
}
};
- private static final ModelPartCloner REPOSITORY_CLONER = new ModelPartCloner()
+ private static final ModelPartCloner<MailingList> MAILING_LIST_CLONER = new ModelPartCloner<MailingList>()
{
- public Object cloneModelPart( Object src )
+ public MailingList cloneModelPart( MailingList src )
{
- return ModelUtils.cloneRepository( (Repository) src );
+ return ModelUtils.cloneMailingList( src );
}
};
- private static final ModelPartCloner PROFILE_CLONER = new ModelPartCloner()
+ private static final ModelPartCloner<Repository> REPOSITORY_CLONER = new ModelPartCloner<Repository>()
{
- public Object cloneModelPart( Object src )
+ public Repository cloneModelPart( Repository src )
{
- return ModelUtils.cloneProfile( (Profile) src );
+ return ModelUtils.cloneRepository( src );
}
};
- private static final ModelPartCloner REPORT_PLUGIN_CLONER = new ModelPartCloner()
+ private static final ModelPartCloner<Profile> PROFILE_CLONER = new ModelPartCloner<Profile>()
{
- public Object cloneModelPart( Object src )
+ public Profile cloneModelPart( Profile src )
{
- return ModelUtils.cloneReportPlugin( (ReportPlugin) src );
+ return ModelUtils.cloneProfile( src );
}
};
- private static final ModelPartCloner REPORT_SET_CLONER = new ModelPartCloner()
+ private static final ModelPartCloner<ReportPlugin> REPORT_PLUGIN_CLONER = new ModelPartCloner<ReportPlugin>()
{
- public Object cloneModelPart( Object src )
+ public ReportPlugin cloneModelPart( ReportPlugin src )
{
- return ModelUtils.cloneReportSet( (ReportSet) src );
+ return ModelUtils.cloneReportPlugin( src );
}
};
- private static final ModelPartCloner DEPENDENCY_EXCLUSION_CLONER = new ModelPartCloner()
+ private static final ModelPartCloner<ReportSet> REPORT_SET_CLONER = new ModelPartCloner<ReportSet>()
{
- public Object cloneModelPart( Object src )
+ public ReportSet cloneModelPart( ReportSet src )
{
- return ModelUtils.cloneExclusion( (Exclusion) src );
+ return ModelUtils.cloneReportSet( src );
}
};
- private static final ModelPartCloner PLUGIN_EXECUTION_CLONER = new ModelPartCloner()
+ private static final ModelPartCloner<Exclusion> DEPENDENCY_EXCLUSION_CLONER = new ModelPartCloner<Exclusion>()
{
- public Object cloneModelPart( Object src )
+ public Exclusion cloneModelPart( Exclusion src )
{
- return ModelUtils.clonePluginExecution( (PluginExecution) src );
+ return ModelUtils.cloneExclusion( src );
}
};
- /**
- * Given this plugin list:
- *
- * A1 -> B -> C -> A2 -> D
- *
- * Rearrange it to this:
- *
- * A(A1 + A2) -> B -> C -> D
- *
- * In cases of overlapping definitions, A1 is overridden by A2
- *
- */
- public static void mergeDuplicatePluginDefinitions( PluginContainer pluginContainer )
+ private static final ModelPartCloner<PluginExecution> PLUGIN_EXECUTION_CLONER = new ModelPartCloner<PluginExecution>()
{
- if ( pluginContainer == null )
+ public PluginExecution cloneModelPart( PluginExecution src )
{
- return;
+ return ModelUtils.clonePluginExecution( src );
}
-
- List originalPlugins = pluginContainer.getPlugins();
-
- if ( ( originalPlugins == null ) || originalPlugins.isEmpty() )
- {
- return;
- }
-
- List normalized = new ArrayList( originalPlugins.size() );
-
- for ( Iterator it = originalPlugins.iterator(); it.hasNext(); )
- {
- Plugin currentPlugin = (Plugin) it.next();
-
- if ( normalized.contains( currentPlugin ) )
- {
- int idx = normalized.indexOf( currentPlugin );
- Plugin firstPlugin = (Plugin) normalized.get( idx );
-
- // MNG-3719: merge currentPlugin with firstPlugin as parent,
- // then use updated currentPlugin as new parent
- mergePluginDefinitions( currentPlugin, firstPlugin, false );
- normalized.set(idx, currentPlugin);
- }
- else
- {
- normalized.add( currentPlugin );
- }
- }
-
- pluginContainer.setPlugins( normalized );
- }
+ };
public static ReportSet cloneReportSet( ReportSet src )
{
@@ -427,7 +373,7 @@
RepositoryPolicy result = new RepositoryPolicy();
result.setChecksumPolicy( src.getChecksumPolicy() );
- result.setEnabled( src.isEnabled() );
+ result.setEnabled( src.getEnabled() );
result.setUpdatePolicy( src.getUpdatePolicy() );
return result;
@@ -452,495 +398,6 @@
return result;
}
- /**
- * This should be the resulting ordering of plugins after merging:
- *
- * Given:
- *
- * parent: X -> A -> B -> D -> E
- * child: Y -> A -> C -> D -> F
- *
- * Result:
- *
- * X -> Y -> A -> B -> C -> D -> E -> F
- */
- public static void mergePluginLists( PluginContainer child, PluginContainer parent,
- boolean handleAsInheritance )
- {
- if ( ( child == null ) || ( parent == null ) )
- {
- // nothing to do.
- return;
- }
-
- List parentPlugins = parent.getPlugins();
-
- if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() )
- {
- parentPlugins = new ArrayList( parentPlugins );
-
- // If we're processing this merge as an inheritance, we have to build up a list of
- // plugins that were considered for inheritance.
- if ( handleAsInheritance )
- {
- for ( Iterator it = parentPlugins.iterator(); it.hasNext(); )
- {
- Plugin plugin = (Plugin) it.next();
-
- String inherited = plugin.getInherited();
-
- if ( ( inherited != null ) && !Boolean.valueOf( inherited ).booleanValue() )
- {
- it.remove();
- }
- }
- }
-
- List assembledPlugins = new ArrayList();
-
- Map childPlugins = child.getPluginsAsMap();
-
- for ( Iterator it = parentPlugins.iterator(); it.hasNext(); )
- {
- Plugin parentPlugin = (Plugin) it.next();
-
- String parentInherited = parentPlugin.getInherited();
-
- // only merge plugin definition from the parent if at least one
- // of these is true:
- // 1. we're not processing the plugins in an inheritance-based merge
- // 2. the parent's <inherited/> flag is not set
- // 3. the parent's <inherited/> flag is set to true
- if ( !handleAsInheritance || ( parentInherited == null ) ||
- Boolean.valueOf( parentInherited ).booleanValue() )
- {
- Plugin childPlugin = (Plugin) childPlugins.get( parentPlugin.getKey() );
-
- if ( ( childPlugin != null ) && !assembledPlugins.contains( childPlugin ) )
- {
- Plugin assembledPlugin = childPlugin;
-
- mergePluginDefinitions( childPlugin, parentPlugin, handleAsInheritance );
-
- // fix for MNG-2221 (assembly cache was not being populated for later reference):
- assembledPlugins.add( assembledPlugin );
- }
-
- // if we're processing this as an inheritance-based merge, and
- // the parent's <inherited/> flag is not set, then we need to
- // clear the inherited flag in the merge result.
- if ( handleAsInheritance && ( parentInherited == null ) )
- {
- parentPlugin.unsetInheritanceApplied();
- }
- }
-
- // very important to use the parentPlugins List, rather than parentContainer.getPlugins()
- // since this list is a local one, and may have been modified during processing.
- List results = ModelUtils.orderAfterMerge( assembledPlugins, parentPlugins,
- child.getPlugins() );
-
-
- child.setPlugins( results );
-
- child.flushPluginMap();
- }
- }
- }
-
- public static List orderAfterMerge( List merged, List highPrioritySource, List lowPrioritySource )
- {
- List results = new ArrayList();
-
- if ( !merged.isEmpty() )
- {
- results.addAll( merged );
- }
-
- List missingFromResults = new ArrayList();
-
- List sources = new ArrayList();
-
- sources.add( highPrioritySource );
- sources.add( lowPrioritySource );
-
- for ( Iterator sourceIterator = sources.iterator(); sourceIterator.hasNext(); )
- {
- List source = (List) sourceIterator.next();
-
- for ( Iterator it = source.iterator(); it.hasNext(); )
- {
- Object item = it.next();
-
- if ( results.contains( item ) )
- {
- if ( !missingFromResults.isEmpty() )
- {
- int idx = results.indexOf( item );
-
- if ( idx < 0 )
- {
- idx = 0;
- }
-
- results.addAll( idx, missingFromResults );
-
- missingFromResults.clear();
- }
- }
- else
- {
- missingFromResults.add( item );
- }
- }
-
- if ( !missingFromResults.isEmpty() )
- {
- results.addAll( missingFromResults );
-
- missingFromResults.clear();
- }
- }
-
- return results;
- }
-
- /**
- * Merge the list of reporting plugins from parent pom and child pom
- * TODO it's pretty much a copy of {@link #mergePluginLists(PluginContainer, PluginContainer, boolean)}
- *
- * @param child
- * @param parent
- * @param handleAsInheritance
- */
- public static void mergeReportPluginLists( Reporting child, Reporting parent, boolean handleAsInheritance )
- {
- if ( ( child == null ) || ( parent == null ) )
- {
- // nothing to do.
- return;
- }
-
- List parentPlugins = parent.getPlugins();
-
- if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() )
- {
- parentPlugins = new ArrayList( parentPlugins );
-
- // If we're processing this merge as an inheritance, we have to build up a list of
- // plugins that were considered for inheritance.
- if ( handleAsInheritance )
- {
- for ( Iterator it = parentPlugins.iterator(); it.hasNext(); )
- {
- ReportPlugin plugin = (ReportPlugin) it.next();
-
- String inherited = plugin.getInherited();
-
- if ( ( inherited != null ) && !Boolean.valueOf( inherited ).booleanValue() )
- {
- it.remove();
- }
- }
- }
-
- List assembledPlugins = new ArrayList();
-
- Map childPlugins = child.getReportPluginsAsMap();
-
- for ( Iterator it = parentPlugins.iterator(); it.hasNext(); )
- {
- ReportPlugin parentPlugin = (ReportPlugin) it.next();
-
- String parentInherited = parentPlugin.getInherited();
-
- // only merge plugin definition from the parent if at least one
- // of these is true:
- // 1. we're not processing the plugins in an inheritance-based merge
- // 2. the parent's <inherited/> flag is not set
- // 3. the parent's <inherited/> flag is set to true
- if ( !handleAsInheritance || ( parentInherited == null ) ||
- Boolean.valueOf( parentInherited ).booleanValue() )
- {
- ReportPlugin childPlugin = (ReportPlugin) childPlugins.get( parentPlugin.getKey() );
-
- if ( ( childPlugin != null ) && !assembledPlugins.contains( childPlugin ) )
- {
- ReportPlugin assembledPlugin = childPlugin;
-
- mergeReportPluginDefinitions( childPlugin, parentPlugin, handleAsInheritance );
-
- // fix for MNG-2221 (assembly cache was not being populated for later reference):
- assembledPlugins.add( assembledPlugin );
- }
-
- // if we're processing this as an inheritance-based merge, and
- // the parent's <inherited/> flag is not set, then we need to
- // clear the inherited flag in the merge result.
- if ( handleAsInheritance && ( parentInherited == null ) )
- {
- parentPlugin.unsetInheritanceApplied();
- }
- }
-
- // very important to use the parentPlugins List, rather than parentContainer.getPlugins()
- // since this list is a local one, and may have been modified during processing.
- List results = ModelUtils.orderAfterMerge( assembledPlugins, parentPlugins,
- child.getPlugins() );
-
- child.setPlugins( results );
-
- child.flushReportPluginMap();
- }
- }
- }
-
- public static void mergePluginDefinitions( Plugin child, Plugin parent, boolean handleAsInheritance )
- {
- if ( ( child == null ) || ( parent == null ) )
- {
- // nothing to do.
- return;
- }
-
- if ( parent.isExtensions() )
- {
- child.setExtensions( true );
- }
-
- if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) )
- {
- child.setVersion( parent.getVersion() );
- }
-
- Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration();
- Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration();
-
- childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration );
-
- child.setConfiguration( childConfiguration );
-
- child.setDependencies( mergeDependencyList( child.getDependencies(), parent.getDependencies() ) );
-
- // from here to the end of the method is dealing with merging of the <executions/> section.
- String parentInherited = parent.getInherited();
-
- boolean parentIsInherited = ( parentInherited == null ) || Boolean.valueOf( parentInherited ).booleanValue();
-
- List parentExecutions = parent.getExecutions();
-
- if ( ( parentExecutions != null ) && !parentExecutions.isEmpty() )
- {
- List mergedExecutions = new ArrayList();
-
- Map assembledExecutions = new TreeMap();
-
- Map childExecutions = child.getExecutionsAsMap();
-
- for ( Iterator it = parentExecutions.iterator(); it.hasNext(); )
- {
- PluginExecution parentExecution = (PluginExecution) it.next();
-
- String inherited = parentExecution.getInherited();
-
- boolean parentExecInherited = parentIsInherited && ( ( inherited == null ) || Boolean.valueOf( inherited ).booleanValue() );
-
- if ( !handleAsInheritance || parentExecInherited )
- {
- PluginExecution assembled = parentExecution;
-
- PluginExecution childExecution = (PluginExecution) childExecutions.get( parentExecution.getId() );
-
- if ( childExecution != null )
- {
- mergePluginExecutionDefinitions( childExecution, parentExecution );
-
- assembled = childExecution;
- }
- else if ( handleAsInheritance && ( parentInherited == null ) )
- {
- parentExecution.unsetInheritanceApplied();
- }
-
- assembledExecutions.put( assembled.getId(), assembled );
- mergedExecutions.add(assembled);
- }
- }
-
- for ( Iterator it = child.getExecutions().iterator(); it.hasNext(); )
- {
- PluginExecution childExecution = (PluginExecution)it.next();
-
- if ( !assembledExecutions.containsKey( childExecution.getId() ) )
- {
- mergedExecutions.add(childExecution);
- }
- }
-
- child.setExecutions(mergedExecutions);
-
- child.flushExecutionMap();
- }
-
- }
-
- public static void mergeReportPluginDefinitions( ReportPlugin child, ReportPlugin parent,
- boolean handleAsInheritance )
- {
- if ( ( child == null ) || ( parent == null ) )
- {
- // nothing to do.
- return;
- }
-
- if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) )
- {
- child.setVersion( parent.getVersion() );
- }
-
- String parentInherited = parent.getInherited();
-
- boolean parentIsInherited = ( parentInherited == null ) || Boolean.valueOf( parentInherited ).booleanValue();
-
- // merge configuration just like with build plugins
- if ( parentIsInherited )
- {
- Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration();
- Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration();
-
- childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration );
-
- child.setConfiguration( childConfiguration );
- }
-
- // from here to the end of the method is dealing with merging of the <executions/> section.
- List parentReportSets = parent.getReportSets();
-
- if ( ( parentReportSets != null ) && !parentReportSets.isEmpty() )
- {
- Map assembledReportSets = new TreeMap();
-
- Map childReportSets = child.getReportSetsAsMap();
-
- for ( Iterator it = parentReportSets.iterator(); it.hasNext(); )
- {
- ReportSet parentReportSet = (ReportSet) it.next();
-
- if ( !handleAsInheritance || parentIsInherited )
- {
- ReportSet assembledReportSet = parentReportSet;
-
- ReportSet childReportSet = (ReportSet) childReportSets.get( parentReportSet.getId() );
-
- if ( childReportSet != null )
- {
- mergeReportSetDefinitions( childReportSet, parentReportSet );
-
- assembledReportSet = childReportSet;
- }
- else if ( handleAsInheritance && ( parentInherited == null ) )
- {
- parentReportSet.unsetInheritanceApplied();
- }
-
- assembledReportSets.put( assembledReportSet.getId(), assembledReportSet );
- }
- }
-
- for ( Iterator it = childReportSets.entrySet().iterator(); it.hasNext(); )
- {
- Map.Entry entry = (Map.Entry) it.next();
-
- String id = (String) entry.getKey();
-
- if ( !assembledReportSets.containsKey( id ) )
- {
- assembledReportSets.put( id, entry.getValue() );
- }
- }
-
- child.setReportSets( new ArrayList( assembledReportSets.values() ) );
-
- child.flushReportSetMap();
- }
-
- }
-
- private static void mergePluginExecutionDefinitions( PluginExecution child, PluginExecution parent )
- {
- if ( child.getPhase() == null )
- {
- child.setPhase( parent.getPhase() );
- }
-
- List parentGoals = parent.getGoals();
- List childGoals = child.getGoals();
-
- List goals = new ArrayList();
-
- if ( ( childGoals != null ) && !childGoals.isEmpty() )
- {
- goals.addAll( childGoals );
- }
-
- if ( parentGoals != null )
- {
- for ( Iterator goalIterator = parentGoals.iterator(); goalIterator.hasNext(); )
- {
- String goal = (String) goalIterator.next();
-
- if ( !goals.contains( goal ) )
- {
- goals.add( goal );
- }
- }
- }
-
- child.setGoals( goals );
-
- Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration();
- Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration();
-
- childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration );
-
- child.setConfiguration( childConfiguration );
- }
-
- private static void mergeReportSetDefinitions( ReportSet child, ReportSet parent )
- {
- List parentReports = parent.getReports();
- List childReports = child.getReports();
-
- List reports = new ArrayList();
-
- if ( ( childReports != null ) && !childReports.isEmpty() )
- {
- reports.addAll( childReports );
- }
-
- if ( parentReports != null )
- {
- for ( Iterator i = parentReports.iterator(); i.hasNext(); )
- {
- String report = (String) i.next();
-
- if ( !reports.contains( report ) )
- {
- reports.add( report );
- }
- }
- }
-
- child.setReports( reports );
-
- Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration();
- Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration();
-
- childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration );
-
- child.setConfiguration( childConfiguration );
- }
-
public static Model cloneModel( Model src )
{
if ( src == null )
@@ -980,6 +437,8 @@
result.setUrl( src.getUrl() );
result.setVersion( src.getVersion() );
+ result.setPomFile( src.getPomFile() );
+
return result;
}
@@ -1150,15 +609,15 @@
return result;
}
- private static List cloneList( List src, ModelPartCloner cloner )
+ private static <T> List<T> cloneList( List<T> src, ModelPartCloner<T> cloner )
{
- List result = null;
+ List<T> result = null;
if ( src != null )
{
- result = new ArrayList( src.size() );
- for ( Iterator it = src.iterator(); it.hasNext(); )
+ result = new ArrayList<T>( src.size() );
+ for ( Iterator<T> it = src.iterator(); it.hasNext(); )
{
- result.add( cloner.cloneModelPart( (Object) it.next() ) );
+ result.add( cloner.cloneModelPart( it.next() ) );
}
}
@@ -1215,17 +674,7 @@
CiManagement result = new CiManagement();
- List notifiers = null;
- if ( src.getNotifiers() != null )
- {
- notifiers = new ArrayList( src.getNotifiers().size() );
- for ( Iterator it = src.getNotifiers().iterator(); it.hasNext(); )
- {
- notifiers.add( cloneNotifier( (Notifier) it.next() ) );
- }
- }
result.setNotifiers( cloneList( src.getNotifiers(), NOTIFIER_CLONER ) );
-
result.setSystem( src.getSystem() );
result.setUrl( src.getUrl() );
@@ -1240,12 +689,13 @@
}
Notifier result = new Notifier();
+ result.setType( src.getType() );
result.setAddress( src.getAddress() );
result.setConfiguration( cloneProperties( src.getConfiguration() ) );
result.setSendOnError( src.isSendOnError() );
- result.setSendOnFailure( result.isSendOnFailure() );
- result.setSendOnSuccess( result.isSendOnSuccess() );
- result.setSendOnWarning( result.isSendOnWarning() );
+ result.setSendOnFailure( src.isSendOnFailure() );
+ result.setSendOnSuccess( src.isSendOnSuccess() );
+ result.setSendOnWarning( src.isSendOnWarning() );
return result;
}
@@ -1258,11 +708,7 @@
}
Properties result = new Properties();
- for( Enumeration e = src.propertyNames(); e.hasMoreElements(); )
- {
- String key = (String) e.nextElement();
- result.setProperty( key, src.getProperty( key ) );
- }
+ result.putAll( src );
return result;
}
@@ -1326,7 +772,7 @@
result.setDirectory( src.getDirectory() );
result.setExcludes( cloneListOfStrings( src.getExcludes() ) );
- result.setFiltering( src.isFiltering() );
+ result.setFiltering( src.getFiltering() );
result.setIncludes( cloneListOfStrings( src.getIncludes() ) );
result.setMergeId( src.getMergeId() );
result.setTargetPath( src.getTargetPath() );
@@ -1375,7 +821,6 @@
return result;
}
- // FIXME: We need something better than this for configurations!
public static Object cloneConfiguration( Object configuration )
{
if ( configuration == null )
@@ -1420,19 +865,18 @@
return result;
}
- public static List cloneListOfStrings( List src )
+ public static List<String> cloneListOfStrings( List<String> src )
{
- List result = null;
+ List<String> result = null;
if ( src != null )
{
- result = new ArrayList( src.size() );
- for ( Iterator it = src.iterator(); it.hasNext(); )
+ result = new ArrayList<String>( src.size() );
+ for ( String item : src )
{
- String item = (String) it.next();
result.add( item );
}
}
-
+
return result;
}
@@ -1476,119 +920,10 @@
return result;
}
-
- public static List mergeRepositoryLists( List dominant, List recessive )
- {
- List repositories = new ArrayList();
-
- for ( Iterator it = dominant.iterator(); it.hasNext(); )
- {
- Repository repository = (Repository) it.next();
-
- repositories.add( repository );
- }
-
- for ( Iterator it = recessive.iterator(); it.hasNext(); )
- {
- Repository repository = (Repository) it.next();
-
- if ( !repositories.contains( repository ) )
- {
- repositories.add( repository );
- }
- }
-
- return repositories;
- }
-
- public static void mergeExtensionLists( Build childBuild, Build parentBuild )
- {
- Map extMap = new LinkedHashMap();
-
- List ext = childBuild.getExtensions();
-
- if ( ext != null )
- {
- for ( Iterator it = ext.iterator(); it.hasNext(); )
- {
- Extension extension = (Extension) it.next();
- extMap.put( extension.getKey(), extension );
- }
- }
-
- ext = parentBuild.getExtensions();
-
- if ( ext != null )
- {
- for ( Iterator it = ext.iterator(); it.hasNext(); )
- {
- Extension extension = (Extension) it.next();
- if ( !extMap.containsKey( extension.getKey() ) )
- {
- extMap.put( extension.getKey(), extension );
- }
- }
- }
-
- childBuild.setExtensions( new ArrayList( extMap.values() ) );
- }
-
- public static void mergeResourceLists( List childResources, List parentResources )
- {
- for ( Iterator i = parentResources.iterator(); i.hasNext(); )
- {
- Resource r = (Resource) i.next();
- if ( !childResources.contains( r ) )
- {
- childResources.add( r );
- }
- }
- }
-
- public static void mergeFilterLists( List childFilters, List parentFilters )
- {
- for ( Iterator i = parentFilters.iterator(); i.hasNext(); )
- {
- String f = (String) i.next();
- if ( !childFilters.contains( f ) )
- {
- childFilters.add( f );
- }
- }
- }
-
- public static List mergeDependencyList( List child, List parent )
- {
- Map depsMap = new LinkedHashMap();
-
- if ( child != null )
- {
- for ( Iterator it = child.iterator(); it.hasNext(); )
- {
- Dependency dependency = (Dependency) it.next();
- depsMap.put( dependency.getManagementKey(), dependency );
- }
- }
-
- if ( parent != null )
- {
- for ( Iterator it = parent.iterator(); it.hasNext(); )
- {
- Dependency dependency = (Dependency) it.next();
- if ( !depsMap.containsKey( dependency.getManagementKey() ) )
- {
- depsMap.put( dependency.getManagementKey(), dependency );
- }
- }
- }
-
- return new ArrayList( depsMap.values() );
- }
- public static interface ModelPartCloner
+ public static interface ModelPartCloner<T>
{
- Object cloneModelPart( Object src );
+ T cloneModelPart( T src );
}
-
}
Added: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UnparseableModelException.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UnparseableModelException.java?rev=780627&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UnparseableModelException.java (added)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UnparseableModelException.java Mon Jun 1 12:17:53 2009
@@ -0,0 +1,76 @@
+package org.apache.maven.model;
+
+/*
+ * 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.
+ */
+
+/**
+ * Signals a failure to read/parse a POM file.
+ *
+ * @author Benjamin Bentmann
+ */
+public class UnparseableModelException
+ extends ModelBuildingException
+{
+
+ /**
+ * The one-based index of the line containing the error.
+ */
+ private int lineNumber;
+
+ /**
+ * The one-based index of the column containing the error.
+ */
+ private int columnNumber;
+
+ /**
+ * Creates a new parser exception with the specified details.
+ *
+ * @param message The error message, may be {@code null}.
+ * @param lineNumber The one-based index of the line containing the error or {@code -1} if unknown.
+ * @param columnNumber The one-based index of the column containing the error or {@code -1} if unknown.
+ * @param cause The nested cause of this error, may be {@code null}.
+ */
+ public UnparseableModelException( String message, int lineNumber, int columnNumber, Throwable cause )
+ {
+ super( message, cause );
+ this.lineNumber = lineNumber;
+ this.columnNumber = columnNumber;
+ }
+
+ /**
+ * Gets the one-based index of the line containing the error.
+ *
+ * @return The one-based index of the line containing the error or a non-positive value if unknown.
+ */
+ public int getLineNumber()
+ {
+ return lineNumber;
+ }
+
+ /**
+ * Gets the one-based index of the column containing the error.
+ *
+ * @return The one-based index of the column containing the error or non-positive value if unknown.
+ */
+ public int getColumnNumber()
+ {
+ return columnNumber;
+ }
+
+}
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UnparseableModelException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UnparseableModelException.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UnresolvableParentException.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UnresolvableParentException.java?rev=780627&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UnresolvableParentException.java (added)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UnresolvableParentException.java Mon Jun 1 12:17:53 2009
@@ -0,0 +1,41 @@
+package org.apache.maven.model;
+
+/*
+ * 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.
+ */
+
+/**
+ * Signals an error when resolving a child's parent model.
+ *
+ * @author Benjamin Bentmann
+ */
+public class UnresolvableParentException
+ extends ModelBuildingException
+{
+
+ public UnresolvableParentException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+ public UnresolvableParentException( String message )
+ {
+ super( message );
+ }
+
+}
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UnresolvableParentException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UnresolvableParentException.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UrlModelSource.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UrlModelSource.java?rev=780627&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UrlModelSource.java (added)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UrlModelSource.java Mon Jun 1 12:17:53 2009
@@ -0,0 +1,78 @@
+package org.apache.maven.model;
+
+/*
+ * 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.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+/**
+ * Wraps an ordinary {@link URL} as a model source.
+ *
+ * @author Benjamin Bentmann
+ */
+public class UrlModelSource
+ implements ModelSource
+{
+
+ private URL pomUrl;
+
+ /**
+ * Creates a new model source backed by the specified URL.
+ *
+ * @param pomUrl The POM file, must not be {@code null}.
+ */
+ public UrlModelSource( URL pomUrl )
+ {
+ if ( pomUrl == null )
+ {
+ throw new IllegalArgumentException( "no POM URL specified" );
+ }
+ this.pomUrl = pomUrl;
+ }
+
+ public InputStream getInputStream()
+ throws IOException
+ {
+ return pomUrl.openStream();
+ }
+
+ public String getLocation()
+ {
+ return pomUrl.toString();
+ }
+
+ /**
+ * Gets the POM URL of this model source.
+ *
+ * @return The underlying POM URL, never {@code null}.
+ */
+ public URL getPomUrl()
+ {
+ return pomUrl;
+ }
+
+ @Override
+ public String toString()
+ {
+ return getLocation();
+ }
+
+}
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UrlModelSource.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/UrlModelSource.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java?rev=780627&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java (added)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java Mon Jun 1 12:17:53 2009
@@ -0,0 +1,96 @@
+package org.apache.maven.model.profile;
+
+/*
+ * 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 java.util.Properties;
+
+/**
+ * Describes the environmental context used to determine the activation status of profiles.
+ *
+ * @author Benjamin Bentmann
+ */
+public class DefaultProfileActivationContext
+ implements ProfileActivationContext
+{
+
+ private List<String> activeProfileIds;
+
+ private List<String> inactiveProfileIds;
+
+ private Properties executionProperties;
+
+ public DefaultProfileActivationContext()
+ {
+ activeProfileIds = new ArrayList<String>();
+ inactiveProfileIds = new ArrayList<String>();
+ executionProperties = new Properties();
+ }
+
+ public List<String> getActiveProfileIds()
+ {
+ return activeProfileIds;
+ }
+
+ public DefaultProfileActivationContext setActiveProfileIds( List<String> activeProfileIds )
+ {
+ this.activeProfileIds.clear();
+ if ( activeProfileIds != null )
+ {
+ this.activeProfileIds.addAll( activeProfileIds );
+ }
+
+ return this;
+ }
+
+ public List<String> getInactiveProfileIds()
+ {
+ return inactiveProfileIds;
+ }
+
+ public DefaultProfileActivationContext setInactiveProfileIds( List<String> inactiveProfileIds )
+ {
+ this.inactiveProfileIds.clear();
+ if ( inactiveProfileIds != null )
+ {
+ this.inactiveProfileIds.addAll( inactiveProfileIds );
+ }
+
+ return this;
+ }
+
+ public Properties getExecutionProperties()
+ {
+ return executionProperties;
+ }
+
+ public DefaultProfileActivationContext setExecutionProperties( Properties executionProperties )
+ {
+ this.executionProperties.clear();
+ if ( executionProperties != null )
+ {
+ this.executionProperties.putAll( executionProperties );
+ }
+
+ return this;
+ }
+
+}
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java?rev=780627&r1=780626&r2=780627&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java (original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java Mon Jun 1 12:17:53 2009
@@ -38,6 +38,14 @@
List<String> getActiveProfileIds();
/**
+ * Sets the identifiers of those profiles that should be activated by explicit demand.
+ *
+ * @param activeProfileIds The identifiers of those profiles to activate, may be {@code null}.
+ * @return This context, never {@code null}.
+ */
+ ProfileActivationContext setActiveProfileIds( List<String> activeProfileIds );
+
+ /**
* Gets the identifiers of those profiles that should be deactivated by explicit demand.
*
* @return The identifiers of those profiles to deactivate, never {@code null}.
@@ -45,10 +53,26 @@
List<String> getInactiveProfileIds();
/**
+ * Sets the identifiers of those profiles that should be deactivated by explicit demand.
+ *
+ * @param inactiveProfileIds The identifiers of those profiles to deactivate, may be {@code null}.
+ * @return This context, never {@code null}.
+ */
+ ProfileActivationContext setInactiveProfileIds( List<String> inactiveProfileIds );
+
+ /**
* Gets the execution properties.
*
* @return The execution properties, never {@code null}.
*/
Properties getExecutionProperties();
+ /**
+ * Sets the execution properties.
+ *
+ * @param executionProperties The execution properties, may be {@code null}.
+ * @return This context, never {@code null}.
+ */
+ ProfileActivationContext setExecutionProperties( Properties executionProperties );
+
}
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/
------------------------------------------------------------------------------
bugtraq:label = Enter issue ID:
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/
------------------------------------------------------------------------------
bugtraq:message = Issue id: %BUGID%
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/
------------------------------------------------------------------------------
bugtraq:number = false
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/
------------------------------------------------------------------------------
bugtraq:url = http://jira.codehaus.org/browse/%BUGID%
Added: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/InvalidRepositoryException.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/InvalidRepositoryException.java?rev=780627&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/InvalidRepositoryException.java (added)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/InvalidRepositoryException.java Mon Jun 1 12:17:53 2009
@@ -0,0 +1,70 @@
+package org.apache.maven.model.resolver;
+
+/*
+ * 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 org.apache.maven.model.Repository;
+
+/**
+ * Signals an error when adding a repository to the model resolver.
+ *
+ * @author Benjamin Bentmann
+ */
+public class InvalidRepositoryException
+ extends Exception
+{
+
+ private Repository repository;
+
+ /**
+ * Creates a new exception with specified detail message and cause for the given repository.
+ *
+ * @param message The detail message, may be {@code null}.
+ * @param repository The repository that caused the error, may be {@code null}.
+ * @param cause The cause, may be {@code null}.
+ */
+ public InvalidRepositoryException( String message, Repository repository, Throwable cause )
+ {
+ super( message, cause );
+ this.repository = repository;
+ }
+
+ /**
+ * Creates a new exception with specified detail message for the given repository.
+ *
+ * @param message The detail message, may be {@code null}.
+ * @param repository The repository that caused the error, may be {@code null}.
+ */
+ public InvalidRepositoryException( String message, Repository repository )
+ {
+ super( message );
+ this.repository = repository;
+ }
+
+ /**
+ * Gets the repository that causes this error (if any).
+ *
+ * @return The repository that causes this error or {@code null} if not known.
+ */
+ public Repository getRepository()
+ {
+ return repository;
+ }
+
+}
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/InvalidRepositoryException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/InvalidRepositoryException.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/ModelResolver.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/ModelResolver.java?rev=780627&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/ModelResolver.java (added)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/ModelResolver.java Mon Jun 1 12:17:53 2009
@@ -0,0 +1,42 @@
+package org.apache.maven.model.resolver;
+
+/*
+ * 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 org.apache.maven.model.ModelBuilder;
+import org.apache.maven.model.ModelSource;
+import org.apache.maven.model.Repository;
+
+/**
+ * Resolves a POM from its coordinates. During the build process, the {@link ModelBuilder} will add any relevant
+ * repositories to the model resolver. In other words, the model resolver is stateful and should not be reused across
+ * multiple model building requests.
+ *
+ * @author Benjamin Bentmann
+ */
+public interface ModelResolver
+{
+
+ ModelSource resolveModel( String groupId, String artifactId, String version )
+ throws UnresolvableModelException;
+
+ void addRepository( Repository repository )
+ throws InvalidRepositoryException;
+
+}
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/ModelResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/ModelResolver.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/UnresolvableModelException.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/UnresolvableModelException.java?rev=780627&view=auto
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/UnresolvableModelException.java (added)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/UnresolvableModelException.java Mon Jun 1 12:17:53 2009
@@ -0,0 +1,52 @@
+package org.apache.maven.model.resolver;
+
+/*
+ * 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.
+ */
+
+/**
+ * Signals an error when resolving the path to an external model.
+ *
+ * @author Benjamin Bentmann
+ */
+public class UnresolvableModelException
+ extends Exception
+{
+
+ /**
+ * Creates a new exception with specified detail message and cause.
+ *
+ * @param message The detail message, may be {@code null}.
+ * @param cause The cause, may be {@code null}.
+ */
+ public UnresolvableModelException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+ /**
+ * Creates a new exception with specified detail message.
+ *
+ * @param message The detail message, may be {@code null}.
+ */
+ public UnresolvableModelException( String message )
+ {
+ super( message );
+ }
+
+}
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/UnresolvableModelException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/resolver/UnresolvableModelException.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activator/AbstractProfileActivatorTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activator/AbstractProfileActivatorTest.java?rev=780627&r1=780626&r2=780627&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activator/AbstractProfileActivatorTest.java (original)
+++ maven/components/trunk/maven-model-builder/src/test/java/org/apache/maven/model/profile/activator/AbstractProfileActivatorTest.java Mon Jun 1 12:17:53 2009
@@ -19,10 +19,9 @@
* under the License.
*/
-import java.util.Collections;
-import java.util.List;
import java.util.Properties;
+import org.apache.maven.model.profile.DefaultProfileActivationContext;
import org.apache.maven.model.profile.ProfileActivationContext;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.component.annotations.Component;
@@ -74,25 +73,7 @@
protected ProfileActivationContext newContext( final Properties executionProperties )
{
- return new ProfileActivationContext()
- {
-
- public List<String> getActiveProfileIds()
- {
- return Collections.emptyList();
- }
-
- public List<String> getInactiveProfileIds()
- {
- return Collections.emptyList();
- }
-
- public Properties getExecutionProperties()
- {
- return executionProperties;
- }
-
- };
+ return new DefaultProfileActivationContext().setExecutionProperties( executionProperties );
}
}
Modified: maven/components/trunk/maven-model/src/main/mdo/maven.mdo
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model/src/main/mdo/maven.mdo?rev=780627&r1=780626&r2=780627&view=diff
==============================================================================
--- maven/components/trunk/maven-model/src/main/mdo/maven.mdo (original)
+++ maven/components/trunk/maven-model/src/main/mdo/maven.mdo Mon Jun 1 12:17:53 2009
@@ -572,10 +572,10 @@
private java.io.File pomFile;
/**
- * Gets the POM file from which this model originated. This can either be a {@code pom.xml} of some project being
- * built or the {@code *.pom} of some artifact being resolved from the repository.
+ * Gets the POM file for the corresponding project (if any).
*
- * @return The POM file from which this model originated or {@code null} if unknown.
+ * @return The POM file from which this model originated or {@code null} if this model does not belong to a local
+ * project (e.g. describes the metadata of some artifact from the repository).
*/
public java.io.File getPomFile()
{
@@ -588,26 +588,14 @@
}
/**
- * The base directory for the corresponding project (if any). This is transient runtime state and therefore not
- * managed by Modello.
- */
- private java.io.File projectDirectory;
-
- /**
- * Gets the base directory for the corresponding project (if any). Note that this is really a separate piece of
- * information and not necessarily equivalent to the parent directory of {@link #getPomFile()}.
+ * Gets the base directory for the corresponding project (if any).
*
* @return The base directory for the corresponding project or {@code null} if this model does not belong to a local
- * project but describes the metadata of some artifact from the repository.
+ * project (e.g. describes the metadata of some artifact from the repository).
*/
public java.io.File getProjectDirectory()
{
- return projectDirectory;
- }
-
- public void setProjectDirectory( java.io.File projectDirectory )
- {
- this.projectDirectory = projectDirectory;
+ return ( pomFile != null ) ? pomFile.getParentFile() : null;
}
/**