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 2008/11/22 16:21:43 UTC
svn commit: r719861 [1/4] - in /maven/components/trunk: maven-mercury/
maven-mercury/src/main/java/org/apache/maven/mercury/
maven-mercury/src/main/resources/org/apache/maven/project/
maven-project-builder/ maven-project-builder/src/main/java/org/apach...
Author: bentmann
Date: Sat Nov 22 07:21:42 2008
New Revision: 719861
URL: http://svn.apache.org/viewvc?rev=719861&view=rev
Log:
o Set svn:eol-style=native
Modified:
maven/components/trunk/maven-mercury/pom.xml (props changed)
maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java (contents, props changed)
maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java (contents, props changed)
maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModelFactory.java (props changed)
maven/components/trunk/maven-mercury/src/main/resources/org/apache/maven/project/pom-4.0.0.xml (props changed)
maven/components/trunk/maven-project-builder/pom.xml (props changed)
maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/ArtifactModelContainerFactory.java (contents, props changed)
maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/ExclusionModelContainerFactory.java (props changed)
maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/IdModelContainerFactory.java (contents, props changed)
maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PluginExecutionIdModelContainerFactory.java (props changed)
maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PluginReportSetIdModelContainerFactory.java (props changed)
maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomInterpolatorTag.java (props changed)
maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomTransformer.java (contents, props changed)
maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/ProjectUri.java (contents, props changed)
maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/profile/ActiveProfileMatcher.java (props changed)
maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/profile/ByDefaultMatcher.java (props changed)
maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/profile/FileMatcher.java (props changed)
maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/profile/JdkMatcher.java (props changed)
maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/profile/OperatingSystemMatcher.java (props changed)
maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/profile/ProfileContext.java (props changed)
maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/profile/ProfileUri.java (props changed)
maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/profile/PropertyMatcher.java (props changed)
maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/DefaultModelContainer.java (props changed)
maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/FileMatcherTest.java (props changed)
maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/JdkMatcherTest.java (props changed)
maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/ProfileContextTest.java (props changed)
maven/components/trunk/maven-project-builder/src/test/java/org/apache/maven/project/builder/PropertyMatcherTest.java (props changed)
maven/components/trunk/maven-project-builder/src/test/resources/test.txt (props changed)
Propchange: maven/components/trunk/maven-mercury/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java?rev=719861&r1=719860&r2=719861&view=diff
==============================================================================
--- maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java (original)
+++ maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java Sat Nov 22 07:21:42 2008
@@ -1,110 +1,110 @@
-package org.apache.maven.mercury;
-
-import java.io.IOException;
-import java.util.*;
-
-import org.apache.maven.mercury.artifact.ArtifactBasicMetadata;
-import org.apache.maven.mercury.builder.api.DependencyProcessor;
-import org.apache.maven.mercury.builder.api.DependencyProcessorException;
-import org.apache.maven.mercury.builder.api.MetadataReader;
-import org.apache.maven.mercury.builder.api.MetadataReaderException;
-import org.apache.maven.project.builder.*;
-import org.apache.maven.shared.model.*;
-
-public final class MavenDependencyProcessor implements DependencyProcessor {
-
- public MavenDependencyProcessor() {
-
- }
-
- public List<ArtifactBasicMetadata> getDependencies(ArtifactBasicMetadata bmd, MetadataReader mdReader, Map system, Map user)
- throws MetadataReaderException, DependencyProcessorException
- {
- if (bmd == null) {
- throw new IllegalArgumentException("bmd: null");
- }
-
- if (mdReader == null) {
- throw new IllegalArgumentException("mdReader: null");
- }
-
- List<InterpolatorProperty> interpolatorProperties = new ArrayList<InterpolatorProperty>();
- interpolatorProperties.add(new InterpolatorProperty("${mavenVersion}", "3.0-SNAPSHOT", PomInterpolatorTag.SYSTEM_PROPERTIES.name()));
- interpolatorProperties.add(new InterpolatorProperty("${maven.version}", "3.0-SNAPSHOT", PomInterpolatorTag.SYSTEM_PROPERTIES.name()));
-
- if(system != null) {
- interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( system,
- PomInterpolatorTag.SYSTEM_PROPERTIES.name()));
- }
- if(user != null) {
- interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( user,
- PomInterpolatorTag.USER_PROPERTIES.name()));
- }
-
- List<DomainModel> domainModels = new ArrayList<DomainModel>();
- try {
-// MavenDomainModel superPom =
-// new MavenDomainModel(MavenDependencyProcessor.class.getResourceAsStream( "pom-4.0.0.xml" ));
-// domainModels.add(superPom);
-
- byte [] superBytes = mdReader.readMetadata( bmd );
-
- if( superBytes == null || superBytes.length < 1 )
- throw new DependencyProcessorException("cannot read metadata for " + bmd.getGAV() );
-
- MavenDomainModel domainModel = new MavenDomainModel( superBytes );
- domainModels.add(domainModel);
-
- Collection<ModelContainer> activeProfiles = domainModel.getActiveProfileContainers(interpolatorProperties);
-
- for(ModelContainer mc : activeProfiles) {
- domainModels.add(new MavenDomainModel(transformProfiles(mc.getProperties())));
- }
-
-
- domainModels.addAll(getParentsOfDomainModel(domainModel, mdReader));
- } catch (IOException e) {
- throw new MetadataReaderException("Failed to create domain model. Message = " + e.getMessage());
- }
-
- PomTransformer transformer = new PomTransformer(new MavenDomainModelFactory());
- ModelTransformerContext ctx = new ModelTransformerContext(
- Arrays.asList(new ArtifactModelContainerFactory(), new IdModelContainerFactory()));
-
- try {
- MavenDomainModel model = ((MavenDomainModel) ctx.transform(domainModels,
- transformer,
- transformer,
- null,
- interpolatorProperties,
- null));
- return model.getDependencyMetadata();
- } catch (IOException e) {
- throw new MetadataReaderException("Unable to transform model");
- }
- }
-
- private static List<DomainModel> getParentsOfDomainModel(MavenDomainModel domainModel, MetadataReader mdReader)
- throws IOException, MetadataReaderException {
- List<DomainModel> domainModels = new ArrayList<DomainModel>();
- if (domainModel.hasParent()) {
- MavenDomainModel parentDomainModel = new MavenDomainModel(mdReader.readMetadata(domainModel.getParentMetadata()));
- domainModels.add(parentDomainModel);
- domainModels.addAll(getParentsOfDomainModel(parentDomainModel, mdReader));
- }
- return domainModels;
- }
-
- private static List<ModelProperty> transformProfiles(List<ModelProperty> modelProperties) {
- List<ModelProperty> properties = new ArrayList<ModelProperty>();
- for(ModelProperty mp : modelProperties) {
- if(mp.getUri().startsWith(ProjectUri.Profiles.Profile.xUri)
- && !mp.getUri().equals(ProjectUri.Profiles.Profile.id)
- && !mp.getUri().startsWith(ProjectUri.Profiles.Profile.Activation.xUri)) {
- properties.add(new ModelProperty(mp.getUri().replace( ProjectUri.Profiles.Profile.xUri, ProjectUri.xUri ),
- mp.getResolvedValue() ));
- }
- }
- return properties;
- }
-}
+package org.apache.maven.mercury;
+
+import java.io.IOException;
+import java.util.*;
+
+import org.apache.maven.mercury.artifact.ArtifactBasicMetadata;
+import org.apache.maven.mercury.builder.api.DependencyProcessor;
+import org.apache.maven.mercury.builder.api.DependencyProcessorException;
+import org.apache.maven.mercury.builder.api.MetadataReader;
+import org.apache.maven.mercury.builder.api.MetadataReaderException;
+import org.apache.maven.project.builder.*;
+import org.apache.maven.shared.model.*;
+
+public final class MavenDependencyProcessor implements DependencyProcessor {
+
+ public MavenDependencyProcessor() {
+
+ }
+
+ public List<ArtifactBasicMetadata> getDependencies(ArtifactBasicMetadata bmd, MetadataReader mdReader, Map system, Map user)
+ throws MetadataReaderException, DependencyProcessorException
+ {
+ if (bmd == null) {
+ throw new IllegalArgumentException("bmd: null");
+ }
+
+ if (mdReader == null) {
+ throw new IllegalArgumentException("mdReader: null");
+ }
+
+ List<InterpolatorProperty> interpolatorProperties = new ArrayList<InterpolatorProperty>();
+ interpolatorProperties.add(new InterpolatorProperty("${mavenVersion}", "3.0-SNAPSHOT", PomInterpolatorTag.SYSTEM_PROPERTIES.name()));
+ interpolatorProperties.add(new InterpolatorProperty("${maven.version}", "3.0-SNAPSHOT", PomInterpolatorTag.SYSTEM_PROPERTIES.name()));
+
+ if(system != null) {
+ interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( system,
+ PomInterpolatorTag.SYSTEM_PROPERTIES.name()));
+ }
+ if(user != null) {
+ interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( user,
+ PomInterpolatorTag.USER_PROPERTIES.name()));
+ }
+
+ List<DomainModel> domainModels = new ArrayList<DomainModel>();
+ try {
+// MavenDomainModel superPom =
+// new MavenDomainModel(MavenDependencyProcessor.class.getResourceAsStream( "pom-4.0.0.xml" ));
+// domainModels.add(superPom);
+
+ byte [] superBytes = mdReader.readMetadata( bmd );
+
+ if( superBytes == null || superBytes.length < 1 )
+ throw new DependencyProcessorException("cannot read metadata for " + bmd.getGAV() );
+
+ MavenDomainModel domainModel = new MavenDomainModel( superBytes );
+ domainModels.add(domainModel);
+
+ Collection<ModelContainer> activeProfiles = domainModel.getActiveProfileContainers(interpolatorProperties);
+
+ for(ModelContainer mc : activeProfiles) {
+ domainModels.add(new MavenDomainModel(transformProfiles(mc.getProperties())));
+ }
+
+
+ domainModels.addAll(getParentsOfDomainModel(domainModel, mdReader));
+ } catch (IOException e) {
+ throw new MetadataReaderException("Failed to create domain model. Message = " + e.getMessage());
+ }
+
+ PomTransformer transformer = new PomTransformer(new MavenDomainModelFactory());
+ ModelTransformerContext ctx = new ModelTransformerContext(
+ Arrays.asList(new ArtifactModelContainerFactory(), new IdModelContainerFactory()));
+
+ try {
+ MavenDomainModel model = ((MavenDomainModel) ctx.transform(domainModels,
+ transformer,
+ transformer,
+ null,
+ interpolatorProperties,
+ null));
+ return model.getDependencyMetadata();
+ } catch (IOException e) {
+ throw new MetadataReaderException("Unable to transform model");
+ }
+ }
+
+ private static List<DomainModel> getParentsOfDomainModel(MavenDomainModel domainModel, MetadataReader mdReader)
+ throws IOException, MetadataReaderException {
+ List<DomainModel> domainModels = new ArrayList<DomainModel>();
+ if (domainModel.hasParent()) {
+ MavenDomainModel parentDomainModel = new MavenDomainModel(mdReader.readMetadata(domainModel.getParentMetadata()));
+ domainModels.add(parentDomainModel);
+ domainModels.addAll(getParentsOfDomainModel(parentDomainModel, mdReader));
+ }
+ return domainModels;
+ }
+
+ private static List<ModelProperty> transformProfiles(List<ModelProperty> modelProperties) {
+ List<ModelProperty> properties = new ArrayList<ModelProperty>();
+ for(ModelProperty mp : modelProperties) {
+ if(mp.getUri().startsWith(ProjectUri.Profiles.Profile.xUri)
+ && !mp.getUri().equals(ProjectUri.Profiles.Profile.id)
+ && !mp.getUri().startsWith(ProjectUri.Profiles.Profile.Activation.xUri)) {
+ properties.add(new ModelProperty(mp.getUri().replace( ProjectUri.Profiles.Profile.xUri, ProjectUri.xUri ),
+ mp.getResolvedValue() ));
+ }
+ }
+ return properties;
+ }
+}
Propchange: maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDependencyProcessor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java?rev=719861&r1=719860&r2=719861&view=diff
==============================================================================
--- maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java (original)
+++ maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java Sat Nov 22 07:21:42 2008
@@ -1,220 +1,220 @@
-package org.apache.maven.mercury;
-
-/*
- * 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.shared.model.*;
-import org.apache.maven.shared.model.impl.DefaultModelDataSource;
-import org.apache.maven.project.builder.*;
-import org.apache.maven.project.builder.profile.ProfileContext;
-import org.apache.maven.mercury.artifact.ArtifactBasicMetadata;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ByteArrayInputStream;
-import java.util.List;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-
-/**
- * Provides a wrapper for the maven model.
- */
-public final class MavenDomainModel implements DomainModel {
-
- /**
- * Bytes containing the underlying model
- */
- private final List<ModelProperty> modelProperties;
-
- /**
- * History of joins and deletes of model properties
- */
- private String eventHistory;
-
- private ArtifactBasicMetadata parentMetadata;
-
-
- /**
- * Constructor
- *
- * @throws IOException if there is a problem constructing the model
- */
- public MavenDomainModel( byte[] bytes )
- throws IOException
- {
- this( new ByteArrayInputStream(bytes) );
- }
-
- /**
- * Constructor
- *
- * @throws IOException if there is a problem constructing the model
- */
- public MavenDomainModel(InputStream inputStream)
- throws IOException {
- this(ModelMarshaller.marshallXmlToModelProperties(inputStream, ProjectUri.baseUri, PomTransformer.URIS));
- }
-
- /**
- * Constructor
- *
- * @throws IOException if there is a problem constructing the model
- */
- public MavenDomainModel(List<ModelProperty> modelProperties)
- throws IOException {
- if (modelProperties == null) {
- throw new IllegalArgumentException("modelProperties: null");
- }
-
- this.modelProperties = new ArrayList<ModelProperty>(modelProperties);
- }
-
- public boolean hasParent() {
- //TODO: Expensive call if no parent
- return getParentMetadata() != null;
- }
-
- public List<ArtifactBasicMetadata> getDependencyMetadata() throws DataSourceException {
- List<ArtifactBasicMetadata> metadatas = new ArrayList<ArtifactBasicMetadata>();
-
- ModelDataSource source = new DefaultModelDataSource();
- source.init(modelProperties, Arrays.asList(new ArtifactModelContainerFactory(), new IdModelContainerFactory()));
- for(ModelContainer modelContainer: source.queryFor(ProjectUri.Dependencies.Dependency.xUri)) {
- metadatas.add(transformContainerToMetadata(modelContainer));
- }
-
- return metadatas;
- }
-
- public Collection<ModelContainer> getActiveProfileContainers(List<InterpolatorProperty> properties) throws DataSourceException {
- ModelDataSource dataSource = new DefaultModelDataSource();
- dataSource.init(modelProperties, Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) );
- return new ProfileContext(dataSource, properties).getActiveProfiles();
- }
-
- public ArtifactBasicMetadata getParentMetadata() {
- if (parentMetadata != null) {
- return copyArtifactBasicMetadata(parentMetadata);
- }
- String groupId = null, artifactId = null, version = null;
-
- for (ModelProperty mp : modelProperties) {
- if (mp.getUri().equals(ProjectUri.Parent.version)) {
- version = mp.getValue();
- } else if (mp.getUri().equals(ProjectUri.Parent.artifactId)) {
- artifactId = mp.getValue();
- } else if (mp.getUri().equals(ProjectUri.Parent.groupId)) {
- groupId = mp.getValue();
- }
- if (groupId != null && artifactId != null && version != null) {
- break;
- }
- }
-
- if (groupId == null || artifactId == null || version == null) {
- return null;
- }
- parentMetadata = new ArtifactBasicMetadata();
- parentMetadata.setArtifactId(artifactId);
- parentMetadata.setVersion(version);
- parentMetadata.setGroupId(groupId);
-
- return copyArtifactBasicMetadata(parentMetadata);
- }
-
- private ArtifactBasicMetadata copyArtifactBasicMetadata(ArtifactBasicMetadata metadata) {
- ArtifactBasicMetadata amd = new ArtifactBasicMetadata();
- amd.setArtifactId(metadata.getArtifactId());
- amd.setGroupId(metadata.getGroupId());
- amd.setVersion(metadata.getVersion());
- return amd;
- }
-
- /**
- * @see org.apache.maven.shared.model.DomainModel#getEventHistory()
- */
- public String getEventHistory() {
- return eventHistory;
- }
-
- /**
- * @see org.apache.maven.shared.model.DomainModel#setEventHistory(String)
- */
- public void setEventHistory(String eventHistory) {
- if (eventHistory == null) {
- throw new IllegalArgumentException("eventHistory: null");
- }
- this.eventHistory = eventHistory;
- }
-
- public List<ModelProperty> getModelProperties() {
- return new ArrayList<ModelProperty>(modelProperties);
- }
-
- private ArtifactBasicMetadata transformContainerToMetadata( ModelContainer container ) throws DataSourceException
- {
- List<ModelProperty> modelProperties = container.getProperties();
-
- ArtifactBasicMetadata metadata = new ArtifactBasicMetadata();
- for ( ModelProperty mp : modelProperties )
- {
- if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.groupId)) {
- metadata.setGroupId(mp.getValue());
- } else if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.artifactId)) {
- metadata.setArtifactId(mp.getValue());
- } else if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.version)) {
- metadata.setVersion(mp.getValue());
- } else if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.classifier)) {
- metadata.setClassifier(mp.getValue());
- } else if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.scope)) {
- metadata.setScope(mp.getValue());
- } else if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.type)) {
- metadata.setType(mp.getValue());
- } else if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.optional)) {
- metadata.setOptional(mp.getValue());
- }
- }
-
- if(metadata.getScope() == null) {
- metadata.setScope("runtime");
- }
-
- ModelDataSource dataSource = new DefaultModelDataSource();
- dataSource.init(container.getProperties(), Arrays.asList(new ArtifactModelContainerFactory(), new ExclusionModelContainerFactory()) );
- List<ArtifactBasicMetadata> exclusions = new ArrayList<ArtifactBasicMetadata>();
-
- for(ModelContainer exclusion : dataSource.queryFor(ProjectUri.Dependencies.Dependency.Exclusions.Exclusion.xUri)) {
- ArtifactBasicMetadata meta = new ArtifactBasicMetadata();
- exclusions.add(meta);
-
- for(ModelProperty mp : exclusion.getProperties()) {
- if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.Exclusions.Exclusion.artifactId)) {
- meta.setArtifactId(mp.getValue());
- } else if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.Exclusions.Exclusion.groupId)) {
- meta.setGroupId(mp.getValue());
- }
- }
-
- }
- metadata.setExclusions(exclusions);
-
- return metadata;
- }
-}
+package org.apache.maven.mercury;
+
+/*
+ * 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.shared.model.*;
+import org.apache.maven.shared.model.impl.DefaultModelDataSource;
+import org.apache.maven.project.builder.*;
+import org.apache.maven.project.builder.profile.ProfileContext;
+import org.apache.maven.mercury.artifact.ArtifactBasicMetadata;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+
+/**
+ * Provides a wrapper for the maven model.
+ */
+public final class MavenDomainModel implements DomainModel {
+
+ /**
+ * Bytes containing the underlying model
+ */
+ private final List<ModelProperty> modelProperties;
+
+ /**
+ * History of joins and deletes of model properties
+ */
+ private String eventHistory;
+
+ private ArtifactBasicMetadata parentMetadata;
+
+
+ /**
+ * Constructor
+ *
+ * @throws IOException if there is a problem constructing the model
+ */
+ public MavenDomainModel( byte[] bytes )
+ throws IOException
+ {
+ this( new ByteArrayInputStream(bytes) );
+ }
+
+ /**
+ * Constructor
+ *
+ * @throws IOException if there is a problem constructing the model
+ */
+ public MavenDomainModel(InputStream inputStream)
+ throws IOException {
+ this(ModelMarshaller.marshallXmlToModelProperties(inputStream, ProjectUri.baseUri, PomTransformer.URIS));
+ }
+
+ /**
+ * Constructor
+ *
+ * @throws IOException if there is a problem constructing the model
+ */
+ public MavenDomainModel(List<ModelProperty> modelProperties)
+ throws IOException {
+ if (modelProperties == null) {
+ throw new IllegalArgumentException("modelProperties: null");
+ }
+
+ this.modelProperties = new ArrayList<ModelProperty>(modelProperties);
+ }
+
+ public boolean hasParent() {
+ //TODO: Expensive call if no parent
+ return getParentMetadata() != null;
+ }
+
+ public List<ArtifactBasicMetadata> getDependencyMetadata() throws DataSourceException {
+ List<ArtifactBasicMetadata> metadatas = new ArrayList<ArtifactBasicMetadata>();
+
+ ModelDataSource source = new DefaultModelDataSource();
+ source.init(modelProperties, Arrays.asList(new ArtifactModelContainerFactory(), new IdModelContainerFactory()));
+ for(ModelContainer modelContainer: source.queryFor(ProjectUri.Dependencies.Dependency.xUri)) {
+ metadatas.add(transformContainerToMetadata(modelContainer));
+ }
+
+ return metadatas;
+ }
+
+ public Collection<ModelContainer> getActiveProfileContainers(List<InterpolatorProperty> properties) throws DataSourceException {
+ ModelDataSource dataSource = new DefaultModelDataSource();
+ dataSource.init(modelProperties, Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) );
+ return new ProfileContext(dataSource, properties).getActiveProfiles();
+ }
+
+ public ArtifactBasicMetadata getParentMetadata() {
+ if (parentMetadata != null) {
+ return copyArtifactBasicMetadata(parentMetadata);
+ }
+ String groupId = null, artifactId = null, version = null;
+
+ for (ModelProperty mp : modelProperties) {
+ if (mp.getUri().equals(ProjectUri.Parent.version)) {
+ version = mp.getValue();
+ } else if (mp.getUri().equals(ProjectUri.Parent.artifactId)) {
+ artifactId = mp.getValue();
+ } else if (mp.getUri().equals(ProjectUri.Parent.groupId)) {
+ groupId = mp.getValue();
+ }
+ if (groupId != null && artifactId != null && version != null) {
+ break;
+ }
+ }
+
+ if (groupId == null || artifactId == null || version == null) {
+ return null;
+ }
+ parentMetadata = new ArtifactBasicMetadata();
+ parentMetadata.setArtifactId(artifactId);
+ parentMetadata.setVersion(version);
+ parentMetadata.setGroupId(groupId);
+
+ return copyArtifactBasicMetadata(parentMetadata);
+ }
+
+ private ArtifactBasicMetadata copyArtifactBasicMetadata(ArtifactBasicMetadata metadata) {
+ ArtifactBasicMetadata amd = new ArtifactBasicMetadata();
+ amd.setArtifactId(metadata.getArtifactId());
+ amd.setGroupId(metadata.getGroupId());
+ amd.setVersion(metadata.getVersion());
+ return amd;
+ }
+
+ /**
+ * @see org.apache.maven.shared.model.DomainModel#getEventHistory()
+ */
+ public String getEventHistory() {
+ return eventHistory;
+ }
+
+ /**
+ * @see org.apache.maven.shared.model.DomainModel#setEventHistory(String)
+ */
+ public void setEventHistory(String eventHistory) {
+ if (eventHistory == null) {
+ throw new IllegalArgumentException("eventHistory: null");
+ }
+ this.eventHistory = eventHistory;
+ }
+
+ public List<ModelProperty> getModelProperties() {
+ return new ArrayList<ModelProperty>(modelProperties);
+ }
+
+ private ArtifactBasicMetadata transformContainerToMetadata( ModelContainer container ) throws DataSourceException
+ {
+ List<ModelProperty> modelProperties = container.getProperties();
+
+ ArtifactBasicMetadata metadata = new ArtifactBasicMetadata();
+ for ( ModelProperty mp : modelProperties )
+ {
+ if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.groupId)) {
+ metadata.setGroupId(mp.getValue());
+ } else if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.artifactId)) {
+ metadata.setArtifactId(mp.getValue());
+ } else if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.version)) {
+ metadata.setVersion(mp.getValue());
+ } else if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.classifier)) {
+ metadata.setClassifier(mp.getValue());
+ } else if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.scope)) {
+ metadata.setScope(mp.getValue());
+ } else if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.type)) {
+ metadata.setType(mp.getValue());
+ } else if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.optional)) {
+ metadata.setOptional(mp.getValue());
+ }
+ }
+
+ if(metadata.getScope() == null) {
+ metadata.setScope("runtime");
+ }
+
+ ModelDataSource dataSource = new DefaultModelDataSource();
+ dataSource.init(container.getProperties(), Arrays.asList(new ArtifactModelContainerFactory(), new ExclusionModelContainerFactory()) );
+ List<ArtifactBasicMetadata> exclusions = new ArrayList<ArtifactBasicMetadata>();
+
+ for(ModelContainer exclusion : dataSource.queryFor(ProjectUri.Dependencies.Dependency.Exclusions.Exclusion.xUri)) {
+ ArtifactBasicMetadata meta = new ArtifactBasicMetadata();
+ exclusions.add(meta);
+
+ for(ModelProperty mp : exclusion.getProperties()) {
+ if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.Exclusions.Exclusion.artifactId)) {
+ meta.setArtifactId(mp.getValue());
+ } else if(mp.getUri().equals(ProjectUri.Dependencies.Dependency.Exclusions.Exclusion.groupId)) {
+ meta.setGroupId(mp.getValue());
+ }
+ }
+
+ }
+ metadata.setExclusions(exclusions);
+
+ return metadata;
+ }
+}
Propchange: maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModel.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-mercury/src/main/java/org/apache/maven/mercury/MavenDomainModelFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-mercury/src/main/resources/org/apache/maven/project/pom-4.0.0.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-project-builder/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/ArtifactModelContainerFactory.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/ArtifactModelContainerFactory.java?rev=719861&r1=719860&r2=719861&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/ArtifactModelContainerFactory.java (original)
+++ maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/ArtifactModelContainerFactory.java Sat Nov 22 07:21:42 2008
@@ -1,217 +1,217 @@
-package org.apache.maven.project.builder;
-
-/*
- * 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.shared.model.ModelContainer;
-import org.apache.maven.shared.model.ModelContainerAction;
-import org.apache.maven.shared.model.ModelContainerFactory;
-import org.apache.maven.shared.model.ModelProperty;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-public final class ArtifactModelContainerFactory
- implements ModelContainerFactory
-{
-
- private static final Collection<String> uris = Collections.unmodifiableList( Arrays.asList(
- ProjectUri.DependencyManagement.Dependencies.Dependency.xUri, ProjectUri.Dependencies.Dependency.xUri,
- ProjectUri.Reporting.Plugins.Plugin.xUri,
- ProjectUri.Build.PluginManagement.Plugins.Plugin.xUri,
- ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.xUri,
-
- ProjectUri.Build.Plugins.Plugin.xUri, ProjectUri.Build.Plugins.Plugin.Dependencies.Dependency.xUri,
- ProjectUri.Build.Plugins.Plugin.Dependencies.Dependency.Exclusions.Exclusion.xUri,
- ProjectUri.Build.Extensions.Extension.xUri
- ) );
-
- public Collection<String> getUris()
- {
- return uris;
- }
-
- public ModelContainer create( List<ModelProperty> modelProperties )
- {
- if ( modelProperties == null || modelProperties.size() == 0 )
- {
- throw new IllegalArgumentException( "modelProperties: null or empty" );
- }
- return new ArtifactModelContainer( modelProperties );
- }
-
- private static class ArtifactModelContainer
- implements ModelContainer
- {
-
- private String groupId;
-
- private String artifactId;
-
- private String version;
-
- private String type;
-
- private String scope;
-
- private List<ModelProperty> properties;
-
- private static String findBaseUriFrom( List<ModelProperty> modelProperties )
- {
- String baseUri = null;
- for ( ModelProperty mp : modelProperties )
- {
- if ( baseUri == null || mp.getUri().length() < baseUri.length() )
- {
- baseUri = mp.getUri();
- }
- }
- return baseUri;
- }
-
- private ArtifactModelContainer( List<ModelProperty> properties )
- {
- this.properties = new ArrayList<ModelProperty>( properties );
- this.properties = Collections.unmodifiableList( this.properties );
- String uri = findBaseUriFrom( this.properties );
-
- for ( ModelProperty mp : this.properties )
- {
- if ( version == null && mp.getUri().equals( uri + "/version" ) )
- {
- this.version = mp.getResolvedValue();
- }
- else if ( artifactId == null && mp.getUri().equals( uri + "/artifactId" ) )
- {
- this.artifactId = mp.getResolvedValue();
- }
- else if ( groupId == null && mp.getUri().equals( uri + "/groupId" ) )
- {
- this.groupId = mp.getResolvedValue();
- }
- else if ( scope == null && mp.getUri().equals( uri + "/scope" ) )
- {
- this.scope = mp.getResolvedValue();
- }
- else if ( type == null && mp.getUri().equals( ProjectUri.Dependencies.Dependency.type )
- || mp.getUri().equals(ProjectUri.DependencyManagement.Dependencies.Dependency.type)
- || mp.getUri().equals(ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.type)
- || mp.getUri().equals(ProjectUri.Build.Plugins.Plugin.Dependencies.Dependency.type))
- {
- this.type = mp.getResolvedValue();
- }
- }
- if ( groupId == null )
- {
- groupId = "org.apache.maven.plugins";
- /*
- if ( ProjectUri.Build.Plugins.Plugin.xUri.equals( uri )
- || ProjectUri.Build.PluginManagement.Plugins.Plugin.xUri.equals( uri )
- || ProjectUri.Reporting.Plugins.Plugin.xUri.equals( uri ) )
- {
- groupId = "org.apache.maven.plugins";
- }
- else
- {
- throw new IllegalArgumentException( "Properties do not contain group id. Artifact ID = "
- + artifactId + ", Version = " + version );
- }
- */
- }
-
- if ( artifactId == null )
- {
- StringBuffer sb = new StringBuffer();
- for ( ModelProperty mp : properties )
- {
- sb.append( mp ).append( "\r\n" );
- }
- throw new IllegalArgumentException( "Properties does not contain artifact id. Group ID = " + groupId +
- ", Version = " + version + ", Base = " + uri + ":\r\n" + sb );
- }
-
- if ( version == null )
- {
- version = "";
- }
-
- if ( type == null )
- {
- type = "jar";
- }
-
- if ( scope == null || scope.equals("provided"))
- {
- scope = "compile";
- }
- }
-
- public ModelContainerAction containerAction( ModelContainer modelContainer )
- {
- if ( modelContainer == null )
- {
- throw new IllegalArgumentException( "modelContainer: null" );
- }
-
- if ( !( modelContainer instanceof ArtifactModelContainer ) )
- {
- throw new IllegalArgumentException( "modelContainer: wrong type" );
- }
-
- ArtifactModelContainer c = (ArtifactModelContainer) modelContainer;
- if ( c.groupId.equals( groupId ) && c.artifactId.equals( artifactId ) && c.type.equals( type ) )
- {
- if ( c.version.equals( version ) )
- {
- return ModelContainerAction.JOIN;
- }
- else
- {
- return ModelContainerAction.DELETE;
- }
- }
- return ModelContainerAction.NOP;
- }
-
- public ModelContainer createNewInstance( List<ModelProperty> modelProperties )
- {
- return new ArtifactModelContainer( modelProperties );
- }
-
- public List<ModelProperty> getProperties()
- {
- return properties;
- }
-
- public String toString()
- {
- StringBuffer sb = new StringBuffer();
- sb.append( "Group ID = " ).append( groupId ).append( ", Artifact ID = " ).append( artifactId )
- .append( ", Version" ).append( version ).append( "\r\n" );
- for ( ModelProperty mp : properties )
- {
- sb.append( mp ).append( "\r\n" );
- }
- return sb.toString();
- }
- }
-}
+package org.apache.maven.project.builder;
+
+/*
+ * 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.shared.model.ModelContainer;
+import org.apache.maven.shared.model.ModelContainerAction;
+import org.apache.maven.shared.model.ModelContainerFactory;
+import org.apache.maven.shared.model.ModelProperty;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+public final class ArtifactModelContainerFactory
+ implements ModelContainerFactory
+{
+
+ private static final Collection<String> uris = Collections.unmodifiableList( Arrays.asList(
+ ProjectUri.DependencyManagement.Dependencies.Dependency.xUri, ProjectUri.Dependencies.Dependency.xUri,
+ ProjectUri.Reporting.Plugins.Plugin.xUri,
+ ProjectUri.Build.PluginManagement.Plugins.Plugin.xUri,
+ ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.xUri,
+
+ ProjectUri.Build.Plugins.Plugin.xUri, ProjectUri.Build.Plugins.Plugin.Dependencies.Dependency.xUri,
+ ProjectUri.Build.Plugins.Plugin.Dependencies.Dependency.Exclusions.Exclusion.xUri,
+ ProjectUri.Build.Extensions.Extension.xUri
+ ) );
+
+ public Collection<String> getUris()
+ {
+ return uris;
+ }
+
+ public ModelContainer create( List<ModelProperty> modelProperties )
+ {
+ if ( modelProperties == null || modelProperties.size() == 0 )
+ {
+ throw new IllegalArgumentException( "modelProperties: null or empty" );
+ }
+ return new ArtifactModelContainer( modelProperties );
+ }
+
+ private static class ArtifactModelContainer
+ implements ModelContainer
+ {
+
+ private String groupId;
+
+ private String artifactId;
+
+ private String version;
+
+ private String type;
+
+ private String scope;
+
+ private List<ModelProperty> properties;
+
+ private static String findBaseUriFrom( List<ModelProperty> modelProperties )
+ {
+ String baseUri = null;
+ for ( ModelProperty mp : modelProperties )
+ {
+ if ( baseUri == null || mp.getUri().length() < baseUri.length() )
+ {
+ baseUri = mp.getUri();
+ }
+ }
+ return baseUri;
+ }
+
+ private ArtifactModelContainer( List<ModelProperty> properties )
+ {
+ this.properties = new ArrayList<ModelProperty>( properties );
+ this.properties = Collections.unmodifiableList( this.properties );
+ String uri = findBaseUriFrom( this.properties );
+
+ for ( ModelProperty mp : this.properties )
+ {
+ if ( version == null && mp.getUri().equals( uri + "/version" ) )
+ {
+ this.version = mp.getResolvedValue();
+ }
+ else if ( artifactId == null && mp.getUri().equals( uri + "/artifactId" ) )
+ {
+ this.artifactId = mp.getResolvedValue();
+ }
+ else if ( groupId == null && mp.getUri().equals( uri + "/groupId" ) )
+ {
+ this.groupId = mp.getResolvedValue();
+ }
+ else if ( scope == null && mp.getUri().equals( uri + "/scope" ) )
+ {
+ this.scope = mp.getResolvedValue();
+ }
+ else if ( type == null && mp.getUri().equals( ProjectUri.Dependencies.Dependency.type )
+ || mp.getUri().equals(ProjectUri.DependencyManagement.Dependencies.Dependency.type)
+ || mp.getUri().equals(ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.type)
+ || mp.getUri().equals(ProjectUri.Build.Plugins.Plugin.Dependencies.Dependency.type))
+ {
+ this.type = mp.getResolvedValue();
+ }
+ }
+ if ( groupId == null )
+ {
+ groupId = "org.apache.maven.plugins";
+ /*
+ if ( ProjectUri.Build.Plugins.Plugin.xUri.equals( uri )
+ || ProjectUri.Build.PluginManagement.Plugins.Plugin.xUri.equals( uri )
+ || ProjectUri.Reporting.Plugins.Plugin.xUri.equals( uri ) )
+ {
+ groupId = "org.apache.maven.plugins";
+ }
+ else
+ {
+ throw new IllegalArgumentException( "Properties do not contain group id. Artifact ID = "
+ + artifactId + ", Version = " + version );
+ }
+ */
+ }
+
+ if ( artifactId == null )
+ {
+ StringBuffer sb = new StringBuffer();
+ for ( ModelProperty mp : properties )
+ {
+ sb.append( mp ).append( "\r\n" );
+ }
+ throw new IllegalArgumentException( "Properties does not contain artifact id. Group ID = " + groupId +
+ ", Version = " + version + ", Base = " + uri + ":\r\n" + sb );
+ }
+
+ if ( version == null )
+ {
+ version = "";
+ }
+
+ if ( type == null )
+ {
+ type = "jar";
+ }
+
+ if ( scope == null || scope.equals("provided"))
+ {
+ scope = "compile";
+ }
+ }
+
+ public ModelContainerAction containerAction( ModelContainer modelContainer )
+ {
+ if ( modelContainer == null )
+ {
+ throw new IllegalArgumentException( "modelContainer: null" );
+ }
+
+ if ( !( modelContainer instanceof ArtifactModelContainer ) )
+ {
+ throw new IllegalArgumentException( "modelContainer: wrong type" );
+ }
+
+ ArtifactModelContainer c = (ArtifactModelContainer) modelContainer;
+ if ( c.groupId.equals( groupId ) && c.artifactId.equals( artifactId ) && c.type.equals( type ) )
+ {
+ if ( c.version.equals( version ) )
+ {
+ return ModelContainerAction.JOIN;
+ }
+ else
+ {
+ return ModelContainerAction.DELETE;
+ }
+ }
+ return ModelContainerAction.NOP;
+ }
+
+ public ModelContainer createNewInstance( List<ModelProperty> modelProperties )
+ {
+ return new ArtifactModelContainer( modelProperties );
+ }
+
+ public List<ModelProperty> getProperties()
+ {
+ return properties;
+ }
+
+ public String toString()
+ {
+ StringBuffer sb = new StringBuffer();
+ sb.append( "Group ID = " ).append( groupId ).append( ", Artifact ID = " ).append( artifactId )
+ .append( ", Version" ).append( version ).append( "\r\n" );
+ for ( ModelProperty mp : properties )
+ {
+ sb.append( mp ).append( "\r\n" );
+ }
+ return sb.toString();
+ }
+ }
+}
Propchange: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/ArtifactModelContainerFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/ExclusionModelContainerFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/IdModelContainerFactory.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/IdModelContainerFactory.java?rev=719861&r1=719860&r2=719861&view=diff
==============================================================================
--- maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/IdModelContainerFactory.java (original)
+++ maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/IdModelContainerFactory.java Sat Nov 22 07:21:42 2008
@@ -1,115 +1,115 @@
-package org.apache.maven.project.builder;
-
-/*
- * 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.shared.model.ModelContainer;
-import org.apache.maven.shared.model.ModelContainerAction;
-import org.apache.maven.shared.model.ModelContainerFactory;
-import org.apache.maven.shared.model.ModelProperty;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-public class IdModelContainerFactory
- implements ModelContainerFactory
-{
-
- private static final Collection<String> uris = Collections.unmodifiableList( Arrays.asList(
- ProjectUri.PluginRepositories.PluginRepository.xUri,
- ProjectUri.Repositories.Repository.xUri,
- ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.xUri,
- ProjectUri.Profiles.Profile.xUri,
- ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri ) );
-
- public Collection<String> getUris()
- {
- return uris;
- }
-
- public ModelContainer create( List<ModelProperty> modelProperties )
- {
- if ( modelProperties == null || modelProperties.size() == 0 )
- {
- throw new IllegalArgumentException( "modelProperties: null or empty" );
- }
- return new IdModelContainer( modelProperties );
- }
-
- private static class IdModelContainer
- implements ModelContainer
- {
-
- private String id;
-
- private List<ModelProperty> properties;
-
- private IdModelContainer( List<ModelProperty> properties )
- {
- this.properties = new ArrayList<ModelProperty>( properties );
- this.properties = Collections.unmodifiableList( this.properties );
-
- for ( ModelProperty mp : properties )
- {
- if ( mp.getUri().endsWith( "/id" ) )
- {
- this.id = mp.getResolvedValue();
- }
- }
- }
-
- public ModelContainerAction containerAction( ModelContainer modelContainer )
- {
- if ( modelContainer == null )
- {
- throw new IllegalArgumentException( "modelContainer: null" );
- }
-
- if ( !( modelContainer instanceof IdModelContainer ) )
- {
- throw new IllegalArgumentException( "modelContainer: wrong type" );
- }
-
- IdModelContainer c = (IdModelContainer) modelContainer;
- if ( c.id == null || id == null )
- {
- return ModelContainerAction.NOP;
- }
- return ( c.id.equals( id ) ) ? ModelContainerAction.JOIN : ModelContainerAction.NOP;
- }
-
- public ModelContainer createNewInstance( List<ModelProperty> modelProperties )
- {
- return new IdModelContainer( modelProperties );
- }
-
- public List<ModelProperty> getProperties()
- {
- return properties;
- }
-
- public String toString()
- {
- return "ID = " + id;
- }
- }
-}
+package org.apache.maven.project.builder;
+
+/*
+ * 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.shared.model.ModelContainer;
+import org.apache.maven.shared.model.ModelContainerAction;
+import org.apache.maven.shared.model.ModelContainerFactory;
+import org.apache.maven.shared.model.ModelProperty;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+public class IdModelContainerFactory
+ implements ModelContainerFactory
+{
+
+ private static final Collection<String> uris = Collections.unmodifiableList( Arrays.asList(
+ ProjectUri.PluginRepositories.PluginRepository.xUri,
+ ProjectUri.Repositories.Repository.xUri,
+ ProjectUri.Reporting.Plugins.Plugin.ReportSets.ReportSet.xUri,
+ ProjectUri.Profiles.Profile.xUri,
+ ProjectUri.Build.Plugins.Plugin.Executions.Execution.xUri ) );
+
+ public Collection<String> getUris()
+ {
+ return uris;
+ }
+
+ public ModelContainer create( List<ModelProperty> modelProperties )
+ {
+ if ( modelProperties == null || modelProperties.size() == 0 )
+ {
+ throw new IllegalArgumentException( "modelProperties: null or empty" );
+ }
+ return new IdModelContainer( modelProperties );
+ }
+
+ private static class IdModelContainer
+ implements ModelContainer
+ {
+
+ private String id;
+
+ private List<ModelProperty> properties;
+
+ private IdModelContainer( List<ModelProperty> properties )
+ {
+ this.properties = new ArrayList<ModelProperty>( properties );
+ this.properties = Collections.unmodifiableList( this.properties );
+
+ for ( ModelProperty mp : properties )
+ {
+ if ( mp.getUri().endsWith( "/id" ) )
+ {
+ this.id = mp.getResolvedValue();
+ }
+ }
+ }
+
+ public ModelContainerAction containerAction( ModelContainer modelContainer )
+ {
+ if ( modelContainer == null )
+ {
+ throw new IllegalArgumentException( "modelContainer: null" );
+ }
+
+ if ( !( modelContainer instanceof IdModelContainer ) )
+ {
+ throw new IllegalArgumentException( "modelContainer: wrong type" );
+ }
+
+ IdModelContainer c = (IdModelContainer) modelContainer;
+ if ( c.id == null || id == null )
+ {
+ return ModelContainerAction.NOP;
+ }
+ return ( c.id.equals( id ) ) ? ModelContainerAction.JOIN : ModelContainerAction.NOP;
+ }
+
+ public ModelContainer createNewInstance( List<ModelProperty> modelProperties )
+ {
+ return new IdModelContainer( modelProperties );
+ }
+
+ public List<ModelProperty> getProperties()
+ {
+ return properties;
+ }
+
+ public String toString()
+ {
+ return "ID = " + id;
+ }
+ }
+}
Propchange: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/IdModelContainerFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PluginExecutionIdModelContainerFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PluginReportSetIdModelContainerFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/components/trunk/maven-project-builder/src/main/java/org/apache/maven/project/builder/PomInterpolatorTag.java
------------------------------------------------------------------------------
svn:eol-style = native