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. * under the License.
*/ */
import org.apache.maven.shared.model.*;
import org.apache.maven.shared.model.impl.DefaultModelDataSource;
import java.io.IOException; 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. * 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; this.factory = factory;
} }
/** /**
* The URIs this transformer supports * The URIs this transformer supports
*/ */
public static final Set<String> URIS = Collections.unmodifiableSet(new HashSet<String>( Arrays.asList( ProjectUri.Build.Extensions.xUri, 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.xUri,
ProjectUri.Build.PluginManagement.Plugins.Plugin.configuration, 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.xUri,
ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.Exclusions.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 //Rule: Do not join plugin executions without ids
Set<ModelProperty> removeProperties = new HashSet<ModelProperty>(); Set<ModelProperty> removeProperties = new HashSet<ModelProperty>();
ModelDataSource dataSource = new DefaultModelDataSource(); ModelDataSource dataSource = new DefaultModelDataSource();
dataSource.init( props, Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) ); dataSource.init( props, Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) );
List<ModelContainer> containers = dataSource.queryFor( ProjectUri.Build.Plugins.Plugin.xUri ); List<ModelContainer> containers = dataSource.queryFor( ProjectUri.Build.Plugins.Plugin.xUri );
for ( ModelContainer pluginContainer : containers ) for ( ModelContainer pluginContainer : containers )
{ {
ModelDataSource executionSource = new DefaultModelDataSource(); ModelDataSource executionSource = new DefaultModelDataSource();
executionSource.init( pluginContainer.getProperties(), executionSource.init( pluginContainer.getProperties(),
Arrays.asList( new ArtifactModelContainerFactory(), new PluginExecutionIdModelContainerFactory() ) ); Arrays.asList( new ArtifactModelContainerFactory(), new PluginExecutionIdModelContainerFactory() ) );
List<ModelContainer> executionContainers = executionSource.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri ); List<ModelContainer> executionContainers = executionSource.queryFor( ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri );
if ( executionContainers.size() < 2 ) if ( executionContainers.size() < 2 )
@ -279,19 +302,21 @@ public class PomTransformer
} }
boolean hasAtLeastOneWithoutId = true; boolean hasAtLeastOneWithoutId = true;
for ( ModelContainer executionContainer : executionContainers ) for ( ModelContainer executionContainer : executionContainers )
{ {
if ( hasAtLeastOneWithoutId ) if ( hasAtLeastOneWithoutId )
{ {
hasAtLeastOneWithoutId = hasExecutionId( executionContainer ); hasAtLeastOneWithoutId = hasExecutionId( executionContainer );
} }
if ( !hasAtLeastOneWithoutId && !hasExecutionId( executionContainer ) &&
executionContainers.indexOf( executionContainer ) > 0 ) if ( !hasAtLeastOneWithoutId && !hasExecutionId( executionContainer ) && executionContainers.indexOf( executionContainer ) > 0 )
{ {
removeProperties.addAll( executionContainer.getProperties() ); removeProperties.addAll( executionContainer.getProperties() );
} }
} }
} }
props.removeAll( removeProperties ); props.removeAll( removeProperties );
for(ModelEventListener listener : eventListeners) for(ModelEventListener listener : eventListeners)

16
pom.xml
View File

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