o move the path translator to the maven-compat package

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@726744 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2008-12-15 17:48:53 +00:00
parent ed32ed5ff0
commit 15da8b59b0
5 changed files with 48 additions and 7 deletions

View File

@ -19,11 +19,28 @@ package org.apache.maven.project.builder;
* under the License.
*/
import org.apache.maven.shared.model.*;
import org.apache.maven.shared.model.impl.DefaultModelDataSource;
import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.maven.shared.model.DomainModel;
import org.apache.maven.shared.model.DomainModelFactory;
import org.apache.maven.shared.model.InterpolatorProperty;
import org.apache.maven.shared.model.ModelContainer;
import org.apache.maven.shared.model.ModelContainerAction;
import org.apache.maven.shared.model.ModelDataSource;
import org.apache.maven.shared.model.ModelEventListener;
import org.apache.maven.shared.model.ModelProperty;
import org.apache.maven.shared.model.ModelTransformer;
import org.apache.maven.shared.model.ModelTransformerContext;
import org.apache.maven.shared.model.impl.DefaultModelDataSource;
/**
* Provides methods for transforming model properties into a domain model for the pom classic format and vice versa.
@ -38,13 +55,13 @@ public class PomTransformer
{
this.factory = factory;
}
/**
* The URIs this transformer supports
*/
public static final Set<String> URIS = Collections.unmodifiableSet(new HashSet<String>( Arrays.asList( ProjectUri.Build.Extensions.xUri,
ProjectUri.Build.PluginManagement.Plugins.xUri,
ProjectUri.Build.PluginManagement.Plugins.Plugin.configuration,
//ProjectUri.Build.PluginManagement.Plugins.Plugin.Executions.xUri,
ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.xUri,
ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.Exclusions.xUri,
@ -263,14 +280,20 @@ public class PomTransformer
//Rule: Do not join plugin executions without ids
Set<ModelProperty> removeProperties = new HashSet<ModelProperty>();
ModelDataSource dataSource = new DefaultModelDataSource();
dataSource.init( props, Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) );
List<ModelContainer> containers = dataSource.queryFor( ProjectUri.Build.Plugins.Plugin.xUri );
for ( ModelContainer pluginContainer : containers )
{
ModelDataSource executionSource = new DefaultModelDataSource();
executionSource.init( pluginContainer.getProperties(),
Arrays.asList( new ArtifactModelContainerFactory(), new PluginExecutionIdModelContainerFactory() ) );
List<ModelContainer> executionContainers = executionSource.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri );
if ( executionContainers.size() < 2 )
@ -279,19 +302,21 @@ public class PomTransformer
}
boolean hasAtLeastOneWithoutId = true;
for ( ModelContainer executionContainer : executionContainers )
{
if ( hasAtLeastOneWithoutId )
{
hasAtLeastOneWithoutId = hasExecutionId( executionContainer );
}
if ( !hasAtLeastOneWithoutId && !hasExecutionId( executionContainer ) &&
executionContainers.indexOf( executionContainer ) > 0 )
if ( !hasAtLeastOneWithoutId && !hasExecutionId( executionContainer ) && executionContainers.indexOf( executionContainer ) > 0 )
{
removeProperties.addAll( executionContainer.getProperties() );
}
}
}
props.removeAll( removeProperties );
for(ModelEventListener listener : eventListeners)

16
pom.xml
View File

@ -43,6 +43,7 @@ under the License.
<url>http://maven.apache.org/</url>
<inceptionYear>2001</inceptionYear>
<properties>
<aspectjVersion>1.5.3</aspectjVersion>
<classWorldsVersion>1.3</classWorldsVersion>
<commonsCliVersion>1.0</commonsCliVersion>
<doxiaVersion>1.0-alpha-9</doxiaVersion>
@ -172,6 +173,15 @@ under the License.
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.0-beta-2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<configuration>
@ -431,6 +441,12 @@ under the License.
<artifactId>mercury-external</artifactId>
<version>${mercuryVersion}</version>
</dependency>
<!-- Needed for backward compat aspect. -->
<dependency>
<groupId>aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectjVersion}</version>
</dependency>
<dependency>
<groupId>org.sonatype.plexus</groupId>
<artifactId>plexus-plugin-manager</artifactId>