You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2008/09/18 13:10:00 UTC
svn commit: r696629 [4/7] - in /maven/components/branches/jvz: ./
maven-core-it-runner/ maven-core/ maven-core/src/main/aspect/
maven-core/src/main/java/org/apache/maven/
maven-core/src/main/java/org/apache/maven/errors/
maven-core/src/main/java/org/ap...
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java Thu Sep 18 04:09:54 2008
@@ -20,13 +20,19 @@
*/
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DefaultArtifact;
+import org.apache.maven.artifact.InvalidArtifactRTException;
import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
+import org.apache.maven.artifact.metadata.ArtifactMetadata;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.model.Resource;
-import org.apache.maven.project.artifact.AttachedArtifact;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import java.io.File;
+import java.util.Collection;
+import java.util.Collections;
import java.util.List;
public class DefaultMavenProjectHelper
@@ -36,7 +42,8 @@
private ArtifactHandlerManager artifactHandlerManager;
- public void attachArtifact( MavenProject project, String artifactType, String artifactClassifier, File artifactFile )
+ public void attachArtifact( MavenProject project, String artifactType, String artifactClassifier,
+ File artifactFile )
{
String type = artifactType;
@@ -57,7 +64,7 @@
artifact.setFile( artifactFile );
artifact.setResolved( true );
- attachArtifact(project, artifact);
+ attachArtifact( project, artifact );
}
public void attachArtifact( MavenProject project, String artifactType, File artifactFile )
@@ -69,33 +76,34 @@
artifact.setFile( artifactFile );
artifact.setResolved( true );
- attachArtifact(project, artifact);
+ attachArtifact( project, artifact );
}
public void attachArtifact( MavenProject project, File artifactFile, String artifactClassifier )
{
Artifact projectArtifact = project.getArtifact();
- Artifact artifact = new AttachedArtifact( projectArtifact, projectArtifact.getType(), artifactClassifier, projectArtifact.getArtifactHandler() );
+ Artifact artifact = new AttachedArtifact( projectArtifact, projectArtifact.getType(), artifactClassifier,
+ projectArtifact.getArtifactHandler() );
artifact.setFile( artifactFile );
artifact.setResolved( true );
- attachArtifact(project, artifact);
+ attachArtifact( project, artifact );
}
- public void attachArtifact(MavenProject project, Artifact artifact)
+ public void attachArtifact( MavenProject project, Artifact artifact )
{
try
{
- project.addAttachedArtifact( artifact );
+ project.addAttachedArtifact( artifact );
}
- catch (DuplicateArtifactAttachmentException dae)
+ catch ( DuplicateArtifactAttachmentException dae )
{
- getLogger().warn(dae.getMessage());
+ getLogger().warn( dae.getMessage() );
- // We can throw this because it's unchecked, and won't change the MavenProjectHelper API, which would break backward compat if it did.
- throw dae;
+ // We can throw this because it's unchecked, and won't change the MavenProjectHelper API, which would break backward compat if it did.
+ throw dae;
}
}
@@ -119,4 +127,140 @@
project.addTestResource( resource );
}
+ private static class AttachedArtifact
+ extends DefaultArtifact
+ {
+
+ private final Artifact parent;
+
+ public AttachedArtifact( Artifact parent, String type, String classifier, ArtifactHandler artifactHandler )
+ {
+ super( parent.getGroupId(), parent.getArtifactId(), parent.getVersionRange(), parent.getScope(), type,
+ classifier, artifactHandler, parent.isOptional() );
+
+ setDependencyTrail( Collections.singletonList( parent.getId() ) );
+
+ this.parent = parent;
+
+ if ( getId().equals( parent.getId() ) )
+ {
+ throw new InvalidArtifactRTException( parent.getGroupId(), parent.getArtifactId(), parent.getVersion(),
+ parent.getType(),
+ "An attached artifact must have a different ID than its corresponding main artifact." );
+ }
+ }
+
+ public AttachedArtifact( Artifact parent, String type, ArtifactHandler artifactHandler )
+ {
+ this( parent, type, null, artifactHandler );
+ }
+
+ public void setArtifactId( String artifactId )
+ {
+ // ignore this. We should ALWAYS use the information from the parent artifact.
+ }
+
+ public List getAvailableVersions()
+ {
+ return parent.getAvailableVersions();
+ }
+
+ public void setAvailableVersions( List availableVersions )
+ {
+ // ignore this. We should ALWAYS use the information from the parent artifact.
+ }
+
+ public String getBaseVersion()
+ {
+ return parent.getBaseVersion();
+ }
+
+ public void setBaseVersion( String baseVersion )
+ {
+ // ignore this. We should ALWAYS use the information from the parent artifact.
+ }
+
+ public String getDownloadUrl()
+ {
+ return parent.getDownloadUrl();
+ }
+
+ public void setDownloadUrl( String downloadUrl )
+ {
+ // ignore this. We should ALWAYS use the information from the parent artifact.
+ }
+
+ public void setGroupId( String groupId )
+ {
+ // ignore this. We should ALWAYS use the information from the parent artifact.
+ }
+
+ public ArtifactRepository getRepository()
+ {
+ return parent.getRepository();
+ }
+
+ public void setRepository( ArtifactRepository repository )
+ {
+ // ignore this. We should ALWAYS use the information from the parent artifact.
+ }
+
+ public String getScope()
+ {
+ return parent.getScope();
+ }
+
+ public void setScope( String scope )
+ {
+ // ignore this. We should ALWAYS use the information from the parent artifact.
+ }
+
+ public String getVersion()
+ {
+ return parent.getVersion();
+ }
+
+ public void setVersion( String version )
+ {
+ // ignore this. We should ALWAYS use the information from the parent artifact.
+ }
+
+ public VersionRange getVersionRange()
+ {
+ return parent.getVersionRange();
+ }
+
+ public void setVersionRange( VersionRange range )
+ {
+ // ignore this. We should ALWAYS use the information from the parent artifact.
+ }
+
+ public boolean isRelease()
+ {
+ return parent.isRelease();
+ }
+
+ public void setRelease( boolean release )
+ {
+ // ignore this. We should ALWAYS use the information from the parent artifact.
+ }
+
+ public boolean isSnapshot()
+ {
+ return parent.isSnapshot();
+ }
+
+ public void addMetadata( ArtifactMetadata metadata )
+ {
+ // ignore. The parent artifact will handle metadata.
+ // we must fail silently here to avoid problems with the artifact transformers.
+ }
+
+ public Collection getMetadataList()
+ {
+ return Collections.EMPTY_LIST;
+ }
+
+ }
+
}
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/DefaultProjectBuilderConfiguration.java Thu Sep 18 04:09:54 2008
@@ -1,5 +1,24 @@
package org.apache.maven.project;
+/*
+ * 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.artifact.repository.ArtifactRepository;
import org.apache.maven.profiles.ProfileManager;
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/DuplicateArtifactAttachmentException.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/DuplicateArtifactAttachmentException.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/DuplicateArtifactAttachmentException.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/DuplicateArtifactAttachmentException.java Thu Sep 18 04:09:54 2008
@@ -27,9 +27,8 @@
*
* @author pgier
* @author jdcasey
- *
* @todo Make this a checked exception, and modify the API of MavenProjectHelper.
- * Currently, this modification would create compatibility problems for existing plugins.
+ * Currently, this modification would create compatibility problems for existing plugins.
*/
public class DuplicateArtifactAttachmentException
extends RuntimeException
@@ -48,8 +47,7 @@
this.artifact = artifact;
}
- private static String constructMessage( MavenProject project,
- Artifact artifact )
+ private static String constructMessage( MavenProject project, Artifact artifact )
{
return DEFAULT_MESSAGE + " (project: " + project.getId() + "; illegal attachment: " + artifact.getId() + ")";
}
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/InvalidProjectModelException.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/InvalidProjectModelException.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/InvalidProjectModelException.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/InvalidProjectModelException.java Thu Sep 18 04:09:54 2008
@@ -20,7 +20,6 @@
*/
import org.apache.maven.artifact.InvalidRepositoryException;
-import org.apache.maven.project.interpolation.ModelInterpolationException;
import org.apache.maven.project.validation.ModelValidationResult;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@@ -37,11 +36,11 @@
}
/**
- * @deprecated use {@link File} constructor for pomLocation
* @param projectId
- * @param pomLocation absolute path of the pom file
+ * @param pomLocation absolute path of the pom file
* @param message
* @param validationResult
+ * @deprecated use {@link File} constructor for pomLocation
*/
public InvalidProjectModelException( String projectId, String pomLocation, String message,
ModelValidationResult validationResult )
@@ -58,30 +57,16 @@
}
/**
- * @deprecated use {@link File} constructor for pomLocation
* @param projectId
* @param pomLocation absolute path of the pom file
* @param message
+ * @deprecated use {@link File} constructor for pomLocation
*/
public InvalidProjectModelException( String projectId, String pomLocation, String message )
{
this( projectId, message, new File( pomLocation ) );
}
- /**
- * @deprecated use {@link File} constructor for pomLocation
- */
- public InvalidProjectModelException( String projectId, String pomLocation, String message,
- ModelInterpolationException cause )
- {
- this( projectId, message, new File( pomLocation ), cause );
- }
-
- public InvalidProjectModelException( String projectId, String message, File pomLocation,
- ModelInterpolationException cause )
- {
- super( projectId, message, pomLocation, cause );
- }
/**
* @deprecated use {@link File} constructor for pomLocation
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/InvalidProjectVersionException.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/InvalidProjectVersionException.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/InvalidProjectVersionException.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/InvalidProjectVersionException.java Thu Sep 18 04:09:54 2008
@@ -1,5 +1,24 @@
package org.apache.maven.project;
+/*
+ * 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.artifact.versioning.InvalidVersionSpecificationException;
import java.io.File;
@@ -9,21 +28,22 @@
{
private final String locationInPom;
+
private final String offendingVersion;
- public InvalidProjectVersionException( String projectId, String locationInPom, String offendingVersion, File pomFile, InvalidVersionSpecificationException cause )
+ public InvalidProjectVersionException( String projectId, String locationInPom, String offendingVersion,
+ File pomFile, InvalidVersionSpecificationException cause )
{
super( projectId, formatMessage( projectId, locationInPom, offendingVersion, cause ), pomFile, cause );
this.locationInPom = locationInPom;
this.offendingVersion = offendingVersion;
}
- private static String formatMessage( String projectId,
- String locationInPom,
- String offendingVersion,
+ private static String formatMessage( String projectId, String locationInPom, String offendingVersion,
InvalidVersionSpecificationException cause )
{
- return "Invalid version: " + offendingVersion + " found for: " + locationInPom + " in project: " + projectId + ". Reason: " + cause.getMessage();
+ return "Invalid version: " + offendingVersion + " found for: " + locationInPom + " in project: " + projectId +
+ ". Reason: " + cause.getMessage();
}
public String getOffendingVersion()
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MavenProject.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MavenProject.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MavenProject.java Thu Sep 18 04:09:54 2008
@@ -19,13 +19,18 @@
* under the License.
*/
+import org.apache.maven.MavenTools;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.artifact.InvalidRepositoryException;
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.artifact.resolver.filter.ExcludesArtifactFilter;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.ManagedVersionMap;
+import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.model.Build;
import org.apache.maven.model.CiManagement;
import org.apache.maven.model.Contributor;
@@ -33,13 +38,15 @@
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.Developer;
import org.apache.maven.model.DistributionManagement;
+import org.apache.maven.model.Exclusion;
+import org.apache.maven.model.Extension;
import org.apache.maven.model.IssueManagement;
import org.apache.maven.model.License;
import org.apache.maven.model.MailingList;
import org.apache.maven.model.Model;
import org.apache.maven.model.Organization;
+import org.apache.maven.model.Parent;
import org.apache.maven.model.Plugin;
-import org.apache.maven.model.PluginExecution;
import org.apache.maven.model.PluginManagement;
import org.apache.maven.model.Prerequisites;
import org.apache.maven.model.ReportPlugin;
@@ -51,6 +58,7 @@
import org.apache.maven.project.artifact.ActiveProjectArtifact;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.project.artifact.MavenMetadataSource;
+import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.io.File;
@@ -59,7 +67,9 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -145,14 +155,30 @@
private Map projectReferences = new HashMap();
- private Build buildOverlay;
-
private boolean executionRoot;
private Map moduleAdjustments;
private Stack previousExecutionProjects = new Stack();
+ private ArtifactFactory artifactFactory;
+
+ private MavenProjectBuilder mavenProjectBuilder;
+
+ private ProjectBuilderConfiguration projectBuilderConfiguration;
+
+ private File parentFile;
+
+ public File getParentFile()
+ {
+ return parentFile;
+ }
+
+ public void setParentFile( File parentFile )
+ {
+ this.parentFile = parentFile;
+ }
+
public MavenProject()
{
Model model = new Model();
@@ -169,157 +195,63 @@
setModel( model );
}
- /**
- * @deprecated use {@link #clone()} so subclasses can provide a copy of the same class
- */
- @Deprecated
- public MavenProject( MavenProject project )
+ public MavenProject( Model model, ArtifactFactory artifactFactory, MavenTools mavenTools, MavenProjectBuilder mavenProjectBuilder,
+ ProjectBuilderConfiguration projectBuilderConfiguration )
+ throws InvalidRepositoryException
{
- deepCopy( project );
- }
-
- private final void deepCopy(MavenProject project){
- // disown the parent
-
- // copy fields
- setFile( project.getFile() );
-
- // don't need a deep copy, they don't get modified or added/removed to/from - but make them unmodifiable to be
- // sure!
- if ( project.getDependencyArtifacts() != null )
- {
- setDependencyArtifacts( Collections.unmodifiableSet( project.getDependencyArtifacts() ) );
- }
-
- if ( project.getArtifacts() != null )
- {
- setArtifacts( Collections.unmodifiableSet( project.getArtifacts() ) );
- }
-
- if ( project.getPluginArtifacts() != null )
- {
- setPluginArtifacts( Collections.unmodifiableSet( project.getPluginArtifacts() ) );
- }
-
- if ( project.getReportArtifacts() != null )
- {
- setReportArtifacts( Collections.unmodifiableSet( project.getReportArtifacts() ) );
- }
-
- if ( project.getExtensionArtifacts() != null )
- {
- setExtensionArtifacts( Collections.unmodifiableSet( project.getExtensionArtifacts() ) );
- }
-
- setParentArtifact( ( project.getParentArtifact() ) );
-
- if ( project.getRemoteArtifactRepositories() != null )
- {
- setRemoteArtifactRepositories( Collections.unmodifiableList( project.getRemoteArtifactRepositories() ) );
- }
-
- if ( project.getPluginArtifactRepositories() != null )
- {
- setPluginArtifactRepositories( ( Collections.unmodifiableList( project.getPluginArtifactRepositories() ) ) );
- }
-
- if ( project.getCollectedProjects() != null )
- {
- setCollectedProjects( ( Collections.unmodifiableList( project.getCollectedProjects() ) ) );
- }
-
- if ( project.getActiveProfiles() != null )
- {
- setActiveProfiles( ( Collections.unmodifiableList( project.getActiveProfiles() ) ) );
- }
-
- if ( project.getAttachedArtifacts() != null )
- {
- // clone properties modifyable by plugins in a forked lifecycle
- setAttachedArtifacts( new ArrayList( project.getAttachedArtifacts() ) );
- }
-
- if ( project.getCompileSourceRoots() != null )
- {
- // clone source roots
- setCompileSourceRoots( ( new ArrayList( project.getCompileSourceRoots() ) ) );
- }
-
- if ( project.getTestCompileSourceRoots() != null )
- {
- setTestCompileSourceRoots( ( new ArrayList( project.getTestCompileSourceRoots() ) ) );
- }
-
- if ( project.getScriptSourceRoots() != null )
- {
- setScriptSourceRoots( ( new ArrayList( project.getScriptSourceRoots() ) ) );
- }
-
- setModel( ( ModelUtils.cloneModel( project.getModel() ) ) );
-
- if ( project.getOriginalModel() != null )
- {
- setOriginalModel( ( ModelUtils.cloneModel( project.getOriginalModel() ) ) );
- }
-
- setExecutionRoot( project.isExecutionRoot() );
-
- if ( project.getArtifact() != null )
- {
- setArtifact( ArtifactUtils.copyArtifact( project.getArtifact() ) );
- }
-
- if ( project.getManagedVersionMap() != null )
- {
- setManagedVersionMap( new ManagedVersionMap( project.getManagedVersionMap() ) );
- }
+ setModel( model );
+ this.artifactFactory = artifactFactory;
+ this.mavenProjectBuilder = mavenProjectBuilder;
+ this.projectBuilderConfiguration = projectBuilderConfiguration;
+ originalModel = ModelUtils.cloneModel( model );
+ DistributionManagement dm = model.getDistributionManagement();
- if ( project.getReleaseArtifactRepository() != null )
+ if ( dm != null )
{
- setReleaseArtifactRepository( project.getReleaseArtifactRepository() );
- }
+ ArtifactRepository repo = mavenTools.buildDeploymentArtifactRepository( dm.getRepository() );
+ setReleaseArtifactRepository( repo );
- if ( project.getSnapshotArtifactRepository() != null )
- {
- setSnapshotArtifactRepository( project.getSnapshotArtifactRepository() );
+ if ( dm.getSnapshotRepository() != null )
+ {
+ repo = mavenTools.buildDeploymentArtifactRepository( dm.getSnapshotRepository() );
+ setSnapshotArtifactRepository( repo );
+ }
}
- if ( project.isConcrete() )
+ try
{
- setDynamicBuild( ModelUtils.cloneBuild( project.getDynamicBuild() ) );
- setOriginalInterpolatedBuild( ModelUtils.cloneBuild( project.getOriginalInterpolatedBuild() ) );
-
- List dynamicRoots = project.getDynamicCompileSourceRoots();
- if ( dynamicRoots != null )
+ LinkedHashSet repoSet = new LinkedHashSet();
+ if ( ( model.getRepositories() != null ) && !model.getRepositories().isEmpty() )
{
- setDynamicCompileSourceRoots( new ArrayList( dynamicRoots ) );
- setOriginalInterpolatedCompileSourceRoots( new ArrayList(
- project.getOriginalInterpolatedCompileSourceRoots() ) );
+ repoSet.addAll( model.getRepositories() );
}
- dynamicRoots = project.getDynamicTestCompileSourceRoots();
- if ( dynamicRoots != null )
+ if ( ( model.getPluginRepositories() != null ) && !model.getPluginRepositories().isEmpty() )
{
- setDynamicTestCompileSourceRoots( new ArrayList( dynamicRoots ) );
- setOriginalInterpolatedTestCompileSourceRoots( new ArrayList(
- project.getOriginalInterpolatedTestCompileSourceRoots() ) );
+ repoSet.addAll( model.getPluginRepositories() );
}
- dynamicRoots = project.getDynamicScriptSourceRoots();
- if ( dynamicRoots != null )
- {
- setDynamicScriptSourceRoots( new ArrayList( dynamicRoots ) );
- setOriginalInterpolatedScriptSourceRoots( new ArrayList(
- project.getOriginalInterpolatedScriptSourceRoots() ) );
- }
+ setRemoteArtifactRepositories( mavenTools.buildArtifactRepositories( new ArrayList( repoSet ) ) );
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
}
+ }
- setConcrete( project.isConcrete() );
+ /**
+ * @deprecated use {@link #clone()} so subclasses can provide a copy of the same class
+ */
+ @Deprecated
+ public MavenProject( MavenProject project )
+ {
+ deepCopy( project );
}
// TODO: Find a way to use <relativePath/> here...it's tricky, because the moduleProject
// usually doesn't have a file associated with it yet.
- public String getModulePathAdjustment( MavenProject moduleProject ) throws IOException
+ public String getModulePathAdjustment( MavenProject moduleProject )
+ throws IOException
{
// FIXME: This is hacky. What if module directory doesn't match artifactid, and parent
// is coming from the repository??
@@ -396,6 +328,43 @@
public MavenProject getParent()
{
+ if ( parent == null )
+ {
+ if ( parentFile != null )
+ {
+ try
+ {
+ parent = mavenProjectBuilder.build( parentFile, projectBuilderConfiguration );
+ }
+ catch ( ProjectBuildingException e )
+ {
+ e.printStackTrace();
+ }
+ }
+ else if ( model.getParent() != null )
+ {
+ try
+ {
+ parent = mavenProjectBuilder.buildFromRepository( getParentArtifact(),
+ this.remoteArtifactRepositories,
+ projectBuilderConfiguration.getLocalRepository() );
+ }
+ catch ( ProjectBuildingException e )
+ {
+ e.printStackTrace();
+ }
+ }
+ /*
+ else
+ {
+ try {
+ parent = mavenProjectBuilder.buildStandaloneSuperProject(projectBuilderConfiguration);
+ } catch (ProjectBuildingException e) {
+ e.printStackTrace();
+ }
+ }
+ */
+ }
return parent;
}
@@ -616,13 +585,6 @@
if ( a.getArtifactHandler().isAddedToClasspath() )
{
- // TODO: let the scope handler deal with this
- // NOTE: [jc] scope == 'test' is the widest possible scope, so we don't really need to perform
- // this check...
- // if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) ||
- // Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
- // {
- // }
File file = a.getFile();
if ( file == null )
{
@@ -645,15 +607,6 @@
// TODO: classpath check doesn't belong here - that's the other method
if ( a.getArtifactHandler().isAddedToClasspath() )
{
- // TODO: let the scope handler deal with this
- // NOTE: [jc] scope == 'test' is the widest possible scope, so we don't really need to perform
- // this check...
- // if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) ||
- // Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
- // {
- // list.add( a );
- // }
-
list.add( a );
}
}
@@ -675,14 +628,6 @@
{
Artifact a = (Artifact) i.next();
- // TODO: let the scope handler deal with this
- // NOTE: [jc] scope == 'test' is the widest possible scope, so we don't really need to perform
- // this check...
- // if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) ||
- // Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
- // {
- // }
-
Dependency dependency = new Dependency();
dependency.setArtifactId( a.getArtifactId() );
@@ -1144,6 +1089,7 @@
* All dependencies that this project has, including transitive ones.
* Contents are lazily populated, so depending on what phases have run dependencies in some scopes won't be included.
* eg. if only compile phase has run, dependencies with scope test won't be included.
+ *
* @return {@link Set} < {@link Artifact} >
* @see #getDependencyArtifacts() to get only direct dependencies
*/
@@ -1158,29 +1104,57 @@
{
artifactMap = ArtifactUtils.artifactMapByVersionlessId( getArtifacts() );
}
-
return artifactMap;
}
- public void setPluginArtifacts( Set pluginArtifacts )
+ public Set getPluginArtifacts()
{
- this.pluginArtifacts = pluginArtifacts;
+ if ( pluginArtifacts != null )
+ {
+ return pluginArtifacts;
+ }
+ pluginArtifacts = new HashSet();
+ if ( artifactFactory != null )
+ {
+ List plugins = getBuildPlugins();
+ for ( Iterator i = plugins.iterator(); i.hasNext(); )
+ {
+ Plugin p = (Plugin) i.next();
- pluginArtifactMap = null;
- }
+ String version;
+ if ( StringUtils.isEmpty( p.getVersion() ) )
+ {
+ version = "RELEASE";
+ }
+ else
+ {
+ version = p.getVersion();
+ }
- public Set getPluginArtifacts()
- {
+ Artifact artifact;
+ try
+ {
+ artifact = artifactFactory.createPluginArtifact( p.getGroupId(), p.getArtifactId(),
+ VersionRange.createFromVersionSpec( version ) );
+ }
+ catch ( InvalidVersionSpecificationException e )
+ {
+ return pluginArtifacts;
+ }
+
+ if ( artifact != null )
+ {
+ pluginArtifacts.add( artifact );
+ }
+ }
+ }
+ pluginArtifactMap = null;
return pluginArtifacts;
}
public Map getPluginArtifactMap()
{
- if ( pluginArtifactMap == null )
- {
- pluginArtifactMap = ArtifactUtils.artifactMapByVersionlessId( getPluginArtifacts() );
- }
-
+ pluginArtifactMap = ArtifactUtils.artifactMapByVersionlessId( getPluginArtifacts() );
return pluginArtifactMap;
}
@@ -1193,6 +1167,47 @@
public Set getReportArtifacts()
{
+ if( reportArtifacts != null )
+ {
+ return reportArtifacts;
+ }
+
+ reportArtifacts = new HashSet();
+ List reports = getReportPlugins();
+ if ( reports != null )
+ {
+ for ( Iterator i = reports.iterator(); i.hasNext(); )
+ {
+ ReportPlugin p = (ReportPlugin) i.next();
+
+ String version;
+ if ( StringUtils.isEmpty( p.getVersion() ) )
+ {
+ version = "RELEASE";
+ }
+ else
+ {
+ version = p.getVersion();
+ }
+
+ Artifact artifact = null;
+ try
+ {
+ artifact = artifactFactory.createPluginArtifact( p.getGroupId(), p.getArtifactId(),
+ VersionRange.createFromVersionSpec( version ) );
+ }
+ catch ( InvalidVersionSpecificationException e )
+ {
+ //throw new InvalidProjectVersionException( projectId, "Report plugin: " + p.getKey(), version, pomLocation, e );
+ }
+
+ if ( artifact != null )
+ {
+ reportArtifacts.add( artifact );
+ }
+ }
+ }
+ reportArtifactMap = null;
return reportArtifacts;
}
@@ -1215,6 +1230,47 @@
public Set getExtensionArtifacts()
{
+ if( extensionArtifacts != null )
+ {
+ return extensionArtifacts;
+ }
+ extensionArtifacts = new HashSet();
+ List extensions = getBuildExtensions();
+ if ( extensions != null )
+ {
+ for ( Iterator i = extensions.iterator(); i.hasNext(); )
+ {
+ Extension ext = (Extension) i.next();
+
+ String version;
+ if ( StringUtils.isEmpty( ext.getVersion() ) )
+ {
+ version = "RELEASE";
+ }
+ else
+ {
+ version = ext.getVersion();
+ }
+
+ Artifact artifact = null;
+ try
+ {
+ VersionRange versionRange = VersionRange.createFromVersionSpec( version );
+ artifact =
+ artifactFactory.createExtensionArtifact( ext.getGroupId(), ext.getArtifactId(), versionRange );
+ }
+ catch ( InvalidVersionSpecificationException e )
+ {
+
+ }
+
+ if ( artifact != null )
+ {
+ extensionArtifacts.add( artifact );
+ }
+ }
+ }
+ extensionArtifactMap = null;
return extensionArtifacts;
}
@@ -1235,6 +1291,11 @@
public Artifact getParentArtifact()
{
+ if ( parentArtifact == null && model.getParent() != null )
+ {
+ Parent p = model.getParent();
+ parentArtifact = artifactFactory.createParentArtifact( p.getGroupId(), p.getArtifactId(), p.getVersion() );
+ }
return parentArtifact;
}
@@ -1251,7 +1312,7 @@
{
if ( getModel().getReporting() == null )
{
- return null;
+ return Collections.EMPTY_LIST;
}
return getModel().getReporting().getPlugins();
@@ -1261,7 +1322,7 @@
{
if ( getModel().getBuild() == null )
{
- return null;
+ return Collections.EMPTY_LIST;
}
return getModel().getBuild().getPlugins();
}
@@ -1357,7 +1418,8 @@
public ArtifactRepository getDistributionManagementArtifactRepository()
{
- return getArtifact().isSnapshot() && ( getSnapshotArtifactRepository() != null ) ? getSnapshotArtifactRepository()
+ return getArtifact().isSnapshot() && ( getSnapshotArtifactRepository() != null )
+ ? getSnapshotArtifactRepository()
: getReleaseArtifactRepository();
}
@@ -1399,8 +1461,8 @@
return attachedArtifacts;
}
- public Xpp3Dom getGoalConfiguration( String pluginGroupId, String pluginArtifactId, String executionId,
- String goalId )
+
+ public Xpp3Dom getReportConfiguration( String pluginGroupId, String pluginArtifactId, String reportSetId )
{
Xpp3Dom dom = null;
@@ -1410,22 +1472,22 @@
// for now I have to iterate through and see what we have.
// ----------------------------------------------------------------------
- if ( getBuildPlugins() != null )
+ if ( getReportPlugins() != null )
{
- for ( Iterator iterator = getBuildPlugins().iterator(); iterator.hasNext(); )
+ for ( Iterator iterator = getReportPlugins().iterator(); iterator.hasNext(); )
{
- Plugin plugin = (Plugin) iterator.next();
+ ReportPlugin plugin = (ReportPlugin) iterator.next();
if ( pluginGroupId.equals( plugin.getGroupId() ) && pluginArtifactId.equals( plugin.getArtifactId() ) )
{
dom = (Xpp3Dom) plugin.getConfiguration();
- if ( executionId != null )
+ if ( reportSetId != null )
{
- PluginExecution execution = (PluginExecution) plugin.getExecutionsAsMap().get( executionId );
- if ( execution != null )
+ ReportSet reportSet = (ReportSet) plugin.getReportSetsAsMap().get( reportSetId );
+ if ( reportSet != null )
{
- Xpp3Dom executionConfiguration = (Xpp3Dom) execution.getConfiguration();
+ Xpp3Dom executionConfiguration = (Xpp3Dom) reportSet.getConfiguration();
if ( executionConfiguration != null )
{
Xpp3Dom newDom = new Xpp3Dom( executionConfiguration );
@@ -1447,61 +1509,14 @@
return dom;
}
- public Xpp3Dom getReportConfiguration( String pluginGroupId, String pluginArtifactId, String reportSetId )
+ public MavenProject getExecutionProject()
{
- Xpp3Dom dom = null;
-
- // ----------------------------------------------------------------------
- // I would like to be able to lookup the Mojo object using a key but
- // we have a limitation in modello that will be remedied shortly. So
- // for now I have to iterate through and see what we have.
- // ----------------------------------------------------------------------
+ return ( executionProject == null ? this : executionProject );
+ }
- if ( getReportPlugins() != null )
- {
- for ( Iterator iterator = getReportPlugins().iterator(); iterator.hasNext(); )
- {
- ReportPlugin plugin = (ReportPlugin) iterator.next();
-
- if ( pluginGroupId.equals( plugin.getGroupId() ) && pluginArtifactId.equals( plugin.getArtifactId() ) )
- {
- dom = (Xpp3Dom) plugin.getConfiguration();
-
- if ( reportSetId != null )
- {
- ReportSet reportSet = (ReportSet) plugin.getReportSetsAsMap().get( reportSetId );
- if ( reportSet != null )
- {
- Xpp3Dom executionConfiguration = (Xpp3Dom) reportSet.getConfiguration();
- if ( executionConfiguration != null )
- {
- Xpp3Dom newDom = new Xpp3Dom( executionConfiguration );
- dom = Xpp3Dom.mergeXpp3Dom( newDom, dom );
- }
- }
- }
- break;
- }
- }
- }
-
- if ( dom != null )
- {
- // make a copy so the original in the POM doesn't get messed with
- dom = new Xpp3Dom( dom );
- }
-
- return dom;
- }
-
- public MavenProject getExecutionProject()
- {
- return ( executionProject == null ? this : executionProject );
- }
-
- public void setExecutionProject( MavenProject executionProject )
- {
- if ( this.executionProject != null )
+ public void setExecutionProject( MavenProject executionProject )
+ {
+ if ( this.executionProject != null )
{
previousExecutionProjects.push( this.executionProject );
}
@@ -1509,24 +1524,9 @@
this.executionProject = executionProject;
}
- public void writeModel( Writer writer )
- throws IOException
- {
- MavenXpp3Writer pomWriter = new MavenXpp3Writer();
-
- pomWriter.write( writer, getModel() );
- }
-
- public void writeOriginalModel( Writer writer )
- throws IOException
- {
- MavenXpp3Writer pomWriter = new MavenXpp3Writer();
-
- pomWriter.write( writer, getOriginalModel() );
- }
-
/**
* Direct dependencies that this project has.
+ *
* @return {@link Set} < {@link Artifact} >
* @see #getArtifacts() to get all transitive dependencies
*/
@@ -1567,6 +1567,77 @@
public Map getManagedVersionMap()
{
+ if ( managedVersionMap != null )
+ {
+ return managedVersionMap;
+ }
+
+ Map map = null;
+ if ( artifactFactory != null )
+ {
+
+ List deps;
+ DependencyManagement dependencyManagement = getDependencyManagement();
+ if ( ( dependencyManagement != null ) && ( ( deps = dependencyManagement.getDependencies() ) != null ) &&
+ ( deps.size() > 0 ) )
+ {
+ map = new ManagedVersionMap( map );
+ for ( Iterator i = dependencyManagement.getDependencies().iterator(); i.hasNext(); )
+ {
+ Dependency d = (Dependency) i.next();
+
+ try
+ {
+ VersionRange versionRange = VersionRange.createFromVersionSpec( d.getVersion() );
+
+ Artifact artifact = artifactFactory.createDependencyArtifact( d.getGroupId(), d.getArtifactId(),
+ versionRange, d.getType(),
+ d.getClassifier(), d.getScope(),
+ d.isOptional() );
+
+ if ( Artifact.SCOPE_SYSTEM.equals( d.getScope() ) && ( d.getSystemPath() != null ) )
+ {
+ artifact.setFile( new File( d.getSystemPath() ) );
+ }
+
+ // If the dependencyManagement section listed exclusions,
+ // add them to the managed artifacts here so that transitive
+ // dependencies will be excluded if necessary.
+
+ if ( ( null != d.getExclusions() ) && !d.getExclusions().isEmpty() )
+ {
+ List exclusions = new ArrayList();
+
+ for ( Iterator j = d.getExclusions().iterator(); j.hasNext(); )
+ {
+ Exclusion e = (Exclusion) j.next();
+
+ exclusions.add( e.getGroupId() + ":" + e.getArtifactId() );
+ }
+
+ ExcludesArtifactFilter eaf = new ExcludesArtifactFilter( exclusions );
+
+ artifact.setDependencyFilter( eaf );
+ }
+ else
+ {
+ artifact.setDependencyFilter( null );
+ }
+
+ map.put( d.getManagementKey(), artifact );
+ }
+ catch ( InvalidVersionSpecificationException e )
+ {
+ map = Collections.EMPTY_MAP;
+ }
+ }
+ }
+ else if ( map == null )
+ {
+ map = Collections.EMPTY_MAP;
+ }
+ }
+ managedVersionMap = map;
return managedVersionMap;
}
@@ -1609,8 +1680,8 @@
}
/**
- * @todo the lazy initialisation of this makes me uneasy.
* @return {@link Set} < {@link Artifact} >
+ * @todo the lazy initialisation of this makes me uneasy.
*/
public Set createArtifacts( ArtifactFactory artifactFactory, String inheritedScope,
ArtifactFilter dependencyFilter )
@@ -1622,12 +1693,8 @@
public void addProjectReference( MavenProject project )
{
- projectReferences.put( getProjectReferenceId( project.getGroupId(), project.getArtifactId(), project.getVersion() ), project );
- }
-
- private static String getProjectReferenceId( String groupId, String artifactId, String version )
- {
- return groupId + ":" + artifactId + ":" + version;
+ projectReferences.put(
+ getProjectReferenceId( project.getGroupId(), project.getArtifactId(), project.getVersion() ), project );
}
/**
@@ -1668,47 +1735,12 @@
return getBuild() != null ? getBuild().getDefaultGoal() : null;
}
-
- protected void setModel( Model model )
- {
- this.model = model;
- }
-
- protected void setAttachedArtifacts( List attachedArtifacts )
- {
- this.attachedArtifacts = attachedArtifacts;
- }
-
- protected void setCompileSourceRoots( List compileSourceRoots )
- {
- this.compileSourceRoots = compileSourceRoots;
- }
-
- protected void setTestCompileSourceRoots( List testCompileSourceRoots )
- {
- this.testCompileSourceRoots = testCompileSourceRoots;
- }
-
- protected void setScriptSourceRoots( List scriptSourceRoots )
- {
- this.scriptSourceRoots = scriptSourceRoots;
- }
-
- protected ArtifactRepository getReleaseArtifactRepository()
- {
- return releaseArtifactRepository;
- }
-
- protected ArtifactRepository getSnapshotArtifactRepository()
- {
- return snapshotArtifactRepository;
- }
-
public Artifact replaceWithActiveArtifact( Artifact pluginArtifact )
{
if ( ( getProjectReferences() != null ) && !getProjectReferences().isEmpty() )
{
- String refId = getProjectReferenceId( pluginArtifact.getGroupId(), pluginArtifact.getArtifactId(), pluginArtifact.getVersion() );
+ String refId = getProjectReferenceId( pluginArtifact.getGroupId(), pluginArtifact.getArtifactId(),
+ pluginArtifact.getVersion() );
MavenProject ref = (MavenProject) getProjectReferences().get( refId );
if ( ( ref != null ) && ( ref.getArtifact() != null ) )
{
@@ -1732,32 +1764,13 @@
}
Iterator itr = ref.getAttachedArtifacts().iterator();
- while(itr.hasNext()) {
+ while ( itr.hasNext() )
+ {
Artifact attached = (Artifact) itr.next();
- if( attached.getDependencyConflictId().equals(pluginArtifact.getDependencyConflictId()) ) {
- /* TODO: if I use the original, I get an exception below:
- java.lang.UnsupportedOperationException: Cannot change the download information for an attached artifact. It is derived from the main artifact.
- at org.apache.maven.project.artifact.AttachedArtifact.setDownloadUrl(AttachedArtifact.java:89)
- at org.apache.maven.project.artifact.MavenMetadataSource.retrieve(MavenMetadataSource.java:205)
- at org.apache.maven.artifact.resolver.DefaultArtifactCollector.recurse(DefaultArtifactCollector.java:275)
- at org.apache.maven.artifact.resolver.DefaultArtifactCollector.collect(DefaultArtifactCollector.java:67)
- at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolveTransitively(DefaultArtifactResolver.java:223)
- at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolveTransitively(DefaultArtifactResolver.java:211)
- at org.apache.maven.artifact.resolver.DefaultArtifactResolver.resolveTransitively(DefaultArtifactResolver.java:182)
- at org.apache.maven.plugin.DefaultPluginManager.resolveTransitiveDependencies(DefaultPluginManager.java:1117)
- at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:366)
- at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:534)
- at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:475)
- at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:454)
- at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:306)
- at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:273)
- at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:140)
- at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:322)
- at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:115)
- at org.apache.maven.cli.MavenCli.main(MavenCli.java:256)
- */
- Artifact resultArtifact=ArtifactUtils.copyArtifact(attached);
- resultArtifact.setScope(pluginArtifact.getScope());
+ if ( attached.getDependencyConflictId().equals( pluginArtifact.getDependencyConflictId() ) )
+ {
+ Artifact resultArtifact = ArtifactUtils.copyArtifact( attached );
+ resultArtifact.setScope( pluginArtifact.getScope() );
return resultArtifact;
}
}
@@ -1780,9 +1793,7 @@
( pluginArtifact.getType().equals( "ejb-client" ) ) &&
( ( ref.getArtifact().getFile() != null ) && ref.getArtifact().getFile().exists() ) )
{
- pluginArtifact = new ActiveProjectArtifact(
- ref,
- pluginArtifact );
+ pluginArtifact = new ActiveProjectArtifact( ref, pluginArtifact );
return pluginArtifact;
}
}
@@ -1790,40 +1801,6 @@
return pluginArtifact;
}
- private void addArtifactPath(Artifact a, List list) throws DependencyResolutionRequiredException
- {
- String refId = getProjectReferenceId( a.getGroupId(), a.getArtifactId(), a.getVersion() );
- MavenProject project = (MavenProject) projectReferences.get( refId );
-
- boolean projectDirFound = false;
- if ( project != null )
- {
- if (a.getType().equals("test-jar"))
- {
- File testOutputDir = new File( project.getBuild().getTestOutputDirectory() );
- if ( testOutputDir.exists() )
- {
- list.add( testOutputDir.getAbsolutePath() );
- projectDirFound = true;
- }
- }
- else
- {
- list.add( project.getBuild().getOutputDirectory() );
- projectDirFound = true;
- }
- }
- if ( ! projectDirFound )
- {
- File file = a.getFile();
- if ( file == null )
- {
- throw new DependencyResolutionRequiredException( a );
- }
- list.add( file.getPath() );
- }
- }
-
public void clearExecutionProject()
{
if ( !previousExecutionProjects.isEmpty() )
@@ -1840,13 +1817,14 @@
{
return (Plugin) getBuild().getPluginsAsMap().get( pluginKey );
}
+
/**
* Default toString
*/
@Override
public String toString()
{
- StringBuffer sb = new StringBuffer(30);
+ StringBuffer sb = new StringBuffer( 30 );
sb.append( "MavenProject: " );
sb.append( getGroupId() );
sb.append( ":" );
@@ -1859,7 +1837,7 @@
{
sb.append( getFile().getPath() );
}
- catch (NullPointerException e)
+ catch ( NullPointerException e )
{
//don't log it.
}
@@ -1867,6 +1845,14 @@
return sb.toString();
}
+ public void writeModel( Writer writer )
+ throws IOException
+ {
+ MavenXpp3Writer pomWriter = new MavenXpp3Writer();
+ pomWriter.write( writer, getModel() );
+ }
+
+
/**
* @throws CloneNotSupportedException
* @since 2.0.9
@@ -1880,159 +1866,187 @@
return clone;
}
-// ----------------------------------------------------------------------------
-// CODE BELOW IS USED TO PRESERVE DYNAMISM IN THE BUILD SECTION OF THE POM.
-// ----------------------------------------------------------------------------
-
- private Build dynamicBuild;
-
- private Build originalInterpolatedBuild;
-
- private List dynamicCompileSourceRoots;
-
- private List originalInterpolatedCompileSourceRoots;
-
- private List dynamicTestCompileSourceRoots;
-
- private List originalInterpolatedTestCompileSourceRoots;
-
- private List dynamicScriptSourceRoots;
-
- private List originalInterpolatedScriptSourceRoots;
-
- private boolean isConcrete = false;
-
- public boolean isConcrete()
+ protected void setModel( Model model )
{
- return isConcrete;
+ this.model = model;
}
- public void setConcrete( boolean concrete )
+ protected void setAttachedArtifacts( List attachedArtifacts )
{
- isConcrete = concrete;
+ this.attachedArtifacts = attachedArtifacts;
}
- public Build getDynamicBuild()
+ protected void setCompileSourceRoots( List compileSourceRoots )
{
- return dynamicBuild;
+ this.compileSourceRoots = compileSourceRoots;
}
- public Build getOriginalInterpolatedBuild()
+ protected void setTestCompileSourceRoots( List testCompileSourceRoots )
{
- return originalInterpolatedBuild;
+ this.testCompileSourceRoots = testCompileSourceRoots;
}
- public List getDynamicCompileSourceRoots()
+ protected void setScriptSourceRoots( List scriptSourceRoots )
{
- return dynamicCompileSourceRoots;
+ this.scriptSourceRoots = scriptSourceRoots;
}
- public List getOriginalInterpolatedCompileSourceRoots()
+ protected ArtifactRepository getReleaseArtifactRepository()
{
- return originalInterpolatedCompileSourceRoots;
+ return releaseArtifactRepository;
}
- public List getDynamicTestCompileSourceRoots()
+ protected ArtifactRepository getSnapshotArtifactRepository()
{
- return dynamicTestCompileSourceRoots;
+ return snapshotArtifactRepository;
}
- public List getOriginalInterpolatedTestCompileSourceRoots()
+ private void deepCopy( MavenProject project )
{
- return originalInterpolatedTestCompileSourceRoots;
- }
+ // disown the parent
- public List getDynamicScriptSourceRoots()
- {
- return dynamicScriptSourceRoots;
- }
+ // copy fields
+ setFile( project.getFile() );
- public List getOriginalInterpolatedScriptSourceRoots()
- {
- return originalInterpolatedScriptSourceRoots;
- }
+ // don't need a deep copy, they don't get modified or added/removed to/from - but make them unmodifiable to be
+ // sure!
+ if ( project.getDependencyArtifacts() != null )
+ {
+ setDependencyArtifacts( Collections.unmodifiableSet( project.getDependencyArtifacts() ) );
+ }
- public void clearRestorableRoots()
- {
- dynamicCompileSourceRoots = null;
- dynamicTestCompileSourceRoots = null;
- dynamicScriptSourceRoots = null;
- originalInterpolatedCompileSourceRoots = null;
- originalInterpolatedScriptSourceRoots = null;
- originalInterpolatedTestCompileSourceRoots = null;
- }
+ if ( project.getArtifacts() != null )
+ {
+ setArtifacts( Collections.unmodifiableSet( project.getArtifacts() ) );
+ }
- public void clearRestorableBuild()
- {
- dynamicBuild = null;
- originalInterpolatedBuild = null;
- }
+ if ( project.getParentFile() != null )
+ {
+ parentFile = new File( project.getParentFile().getAbsolutePath() );
+ }
- public void preserveCompileSourceRoots( List originalInterpolatedCompileSourceRoots )
- {
- dynamicCompileSourceRoots = getCompileSourceRoots();
- this.originalInterpolatedCompileSourceRoots = originalInterpolatedCompileSourceRoots;
- }
+ if ( project.getReportArtifacts() != null )
+ {
+ setReportArtifacts( Collections.unmodifiableSet( project.getReportArtifacts() ) );
+ }
- public void preserveTestCompileSourceRoots( List originalInterpolatedTestCompileSourceRoots )
- {
- dynamicTestCompileSourceRoots = getTestCompileSourceRoots();
- this.originalInterpolatedTestCompileSourceRoots = originalInterpolatedTestCompileSourceRoots;
- }
+ if ( project.getExtensionArtifacts() != null )
+ {
+ setExtensionArtifacts( Collections.unmodifiableSet( project.getExtensionArtifacts() ) );
+ }
- public void preserveScriptSourceRoots( List originalInterpolatedScriptSourceRoots )
- {
- dynamicScriptSourceRoots = getScriptSourceRoots();
- this.originalInterpolatedScriptSourceRoots = originalInterpolatedScriptSourceRoots;
- }
+ setParentArtifact( ( project.getParentArtifact() ) );
- public void preserveBuild( Build originalInterpolatedBuild )
- {
- dynamicBuild = getBuild();
- this.originalInterpolatedBuild = originalInterpolatedBuild;
+ if ( project.getRemoteArtifactRepositories() != null )
+ {
+ setRemoteArtifactRepositories( Collections.unmodifiableList( project.getRemoteArtifactRepositories() ) );
+ }
- this.originalInterpolatedBuild.setPluginManagement( null );
- this.originalInterpolatedBuild.setPlugins( null );
- }
+ if ( project.getPluginArtifactRepositories() != null )
+ {
+ setPluginArtifactRepositories(
+ ( Collections.unmodifiableList( project.getPluginArtifactRepositories() ) ) );
+ }
- protected void setDynamicBuild( Build dynamicBuild )
- {
- this.dynamicBuild = dynamicBuild;
- }
+ if ( project.getCollectedProjects() != null )
+ {
+ setCollectedProjects( ( Collections.unmodifiableList( project.getCollectedProjects() ) ) );
+ }
- protected void setOriginalInterpolatedBuild( Build originalInterpolatedBuild )
- {
- this.originalInterpolatedBuild = originalInterpolatedBuild;
- }
+ if ( project.getActiveProfiles() != null )
+ {
+ setActiveProfiles( ( Collections.unmodifiableList( project.getActiveProfiles() ) ) );
+ }
- protected void setDynamicCompileSourceRoots( List dynamicCompileSourceRoots )
- {
- this.dynamicCompileSourceRoots = dynamicCompileSourceRoots;
- }
+ if ( project.getAttachedArtifacts() != null )
+ {
+ // clone properties modifyable by plugins in a forked lifecycle
+ setAttachedArtifacts( new ArrayList( project.getAttachedArtifacts() ) );
+ }
- protected void setOriginalInterpolatedCompileSourceRoots( List originalInterpolatedCompileSourceRoots )
- {
- this.originalInterpolatedCompileSourceRoots = originalInterpolatedCompileSourceRoots;
- }
+ if ( project.getCompileSourceRoots() != null )
+ {
+ // clone source roots
+ setCompileSourceRoots( ( new ArrayList( project.getCompileSourceRoots() ) ) );
+ }
- protected void setDynamicTestCompileSourceRoots( List dynamicTestCompileSourceRoots )
- {
- this.dynamicTestCompileSourceRoots = dynamicTestCompileSourceRoots;
- }
+ if ( project.getTestCompileSourceRoots() != null )
+ {
+ setTestCompileSourceRoots( ( new ArrayList( project.getTestCompileSourceRoots() ) ) );
+ }
- protected void setOriginalInterpolatedTestCompileSourceRoots( List originalInterpolatedTestCompileSourceRoots )
- {
- this.originalInterpolatedTestCompileSourceRoots = originalInterpolatedTestCompileSourceRoots;
+ if ( project.getScriptSourceRoots() != null )
+ {
+ setScriptSourceRoots( ( new ArrayList( project.getScriptSourceRoots() ) ) );
+ }
+
+ setModel( ( ModelUtils.cloneModel( project.getModel() ) ) );
+
+ if ( project.getOriginalModel() != null )
+ {
+ setOriginalModel( ( ModelUtils.cloneModel( project.getOriginalModel() ) ) );
+ }
+
+ setExecutionRoot( project.isExecutionRoot() );
+
+ if ( project.getArtifact() != null )
+ {
+ setArtifact( ArtifactUtils.copyArtifact( project.getArtifact() ) );
+ }
+
+ if ( project.getManagedVersionMap() != null )
+ {
+ setManagedVersionMap( new ManagedVersionMap( project.getManagedVersionMap() ) );
+ }
+
+ if ( project.getReleaseArtifactRepository() != null )
+ {
+ setReleaseArtifactRepository( project.getReleaseArtifactRepository() );
+ }
+
+ if ( project.getSnapshotArtifactRepository() != null )
+ {
+ setSnapshotArtifactRepository( project.getSnapshotArtifactRepository() );
+ }
}
- protected void setDynamicScriptSourceRoots( List dynamicScriptSourceRoots )
+ private void addArtifactPath( Artifact a, List list )
+ throws DependencyResolutionRequiredException
{
- this.dynamicScriptSourceRoots = dynamicScriptSourceRoots;
+ String refId = getProjectReferenceId( a.getGroupId(), a.getArtifactId(), a.getVersion() );
+ MavenProject project = (MavenProject) projectReferences.get( refId );
+
+ boolean projectDirFound = false;
+ if ( project != null )
+ {
+ if ( a.getType().equals( "test-jar" ) )
+ {
+ File testOutputDir = new File( project.getBuild().getTestOutputDirectory() );
+ if ( testOutputDir.exists() )
+ {
+ list.add( testOutputDir.getAbsolutePath() );
+ projectDirFound = true;
+ }
+ }
+ else
+ {
+ list.add( project.getBuild().getOutputDirectory() );
+ projectDirFound = true;
+ }
+ }
+ if ( !projectDirFound )
+ {
+ File file = a.getFile();
+ if ( file == null )
+ {
+ throw new DependencyResolutionRequiredException( a );
+ }
+ list.add( file.getPath() );
+ }
}
- protected void setOriginalInterpolatedScriptSourceRoots( List originalInterpolatedScriptSourceRoots )
+ private static String getProjectReferenceId( String groupId, String artifactId, String version )
{
- this.originalInterpolatedScriptSourceRoots = originalInterpolatedScriptSourceRoots;
+ return groupId + ":" + artifactId + ":" + version;
}
-
}
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java Thu Sep 18 04:09:54 2008
@@ -22,7 +22,6 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.profiles.ProfileManager;
-import org.apache.maven.project.interpolation.ModelInterpolationException;
import java.io.File;
import java.util.List;
@@ -35,7 +34,7 @@
String STANDALONE_SUPERPOM_ARTIFACTID = "super-pom";
- String STANDALONE_SUPERPOM_VERSION = "2.1";
+ String STANDALONE_SUPERPOM_VERSION = "3.0";
boolean STRICT_MODEL_PARSING = true;
@@ -43,21 +42,17 @@
* @deprecated Use {@link MavenProjectBuilder#build(File, ProjectBuilderConfiguration)} instead.
*/
@Deprecated
- MavenProject build( File project,
- ArtifactRepository localRepository,
- ProfileManager globalProfileManager )
+ MavenProject build( File project, ArtifactRepository localRepository, ProfileManager globalProfileManager )
throws ProjectBuildingException;
MavenProject build( File project, ProjectBuilderConfiguration configuration )
throws ProjectBuildingException;
- MavenProject buildWithDependencies( File project,
- ArtifactRepository localRepository,
+ MavenProject buildWithDependencies( File project, ArtifactRepository localRepository,
ProfileManager globalProfileManager )
throws ProjectBuildingException;
- MavenProjectBuildingResult buildProjectWithDependencies( File project,
- ProjectBuilderConfiguration config )
+ MavenProjectBuildingResult buildProjectWithDependencies( File project, ProjectBuilderConfiguration config )
throws ProjectBuildingException;
@@ -65,23 +60,21 @@
* @deprecated Use {@link MavenProjectBuilder#buildProjectWithDependencies(File, ProjectBuilderConfiguration)} instead.
*/
@Deprecated
- MavenProjectBuildingResult buildProjectWithDependencies( File project,
- ArtifactRepository localRepository,
+ MavenProjectBuildingResult buildProjectWithDependencies( File project, ArtifactRepository localRepository,
ProfileManager globalProfileManager )
throws ProjectBuildingException;
- MavenProject buildFromRepository( Artifact artifact,
- List remoteArtifactRepositories,
+ MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories,
ArtifactRepository localRepository )
throws ProjectBuildingException;
- /** @deprecated We do not want to allow projects to not have POMs. Maven 1.x repositories be damned. */
+ /**
+ * @deprecated We do not want to allow projects to not have POMs. Maven 1.x repositories be damned.
+ */
@Deprecated
- MavenProject buildFromRepository( Artifact artifact,
- List remoteArtifactRepositories,
- ArtifactRepository localRepository,
- boolean allowStub )
+ MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories,
+ ArtifactRepository localRepository, boolean allowStub )
throws ProjectBuildingException;
/**
@@ -101,15 +94,4 @@
MavenProject buildStandaloneSuperProject( ProjectBuilderConfiguration config )
throws ProjectBuildingException;
- // ----------------------------------------------------------------------------
- // API BELOW IS USED TO PRESERVE DYNAMISM IN THE BUILD SECTION OF THE POM.
- // ----------------------------------------------------------------------------
-
- void calculateConcreteState( MavenProject project,
- ProjectBuilderConfiguration config )
- throws ModelInterpolationException;
-
- void restoreDynamicState( MavenProject project,
- ProjectBuilderConfiguration config )
- throws ModelInterpolationException;
}
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuildingResult.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuildingResult.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuildingResult.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuildingResult.java Thu Sep 18 04:09:54 2008
@@ -31,8 +31,7 @@
private ArtifactResolutionResult artifactResolutionResult;
- public MavenProjectBuildingResult( MavenProject project,
- ArtifactResolutionResult artifactResolutionResult )
+ public MavenProjectBuildingResult( MavenProject project, ArtifactResolutionResult artifactResolutionResult )
{
this.project = project;
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MavenProjectHelper.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MavenProjectHelper.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MavenProjectHelper.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MavenProjectHelper.java Thu Sep 18 04:09:54 2008
@@ -23,17 +23,17 @@
import java.util.List;
public interface MavenProjectHelper
-{
+{
String ROLE = MavenProjectHelper.class.getName();
void attachArtifact( MavenProject project, File artifactFile, String artifactClassifier );
-
+
void attachArtifact( MavenProject project, String artifactType, File artifactFile );
-
+
void attachArtifact( MavenProject project, String artifactType, String artifactClassifier, File artifactFile );
-
+
void addResource( MavenProject project, String resourceDirectory, List includes, List excludes );
-
+
void addTestResource( MavenProject project, String resourceDirectory, List includes, List excludes );
-
+
}
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MissingRepositoryElementException.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MissingRepositoryElementException.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MissingRepositoryElementException.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/MissingRepositoryElementException.java Thu Sep 18 04:09:54 2008
@@ -1,13 +1,31 @@
package org.apache.maven.project;
+/*
+ * 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.artifact.InvalidRepositoryException;
public class MissingRepositoryElementException
extends InvalidRepositoryException
{
- public MissingRepositoryElementException( String message,
- String repositoryId )
+ public MissingRepositoryElementException( String message, String repositoryId )
{
super( message, repositoryId );
}