You are viewing a plain text version of this content. The canonical link for it is here.
Posted to m2-dev@maven.apache.org by jv...@apache.org on 2004/06/14 23:32:43 UTC
cvs commit: maven-components/maven-core/src/test/java/org/apache/maven/project DefaultProjectBuilderTest.java
jvanzyl 2004/06/14 14:32:43
Modified: maven-core/src/main/java/org/apache/maven/artifact/factory
DefaultMavenArtifactFactory.java
maven-core/src/main/java/org/apache/maven/project
DefaultMavenProjectBuilder.java MavenProject.java
maven-core/src/main/resources/org/apache/maven plexus.xml
maven-core/src/test/java/org/apache/maven/project
DefaultProjectBuilderTest.java
Added: maven-core/src/main/java/org/apache/maven/project/inheritance
DefaultModelInheritanceAssembler.java
ModelInheritanceAssembler.java
Removed: maven-core/src/main/java/org/apache/maven/project
DefaultModelInheritanceAssembler.java
ModelInheritanceAssembler.java
Log:
Revision Changes Path
1.2 +1 -1 maven-components/maven-core/src/main/java/org/apache/maven/artifact/factory/DefaultMavenArtifactFactory.java
Index: DefaultMavenArtifactFactory.java
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/artifact/factory/DefaultMavenArtifactFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultMavenArtifactFactory.java 14 Jun 2004 15:43:18 -0000 1.1
+++ DefaultMavenArtifactFactory.java 14 Jun 2004 21:32:42 -0000 1.2
@@ -42,7 +42,7 @@
{
Dependency d = (Dependency) i.next();
- String mavenJarProperty = project.getProperty( "maven.jar." + MavenProject.standardToLegacyId( d.getId() ) );
+ String mavenJarProperty = project.getProperty( "maven.jar." + project.getArtifactId() );
MavenArtifact artifact = createArtifact( d );
1.2 +5 -9 maven-components/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
Index: DefaultMavenProjectBuilder.java
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultMavenProjectBuilder.java 11 Jun 2004 15:11:53 -0000 1.1
+++ DefaultMavenProjectBuilder.java 14 Jun 2004 21:32:42 -0000 1.2
@@ -26,6 +26,7 @@
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.wagon.manager.WagonManager;
+import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.util.CollectionUtils;
@@ -88,7 +89,7 @@
{
// michal: I set it to false as this is backward compatible.
// I think that this method should be revoved and version with 3 params should be used exclusivly
- boolean followTransitiveDeps = true;
+ boolean followTransitiveDeps = false;
return build( projectDescriptor, useParentPom, followTransitiveDeps );
}
@@ -122,6 +123,8 @@
project.getArtifacts().addAll( result.getArtifacts().values() );
}
+ project.setFile( projectDescriptor );
+
project.initialize();
return project;
@@ -265,14 +268,7 @@
if ( mavenFinalName == null || mavenFinalName.indexOf( "${" ) >= 0 )
{
- if ( project.getArtifactId() != null )
- {
- project.setProperty( "maven.final.name", project.getArtifactId() + "-" + project.getVersion() );
- }
- else
- {
- project.setProperty( "maven.final.name", MavenProject.standardToLegacyId( project.getId() ) + "-" + project.getVersion() );
- }
+ project.setProperty( "maven.final.name", project.getArtifactId() + "-" + project.getVersion() );
}
}
1.4 +51 -129 maven-components/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
Index: MavenProject.java
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/project/MavenProject.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- MavenProject.java 14 Jun 2004 20:43:30 -0000 1.3
+++ MavenProject.java 14 Jun 2004 21:32:42 -0000 1.4
@@ -18,7 +18,18 @@
import org.apache.maven.artifact.MavenArtifact;
import org.apache.maven.artifact.collector.ArtifactCollectionResult;
-import org.apache.maven.model.*;
+import org.apache.maven.model.Build;
+import org.apache.maven.model.Contributor;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Developer;
+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.Repository;
+import org.apache.maven.model.Resource;
+import org.apache.maven.model.Scm;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
@@ -30,22 +41,21 @@
/**
* The concern of the project is provide runtime values based on the model.
- *
+ * <p/>
* The values in the model remain untouched but during the process of building
* a project notions like inheritance and interpolation can be added. This allows
* to have an entity which is useful in a runtime while preserving the model so that
* it can be marshalled and unmarshalled without being tainted by runtime
* requirements.
- *
+ * <p/>
* We need to leave the model intact because we don't want the following:
- *<ol>
+ * <ol>
* <li>We don't want interpolated values being written back into the model.
* <li>We don't want inherited values being written back into the model.
- *</ol>
- * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
+ * </ol>
*
+ * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id$
- *
* @todo addParentDependencies for 1.x compat.
*/
public class MavenProject
@@ -61,7 +71,7 @@
private List artifacts;
private Map properties;
-
+
private String FILE_SEPARATOR = "/";
private boolean alignedToBaseDirectory;
@@ -129,25 +139,21 @@
public void initialize()
{
- }
-
- // ----------------------------------------------------------------------
- // Scm Support
- // ----------------------------------------------------------------------
-
- public boolean hasScm()
- {
- return ( model.getScm() != null );
+ alignToBaseDirectory();
}
// ----------------------------------------------------------------------
// Dependency Support
// ----------------------------------------------------------------------
- /** Map of dependency ids to their real paths in the system. */
+ /**
+ * Map of dependency ids to their real paths in the system.
+ */
private Map dependencyPaths = new HashMap();
- /** Dependencies Map so that an individual dependency can be retrieved by id. */
+ /**
+ * Dependencies Map so that an individual dependency can be retrieved by id.
+ */
private Map dependencyMap = new HashMap();
/**
@@ -249,7 +255,6 @@
}
}
-
public String getTestCompileSourceRoots()
{
// Get rid of any trailing path separators.
@@ -574,13 +579,6 @@
public Build getBuild()
{
- if ( alignedToBaseDirectory )
- {
- alignToBaseDirectory();
-
- alignedToBaseDirectory = true;
- }
-
return getModel().getBuild();
}
@@ -651,85 +649,14 @@
return property;
}
- // ----------------------------------------------------------------------
- // L E G A C Y I D S U P P O R T
- // ----------------------------------------------------------------------
-
- /**
- * This is to support methods that are using the legacy form of
- * the project id. Currently the id is <groupId>:<artifactId> but the
- * following methods assume <groupId>:
- *
- * Project::getDependencyPath( <groupId> )
- * Project::getDependency( <groupId> )
- *
- * We don't want users to have to alter any usage until we have properly
- * deprecated the use of the <groupId> form.
- *
- * @param id
- * @return
- *
- * @todo (michal)do we still need this?
- */
- public static String legacyToStandardId( String id )
- {
- String newId = id;
-
- if ( id.indexOf( "+" ) != -1 )
- {
- // legacy format is groupId "+" partial artifactId
- // standard format is groupId ":" groupId "-" partialArtifactId
- int plusPos = id.indexOf( "+" );
-
- String groupId = id.substring( 0, plusPos );
-
- String partialArtifactId = id.substring( plusPos + 1 );
-
- newId = groupId + ":" + groupId + "-" + partialArtifactId;
- }
- else if ( id.indexOf( ":" ) == -1 )
- {
- newId += ":" + id;
- }
-
- return newId;
- }
-
- /**
- * This method is to support methods are expecting legacy ids. The following
- * methods expect legacy ids.
- *
- * MavenJellyContext::getMavenJarOverride( <groupId> )
- * Project::addPluginContext( <groupId>, pluginContext )
- * Project::getArtifactDirectory( <groupId> )
- *
- * We don't want users to have to alter any usage until we have properly
- * deprecated the use of the <groupId> form.
- *
- * @param id
- * @return
- */
- public static String standardToLegacyId( String id )
- {
- int i = id.indexOf( ":" );
-
- if ( i > 0 )
- {
- id = id.substring( i + 1 );
- }
-
- return id;
- }
-
/**
* Convert a <code>String</code> property to a
* <code>Boolean</code> based on its contents. It would be nice
* if Jelly would deal with this automatically.
*
- * @param key The property key to lookup and convert.
- *
- * @return The boolean value of the property if convertiable,
- * otherwise <code>Boolean.FALSE</code>.
+ * @param key The property key to lookup and convert.
+ * @return The boolean value of the property if convertiable,
+ * otherwise <code>Boolean.FALSE</code>.
*/
public boolean getBooleanProperty( String key )
{
@@ -760,13 +687,9 @@
{
String s = stripBasedirToken( build.getDirectory() );
- System.out.println( "build.directory = " + s );
-
if ( requiresBaseDirectoryAlignment( s ) )
{
build.setDirectory( new File( getFile().getParentFile(), s ).getPath() );
-
- System.out.println( "build.getDirectory() = " + build.getDirectory() );
}
s = stripBasedirToken( build.getSourceDirectory() );
@@ -828,7 +751,7 @@
if ( s.startsWith( "${basedir}" ) )
{
- // Take out ${basedir} and the leading slash
+// Take out ${basedir} and the leading slash
s = s.substring( 11 );
}
}
@@ -856,45 +779,44 @@
}
/**
+ * @return
* @todo create something like MavenContants class and put "maven.repo.local"
- *
* @todo In fact I am not sure if this object should be used for accessing the information
- * where maven local repository is. There should be only one local repository and it
- * should be shared between all projects. Probably we can have a component like
- * MavenEnvinromnent which will contain all behavioral settings shared between projects.
- * This component can read on the startup ${user.home}/build.properties file
- *
- *
- * there
- * @return
+ * where maven local repository is. There should be only one local repository and it
+ * should be shared between all projects. Probably we can have a component like
+ * MavenEnvinromnent which will contain all behavioral settings shared between projects.
+ * This component can read on the startup ${user.home}/build.properties file
+ * <p/>
+ * <p/>
+ * there
*/
public String getLocalRepository()
{
return getProperty( "maven.repo.local" );
}
-
+
public void setLocalRepository( String path )
{
- properties.put( "maven.repo.local", path );
+ properties.put( "maven.repo.local", path );
}
public List getRepositories()
{
return model.getRepositories();
}
-
+
public void addRepository( Repository repository )
- {
+ {
model.getRepositories().add( repository );
}
-
+
public void addRepository( String url )
- {
+ {
Repository repository = new Repository();
-
- repository.setUrl( url );
-
- addRepository( repository );
+
+ repository.setUrl( url );
+
+ addRepository( repository );
}
public ArtifactCollectionResult getArtifactCollectionResult()
@@ -902,10 +824,10 @@
return artifactCollectionResult;
}
- public void setArtifactCollectionResult( ArtifactCollectionResult artifactCollectionResult )
+ public void setArtifactCollectionResult( ArtifactCollectionResult artifactCollectionResult )
{
-
- this.artifactCollectionResult = artifactCollectionResult ;
+
+ this.artifactCollectionResult = artifactCollectionResult;
}
}
1.1 maven-components/maven-core/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
Index: DefaultModelInheritanceAssembler.java
===================================================================
package org.apache.maven.project.inheritance;
import java.util.List;
import java.util.Iterator;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.model.Repository;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id: DefaultModelInheritanceAssembler.java,v 1.1 2004/06/14 21:32:42 jvanzyl Exp $
*
* @todo generate this with modello to keep it in sync with changes in the model.
*/
public class DefaultModelInheritanceAssembler
implements ModelInheritanceAssembler
{
public void assembleModelInheritance( Model child, Model parent )
{
// Pom version
if ( child.getModelVersion() == null )
{
child.setModelVersion( parent.getModelVersion() );
}
// Group id
if ( child.getGroupId() == null )
{
child.setGroupId( parent.getGroupId() );
}
// artifactId
if ( child.getArtifactId() == null )
{
child.setArtifactId( parent.getArtifactId() );
}
// name
if ( child.getName() == null )
{
child.setName( parent.getName() );
}
// currentVersion
if ( child.getVersion() == null )
{
child.setVersion( parent.getVersion() );
}
// inceptionYear
if ( child.getInceptionYear() == null )
{
child.setInceptionYear( parent.getInceptionYear() );
}
// Name
if ( child.getPackage() == null )
{
child.setPackage( parent.getPackage() );
}
// url
if ( child.getUrl() == null )
{
child.setUrl( parent.getUrl() );
}
// siteAddress
if ( child.getSiteAddress() == null )
{
child.setSiteAddress( parent.getSiteAddress() );
}
// siteDirectory
if ( child.getSiteDirectory() == null )
{
child.setSiteDirectory( parent.getSiteDirectory() );
}
// distributionDirectory
if ( child.getDistributionDirectory() == null )
{
child.setDistributionDirectory( parent.getDistributionDirectory() );
}
// issueManagement
if ( child.getIssueManagement() == null )
{
child.setIssueManagement( parent.getIssueManagement() );
}
// Short description
if ( child.getShortDescription() == null )
{
child.setShortDescription( parent.getShortDescription() );
}
// Short description
if ( child.getDescription() == null )
{
child.setDescription( parent.getDescription() );
}
// Organization
if ( child.getOrganization() == null )
{
child.setOrganization( parent.getOrganization() );
}
// Scm
if ( child.getScm() == null )
{
child.setScm( parent.getScm() );
}
// developers
if ( child.getDevelopers().size() == 0 )
{
child.setDevelopers( parent.getDevelopers() );
}
// developers
if ( child.getContributors().size() == 0 )
{
child.setContributors( parent.getContributors() );
}
// mailingLists
if ( child.getMailingLists().size() == 0 )
{
child.setMailingLists( parent.getMailingLists() );
}
// reports
if ( child.getReports().size() == 0 )
{
child.setReports( parent.getReports() );
}
// Build
if ( child.getBuild() == null )
{
child.setBuild( parent.getBuild() );
}
// Dependencies :: aggregate
List dependencies = parent.getDependencies();
for ( Iterator iterator = dependencies.iterator(); iterator.hasNext();)
{
Dependency dependency = ( Dependency ) iterator.next();
child.addDependency( dependency );
}
//Repositories :: aggreagte
List parentRepositories = parent.getRepositories();
List childRepositories = child.getRepositories();
for ( Iterator iterator = parentRepositories.iterator(); iterator.hasNext();)
{
Repository repository = ( Repository ) iterator.next();
if ( !childRepositories.contains( repository ) )
{
child.addRepository( repository );
}
}
}
}
1.1 maven-components/maven-core/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceAssembler.java
Index: ModelInheritanceAssembler.java
===================================================================
package org.apache.maven.project.inheritance;
import org.apache.maven.model.Model;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id: ModelInheritanceAssembler.java,v 1.1 2004/06/14 21:32:42 jvanzyl Exp $
*/
public interface ModelInheritanceAssembler
{
String ROLE = ModelInheritanceAssembler.class.getName();
void assembleModelInheritance( Model child, Model parent );
}
1.3 +3 -8 maven-components/maven-core/src/main/resources/org/apache/maven/plexus.xml
Index: plexus.xml
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/main/resources/org/apache/maven/plexus.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- plexus.xml 14 Jun 2004 17:42:41 -0000 1.2
+++ plexus.xml 14 Jun 2004 21:32:42 -0000 1.3
@@ -64,7 +64,7 @@
<implementation>org.apache.maven.project.DefaultMavenProjectBuilder</implementation>
<requirements>
<requirement>
- <role>org.apache.maven.project.ModelInheritanceAssembler</role>
+ <role>org.apache.maven.project.inheritance.ModelInheritanceAssembler</role>
</requirement>
<requirement>
<role>org.apache.maven.artifact.collector.ArtifactCollector</role>
@@ -94,11 +94,6 @@
<role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
<implementation>org.apache.maven.artifact.resolver.DefaultArtifactResolver</implementation>
<requirements>
- <!--
- <requirement>
- <role>org.apache.maven.artifact.factory.MavenArtifactFactory</role>
- </requirement>
- -->
<requirement>
<role>org.apache.maven.artifact.downloader.ArtifactDownloader</role>
</requirement>
@@ -117,8 +112,8 @@
</requirements>
</component>
<component>
- <role>org.apache.maven.project.ModelInheritanceAssembler</role>
- <implementation>org.apache.maven.project.DefaultModelInheritanceAssembler</implementation>
+ <role>org.apache.maven.project.inheritance.ModelInheritanceAssembler</role>
+ <implementation>org.apache.maven.project.inheritance.DefaultModelInheritanceAssembler</implementation>
</component>
<component>
<role>org.apache.maven.artifact.snapshot.SnapshotResolver</role>
1.3 +1 -0 maven-components/maven-core/src/test/java/org/apache/maven/project/DefaultProjectBuilderTest.java
Index: DefaultProjectBuilderTest.java
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/project/DefaultProjectBuilderTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultProjectBuilderTest.java 14 Jun 2004 20:43:32 -0000 1.2
+++ DefaultProjectBuilderTest.java 14 Jun 2004 21:32:43 -0000 1.3
@@ -55,6 +55,7 @@
// Build
// ----------------------------------------------------------------------
+ //@todo these are now aligned right off the hop so we need to test against the users env.
//Build build = model.getBuild();
//assertEquals( "src/main/java", build.getSourceDirectory() );