The archiver doesnt have to understand eclipse. But it can't create a MavenProject object when the one passed is a subclass that may have customized behavior
On Thu, Feb 14, 2008 at 5:42 PM, Brian E. Fox <[EMAIL PROTECTED]> wrote: > It seems curious to me that the archiver needs to understand eclipse. > Isn't this a generic component? Perhaps you should be making > maven-eclipse-archiver or something. > > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Carlos > Sanchez > Sent: Thursday, February 14, 2008 5:41 PM > To: Maven Developers List > Subject: Re: svn commit: r627675 - in > /maven/components/branches/maven-2.0.x/maven-project/src: > main/java/org/apache/maven/project/MavenProject.java > > > test/java/org/apache/maven/project/MavenProjectTest.java > > The archiver is making a copy of the MavenProject using newProject = > new MavenProject(project) > project is a subclass of MavenProject (EclipseMavenProject) > Instead the archiver should do project.clone() if any > > Previous to my patch new MavenProject(project) fails with NPE as the > fields are accessed directly. After the patch it works, although I > still think to make copies it should use clone() and that's why I > deprecated the constructor > > what @todo are you talking about? > > I will fix the clone method. > > On Thu, Feb 14, 2008 at 5:17 PM, Brett Porter <[EMAIL PROTECTED]> wrote: > > I'm not sure why the archiver needs to use the delegate? Is it because > > you lose track of the updates? IF that's all, then you could follow > > the @todo in the class javadoc :) > > > > If it truly needs it, clone is the right method - I'd definitely > > recommend reading the section on clone in Effective Java though :) > > > > - Brett > > > > > > > > On 15/02/2008, at 11:57 AM, Carlos Sanchez wrote: > > > > > Reading carefully the javadoc I see the mistakes i made in clone :( > I > > > can fix that > > > > > > The problem arised with a delegate pattern implementation, the > > > MavenProject instance is encapsulated [1], but the problem comes > with > > > other classes using this constructor to make copies, which will > ignore > > > any customizations made in the delegating object (the subclass). > > > > > > If the way to make a copy where defined in a method ( clone() seems > to > > > be the right one ) then subclasses could just override that method > and > > > there wouldnt be any need of getters/setters, but right now that > > > constructor is used in the maven archiver. Adding the getters and > > > setters is a patch until the other classes are updated to use > clone() > > > and to keep backwards compatibility. > > > > > > [1] http://tinyurl.com/29jzte > > > > > > > > > On Thu, Feb 14, 2008 at 4:15 PM, Brett Porter <[EMAIL PROTECTED]> > > > wrote: > > >> Carlos, > > >> > > >> Can you elaborate on the need for this? > > >> > > >> I understand that since MavenProject is non-final and so are the > get/ > > >> sets they can be overridden and so we should be using the get/set > > >> internally. However, it would seem we don't need that > funcationality > > >> for every field - which particular ones do you see as needing to > be > > >> overridden? > > >> > > >> Also, I don't think the clone() stuff is right: > > >> - you've deprecated the copy constructor even though it is still > > >> useful. You also require it's existence which means it shouldn't > be > > >> deprecated. > > >> - clone()'s contract says that it doesn't call any constructors, > > >> making the method work but not as documented by the JDK > > >> - clone() should call super.clone() to get a valid MavenProject > > >> instance > > >> - MavenProject doesn't implement clonable > > >> Why did you need clone()? > > >> > > >> Thanks, > > >> Brett > > >> > > >> On 14/02/2008, at 5:40 PM, [EMAIL PROTECTED] wrote: > > >> > > >>> Author: carlos > > >>> Date: Wed Feb 13 22:40:35 2008 > > >>> New Revision: 627675 > > >>> > > >>> URL: http://svn.apache.org/viewvc?rev=627675&view=rev > > >>> Log: > > >>> [MNG-3400] MavenProject is not extensible. Merge rev 627670 from > > >>> trunk > > >>> > > >>> Modified: > > >>> > maven/components/branches/maven-2.0.x/maven-project/src/main/java/ > > >>> org/apache/maven/project/MavenProject.java > > >>> > maven/components/branches/maven-2.0.x/maven-project/src/test/java/ > > >>> org/apache/maven/project/MavenProjectTest.java > > >>> > > >>> Modified: > maven/components/branches/maven-2.0.x/maven-project/src/ > > >>> main/java/org/apache/maven/project/MavenProject.java > > >>> URL: > http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven > -project/src/main/java/org/apache/maven/project/MavenProject.java?rev=62 > 7675&r1=627674&r2=627675&view=diff > > >>> = > > >>> = > > >>> = > > >>> = > > >>> = > > >>> = > > >>> = > > >>> = > > >>> = > > >>> = > > >>> > ==================================================================== > > >>> --- maven/components/branches/maven-2.0.x/maven-project/src/main/ > > >>> java/org/apache/maven/project/MavenProject.java (original) > > >>> +++ maven/components/branches/maven-2.0.x/maven-project/src/main/ > > >>> java/org/apache/maven/project/MavenProject.java Wed Feb 13 > 22:40:35 > > >>> 2008 > > >>> @@ -158,103 +158,107 @@ > > >>> model.setArtifactId( EMPTY_PROJECT_ARTIFACT_ID ); > > >>> model.setVersion( EMPTY_PROJECT_VERSION ); > > >>> > > >>> - this.model = model; > > >>> + this.setModel( model ); > > >>> } > > >>> > > >>> public MavenProject( Model model ) > > >>> { > > >>> - this.model = model; > > >>> + this.setModel( model ); > > >>> } > > >>> > > >>> + /** > > >>> + * @deprecated use [EMAIL PROTECTED] #clone()} > > >>> + */ > > >>> public MavenProject( MavenProject project ) > > >>> { > > >>> // disown the parent > > >>> > > >>> // copy fields > > >>> - this.file = project.file; > > >>> + 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.dependencyArtifacts != null ) > > >>> + // 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 ) > > >>> { > > >>> - this.dependencyArtifacts = > > >>> Collections.unmodifiableSet( project.dependencyArtifacts ); > > >>> + > > >>> setDependencyArtifacts > > >>> ( Collections.unmodifiableSet( project.getDependencyArtifacts() ) > ); > > >>> } > > >>> - > > >>> - if ( project.artifacts != null ) > > >>> + > > >>> + if ( project.getArtifacts() != null ) > > >>> { > > >>> - this.artifacts = > > >>> Collections.unmodifiableSet( project.artifacts ); > > >>> + > > >>> setArtifacts > > >>> ( Collections.unmodifiableSet( project.getArtifacts() ) ); > > >>> } > > >>> - > > >>> - if ( project.pluginArtifacts != null ) > > >>> + > > >>> + if ( project.getPluginArtifacts() != null ) > > >>> { > > >>> - this.pluginArtifacts = > > >>> Collections.unmodifiableSet( project.pluginArtifacts ); > > >>> + > > >>> setPluginArtifacts > > >>> ( Collections.unmodifiableSet( project.getPluginArtifacts() ) ); > > >>> } > > >>> - > > >>> - if ( project.reportArtifacts != null ) > > >>> + > > >>> + if ( project.getReportArtifacts() != null ) > > >>> { > > >>> - this.reportArtifacts = > > >>> Collections.unmodifiableSet( project.reportArtifacts ); > > >>> - } > > >>> - > > >>> - if ( project.extensionArtifacts != null ) > > >>> + > > >>> setReportArtifacts > > >>> ( Collections.unmodifiableSet( project.getReportArtifacts() ) ); > > >>> + } > > >>> + > > >>> + if ( project.getExtensionArtifacts() != null ) > > >>> { > > >>> - this.extensionArtifacts = > > >>> Collections.unmodifiableSet( project.extensionArtifacts ); > > >>> - } > > >>> - > > >>> - this.parentArtifact = project.parentArtifact; > > >>> + > > >>> setExtensionArtifacts > > >>> ( Collections.unmodifiableSet( project.getExtensionArtifacts() ) > ); > > >>> + } > > >>> + > > >>> + setParentArtifact( ( project.getParentArtifact() ) ); > > >>> > > >>> - if ( project.remoteArtifactRepositories != null ) > > >>> + if ( project.getRemoteArtifactRepositories() != null ) > > >>> { > > >>> - this.remoteArtifactRepositories = > > >>> Collections.unmodifiableList( project.remoteArtifactRepositories > ); > > >>> - } > > >>> - > > >>> - if ( project.pluginArtifactRepositories != null ) > > >>> + > > >>> setRemoteArtifactRepositories > > >>> ( Collections > > >>> .unmodifiableList( project.getRemoteArtifactRepositories() ) ); > > >>> + } > > >>> + > > >>> + if ( project.getPluginArtifactRepositories() != null ) > > >>> { > > >>> - this.pluginArtifactRepositories = > > >>> Collections.unmodifiableList( project.pluginArtifactRepositories > ); > > >>> - } > > >>> - > > >>> - if ( project.collectedProjects != null ) > > >>> + > > >>> setPluginArtifactRepositories > > >>> ( ( Collections > > >>> .unmodifiableList( project.getPluginArtifactRepositories() ) ) ); > > >>> + } > > >>> + > > >>> + if ( project.getCollectedProjects() != null ) > > >>> { > > >>> - this.collectedProjects = > > >>> Collections.unmodifiableList( project.collectedProjects ); > > >>> - } > > >>> - > > >>> - if ( project.activeProfiles != null ) > > >>> + > > >>> setCollectedProjects > > >>> ( ( Collections > > >>> .unmodifiableList( project.getCollectedProjects() ) ) ); > > >>> + } > > >>> + > > >>> + if ( project.getActiveProfiles() != null ) > > >>> { > > >>> - this.activeProfiles = > > >>> Collections.unmodifiableList( project.activeProfiles ); > > >>> - } > > >>> - > > >>> + > > >>> setActiveProfiles > > >>> ( ( Collections.unmodifiableList( project.getActiveProfiles() ) ) > ); > > >>> + } > > >>> + > > >>> if ( project.getAttachedArtifacts() != null ) > > >>> { > > >>> // clone properties modifyable by plugins in a forked > > >>> lifecycle > > >>> - this.attachedArtifacts = new > > >>> ArrayList( project.getAttachedArtifacts() ); > > >>> - } > > >>> - > > >>> - if ( project.compileSourceRoots != null ) > > >>> + setAttachedArtifacts( new > > >>> ArrayList( project.getAttachedArtifacts() ) ); > > >>> + } > > >>> + > > >>> + if ( project.getCompileSourceRoots() != null ) > > >>> { > > >>> // clone source roots > > >>> - this.compileSourceRoots = new > > >>> ArrayList( project.compileSourceRoots ); > > >>> - } > > >>> - > > >>> - if ( project.testCompileSourceRoots != null ) > > >>> + setCompileSourceRoots( ( new > > >>> ArrayList( project.getCompileSourceRoots() ) ) ); > > >>> + } > > >>> + > > >>> + if ( project.getTestCompileSourceRoots() != null ) > > >>> { > > >>> - this.testCompileSourceRoots = new > > >>> ArrayList( project.testCompileSourceRoots ); > > >>> - } > > >>> - > > >>> - if ( project.scriptSourceRoots != null ) > > >>> + setTestCompileSourceRoots( ( new > > >>> ArrayList( project.getTestCompileSourceRoots() ) ) ); > > >>> + } > > >>> + > > >>> + if ( project.getScriptSourceRoots() != null ) > > >>> { > > >>> - this.scriptSourceRoots = new > > >>> ArrayList( project.scriptSourceRoots ); > > >>> - } > > >>> - > > >>> - this.model = ModelUtils.cloneModel( project.model ); > > >>> + setScriptSourceRoots( ( new > > >>> ArrayList( project.getScriptSourceRoots() ) ) ); > > >>> + } > > >>> > > >>> - if ( project.originalModel != null ) > > >>> + > > >>> setModel( ( ModelUtils.cloneModel( project.getModel() ) ) ); > > >>> + > > >>> + if ( project.getOriginalModel() != null ) > > >>> { > > >>> - this.originalModel = > > >>> ModelUtils.cloneModel( project.originalModel ); > > >>> + > > >>> setOriginalModel > > >>> ( ( ModelUtils.cloneModel( project.getOriginalModel() ) ) ); > > >>> } > > >>> > > >>> - this.executionRoot = project.executionRoot; > > >>> + setExecutionRoot( project.isExecutionRoot() ); > > >>> > > >>> - if ( project.artifact != null ) > > >>> + if ( project.getArtifact() != null ) > > >>> { > > >>> - this.artifact = > > >>> ArtifactUtils.copyArtifact( project.artifact ); > > >>> + > > >>> setArtifact( ArtifactUtils.copyArtifact( project.getArtifact() ) > ); > > >>> } > > >>> > > >>> if ( project.getManagedVersionMap() != null ) > > >>> @@ -262,14 +266,14 @@ > > >>> setManagedVersionMap( new > > >>> ManagedVersionMap( project.getManagedVersionMap() ) ); > > >>> } > > >>> > > >>> - if ( project.releaseArtifactRepository != null ) > > >>> + if ( project.getReleaseArtifactRepository() != null ) > > >>> { > > >>> - releaseArtifactRepository = > > >>> project.releaseArtifactRepository; > > >>> + > > >>> setReleaseArtifactRepository > > >>> ( project.getReleaseArtifactRepository() ); > > >>> } > > >>> > > >>> - if ( project.snapshotArtifactRepository != null ) > > >>> + if ( project.getSnapshotArtifactRepository() != null ) > > >>> { > > >>> - snapshotArtifactRepository = > > >>> project.snapshotArtifactRepository; > > >>> + > > >>> setSnapshotArtifactRepository > > >>> ( project.getSnapshotArtifactRepository() ); > > >>> } > > >>> } > > >>> > > >>> @@ -403,17 +407,17 @@ > > >>> > > >>> public void setDependencies( List dependencies ) > > >>> { > > >>> - model.setDependencies( dependencies ); > > >>> + getModel().setDependencies( dependencies ); > > >>> } > > >>> > > >>> public List getDependencies() > > >>> { > > >>> - return model.getDependencies(); > > >>> + return getModel().getDependencies(); > > >>> } > > >>> > > >>> public DependencyManagement getDependencyManagement() > > >>> { > > >>> - return model.getDependencyManagement(); > > >>> + return getModel().getDependencyManagement(); > > >>> } > > >>> > > >>> // > > >>> > ---------------------------------------------------------------------- > > >>> @@ -427,9 +431,9 @@ > > >>> path = path.trim(); > > >>> if ( path.length() != 0 ) > > >>> { > > >>> - if ( !compileSourceRoots.contains( path ) ) > > >>> + if ( !getCompileSourceRoots().contains( path ) ) > > >>> { > > >>> - compileSourceRoots.add( path ); > > >>> + getCompileSourceRoots().add( path ); > > >>> } > > >>> } > > >>> } > > >>> @@ -442,9 +446,9 @@ > > >>> path = path.trim(); > > >>> if ( path.length() != 0 ) > > >>> { > > >>> - if ( !scriptSourceRoots.contains( path ) ) > > >>> + if ( !getScriptSourceRoots().contains( path ) ) > > >>> { > > >>> - scriptSourceRoots.add( path ); > > >>> + getScriptSourceRoots().add( path ); > > >>> } > > >>> } > > >>> } > > >>> @@ -457,9 +461,9 @@ > > >>> path = path.trim(); > > >>> if ( path.length() != 0 ) > > >>> { > > >>> - if ( !testCompileSourceRoots.contains( path ) ) > > >>> + if ( ! > > >>> getTestCompileSourceRoots().contains( path ) ) > > >>> { > > >>> - testCompileSourceRoots.add( path ); > > >>> + getTestCompileSourceRoots().add( path ); > > >>> } > > >>> } > > >>> } > > >>> @@ -821,31 +825,31 @@ > > >>> > > >>> public void setModelVersion( String pomVersion ) > > >>> { > > >>> - model.setModelVersion( pomVersion ); > > >>> + getModel().setModelVersion( pomVersion ); > > >>> } > > >>> > > >>> public String getModelVersion() > > >>> { > > >>> - return model.getModelVersion(); > > >>> + return getModel().getModelVersion(); > > >>> } > > >>> > > >>> public String getId() > > >>> { > > >>> - return model.getId(); > > >>> + return getModel().getId(); > > >>> } > > >>> > > >>> public void setGroupId( String groupId ) > > >>> { > > >>> - model.setGroupId( groupId ); > > >>> + getModel().setGroupId( groupId ); > > >>> } > > >>> > > >>> public String getGroupId() > > >>> { > > >>> - String groupId = model.getGroupId(); > > >>> - > > >>> - if ( groupId == null && model.getParent() != null ) > > >>> + String groupId = getModel().getGroupId(); > > >>> + > > >>> + if ( ( groupId == null ) && ( getModel().getParent() != > > >>> null ) ) > > >>> { > > >>> - groupId = model.getParent().getGroupId(); > > >>> + groupId = getModel().getParent().getGroupId(); > > >>> } > > >>> > > >>> return groupId; > > >>> @@ -853,25 +857,25 @@ > > >>> > > >>> public void setArtifactId( String artifactId ) > > >>> { > > >>> - model.setArtifactId( artifactId ); > > >>> + getModel().setArtifactId( artifactId ); > > >>> } > > >>> > > >>> public String getArtifactId() > > >>> { > > >>> - return model.getArtifactId(); > > >>> + return getModel().getArtifactId(); > > >>> } > > >>> > > >>> public void setName( String name ) > > >>> { > > >>> - model.setName( name ); > > >>> + getModel().setName( name ); > > >>> } > > >>> > > >>> public String getName() > > >>> { > > >>> // TODO: this should not be allowed to be null. > > >>> - if ( model.getName() != null ) > > >>> + if ( getModel().getName() != null ) > > >>> { > > >>> - return model.getName(); > > >>> + return getModel().getName(); > > >>> } > > >>> else > > >>> { > > >>> @@ -881,16 +885,16 @@ > > >>> > > >>> public void setVersion( String version ) > > >>> { > > >>> - model.setVersion( version ); > > >>> + getModel().setVersion( version ); > > >>> } > > >>> > > >>> public String getVersion() > > >>> { > > >>> - String version = model.getVersion(); > > >>> - > > >>> - if ( version == null && model.getParent() != null ) > > >>> + String version = getModel().getVersion(); > > >>> + > > >>> + if ( ( version == null ) && ( getModel().getParent() != > > >>> null ) ) > > >>> { > > >>> - version = model.getParent().getVersion(); > > >>> + version = getModel().getParent().getVersion(); > > >>> } > > >>> > > >>> return version; > > >>> @@ -898,149 +902,149 @@ > > >>> > > >>> public String getPackaging() > > >>> { > > >>> - return model.getPackaging(); > > >>> + return getModel().getPackaging(); > > >>> } > > >>> > > >>> public void setPackaging( String packaging ) > > >>> { > > >>> - model.setPackaging( packaging ); > > >>> + getModel().setPackaging( packaging ); > > >>> } > > >>> > > >>> public void setInceptionYear( String inceptionYear ) > > >>> { > > >>> - model.setInceptionYear( inceptionYear ); > > >>> + getModel().setInceptionYear( inceptionYear ); > > >>> } > > >>> > > >>> public String getInceptionYear() > > >>> { > > >>> - return model.getInceptionYear(); > > >>> + return getModel().getInceptionYear(); > > >>> } > > >>> > > >>> public void setUrl( String url ) > > >>> { > > >>> - model.setUrl( url ); > > >>> + getModel().setUrl( url ); > > >>> } > > >>> > > >>> public String getUrl() > > >>> { > > >>> - return model.getUrl(); > > >>> + return getModel().getUrl(); > > >>> } > > >>> > > >>> public Prerequisites getPrerequisites() > > >>> { > > >>> - return model.getPrerequisites(); > > >>> + return getModel().getPrerequisites(); > > >>> } > > >>> > > >>> public void setIssueManagement( IssueManagement > issueManagement ) > > >>> { > > >>> - model.setIssueManagement( issueManagement ); > > >>> + getModel().setIssueManagement( issueManagement ); > > >>> } > > >>> > > >>> public CiManagement getCiManagement() > > >>> { > > >>> - return model.getCiManagement(); > > >>> + return getModel().getCiManagement(); > > >>> } > > >>> > > >>> public void setCiManagement( CiManagement ciManagement ) > > >>> { > > >>> - model.setCiManagement( ciManagement ); > > >>> + getModel().setCiManagement( ciManagement ); > > >>> } > > >>> > > >>> public IssueManagement getIssueManagement() > > >>> { > > >>> - return model.getIssueManagement(); > > >>> + return getModel().getIssueManagement(); > > >>> } > > >>> > > >>> public void setDistributionManagement( DistributionManagement > > >>> distributionManagement ) > > >>> { > > >>> - model.setDistributionManagement( distributionManagement > ); > > >>> + > > >>> getModel().setDistributionManagement( distributionManagement ); > > >>> } > > >>> > > >>> public DistributionManagement getDistributionManagement() > > >>> { > > >>> - return model.getDistributionManagement(); > > >>> + return getModel().getDistributionManagement(); > > >>> } > > >>> > > >>> public void setDescription( String description ) > > >>> { > > >>> - model.setDescription( description ); > > >>> + getModel().setDescription( description ); > > >>> } > > >>> > > >>> public String getDescription() > > >>> { > > >>> - return model.getDescription(); > > >>> + return getModel().getDescription(); > > >>> } > > >>> > > >>> public void setOrganization( Organization organization ) > > >>> { > > >>> - model.setOrganization( organization ); > > >>> + getModel().setOrganization( organization ); > > >>> } > > >>> > > >>> public Organization getOrganization() > > >>> { > > >>> - return model.getOrganization(); > > >>> + return getModel().getOrganization(); > > >>> } > > >>> > > >>> public void setScm( Scm scm ) > > >>> { > > >>> - model.setScm( scm ); > > >>> + getModel().setScm( scm ); > > >>> } > > >>> > > >>> public Scm getScm() > > >>> { > > >>> - return model.getScm(); > > >>> + return getModel().getScm(); > > >>> } > > >>> > > >>> public void setMailingLists( List mailingLists ) > > >>> { > > >>> - model.setMailingLists( mailingLists ); > > >>> + getModel().setMailingLists( mailingLists ); > > >>> } > > >>> > > >>> public List getMailingLists() > > >>> { > > >>> - return model.getMailingLists(); > > >>> + return getModel().getMailingLists(); > > >>> } > > >>> > > >>> public void addMailingList( MailingList mailingList ) > > >>> { > > >>> - model.addMailingList( mailingList ); > > >>> + getModel().addMailingList( mailingList ); > > >>> } > > >>> > > >>> public void setDevelopers( List developers ) > > >>> { > > >>> - model.setDevelopers( developers ); > > >>> + getModel().setDevelopers( developers ); > > >>> } > > >>> > > >>> public List getDevelopers() > > >>> { > > >>> - return model.getDevelopers(); > > >>> + return getModel().getDevelopers(); > > >>> } > > >>> > > >>> public void addDeveloper( Developer developer ) > > >>> { > > >>> - model.addDeveloper( developer ); > > >>> + getModel().addDeveloper( developer ); > > >>> } > > >>> > > >>> public void setContributors( List contributors ) > > >>> { > > >>> - model.setContributors( contributors ); > > >>> + getModel().setContributors( contributors ); > > >>> } > > >>> > > >>> public List getContributors() > > >>> { > > >>> - return model.getContributors(); > > >>> + return getModel().getContributors(); > > >>> } > > >>> > > >>> public void addContributor( Contributor contributor ) > > >>> { > > >>> - model.addContributor( contributor ); > > >>> + getModel().addContributor( contributor ); > > >>> } > > >>> > > >>> public void setBuild( Build build ) > > >>> { > > >>> this.buildOverlay = new BuildOverlay( build ); > > >>> > > >>> - model.setBuild( build ); > > >>> + getModel().setBuild( build ); > > >>> } > > >>> > > >>> public Build getBuild() > > >>> @@ -1075,27 +1079,27 @@ > > >>> > > >>> public void setReporting( Reporting reporting ) > > >>> { > > >>> - model.setReporting( reporting ); > > >>> + getModel().setReporting( reporting ); > > >>> } > > >>> > > >>> public Reporting getReporting() > > >>> { > > >>> - return model.getReporting(); > > >>> + return getModel().getReporting(); > > >>> } > > >>> > > >>> public void setLicenses( List licenses ) > > >>> { > > >>> - model.setLicenses( licenses ); > > >>> + getModel().setLicenses( licenses ); > > >>> } > > >>> > > >>> public List getLicenses() > > >>> { > > >>> - return model.getLicenses(); > > >>> + return getModel().getLicenses(); > > >>> } > > >>> > > >>> public void addLicense( License license ) > > >>> { > > >>> - model.addLicense( license ); > > >>> + getModel().addLicense( license ); > > >>> } > > >>> > > >>> public void setArtifacts( Set artifacts ) > > >>> @@ -1206,7 +1210,7 @@ > > >>> > > >>> public List getRepositories() > > >>> { > > >>> - return model.getRepositories(); > > >>> + return getModel().getRepositories(); > > >>> } > > >>> > > >>> // > > >>> > ---------------------------------------------------------------------- > > >>> @@ -1215,33 +1219,33 @@ > > >>> > > >>> public List getReportPlugins() > > >>> { > > >>> - if ( model.getReporting() == null ) > > >>> + if ( getModel().getReporting() == null ) > > >>> { > > >>> return null; > > >>> } > > >>> - return model.getReporting().getPlugins(); > > >>> + return getModel().getReporting().getPlugins(); > > >>> > > >>> } > > >>> > > >>> public List getBuildPlugins() > > >>> { > > >>> - if ( model.getBuild() == null ) > > >>> + if ( getModel().getBuild() == null ) > > >>> { > > >>> return null; > > >>> } > > >>> - return model.getBuild().getPlugins(); > > >>> + return getModel().getBuild().getPlugins(); > > >>> } > > >>> > > >>> public List getModules() > > >>> { > > >>> - return model.getModules(); > > >>> + return getModel().getModules(); > > >>> } > > >>> > > >>> public PluginManagement getPluginManagement() > > >>> { > > >>> PluginManagement pluginMgmt = null; > > >>> > > >>> - Build build = model.getBuild(); > > >>> + Build build = getModel().getBuild(); > > >>> if ( build != null ) > > >>> { > > >>> pluginMgmt = build.getPluginManagement(); > > >>> @@ -1252,13 +1256,13 @@ > > >>> > > >>> private Build getModelBuild() > > >>> { > > >>> - Build build = model.getBuild(); > > >>> + Build build = getModel().getBuild(); > > >>> > > >>> if ( build == null ) > > >>> { > > >>> build = new Build(); > > >>> > > >>> - model.setBuild( build ); > > >>> + getModel().setBuild( build ); > > >>> } > > >>> > > >>> return build; > > >>> @@ -1322,13 +1326,13 @@ > > >>> > > >>> public ArtifactRepository > > >>> getDistributionManagementArtifactRepository() > > >>> { > > >>> - return getArtifact().isSnapshot() && > > >>> snapshotArtifactRepository != null ? snapshotArtifactRepository > > >>> - : releaseArtifactRepository; > > >>> + return getArtifact().isSnapshot() && > > >>> ( getSnapshotArtifactRepository() != null ) ? > > >>> getSnapshotArtifactRepository() > > >>> + : getReleaseArtifactRepository(); > > >>> } > > >>> > > >>> public List getPluginRepositories() > > >>> { > > >>> - return model.getPluginRepositories(); > > >>> + return getModel().getPluginRepositories(); > > >>> } > > >>> > > >>> public void setActiveProfiles( List activeProfiles ) > > >>> @@ -1624,6 +1628,42 @@ > > >>> 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() ) > > >>> @@ -1743,6 +1783,14 @@ > > >>> } > > >>> > > >>> return sb.toString(); > > >>> + } > > >>> + > > >>> + /** > > >>> + * @since 2.0.9 > > >>> + */ > > >>> + public Object clone() > > >>> + { > > >>> + return new MavenProject( this ); > > >>> } > > >>> > > >>> } > > >>> > > >>> Modified: > maven/components/branches/maven-2.0.x/maven-project/src/ > > >>> test/java/org/apache/maven/project/MavenProjectTest.java > > >>> URL: > http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven > -project/src/test/java/org/apache/maven/project/MavenProjectTest.java?re > v=627675&r1=627674&r2=627675&view=diff > > >>> = > > >>> = > > >>> = > > >>> = > > >>> = > > >>> = > > >>> = > > >>> = > > >>> = > > >>> = > > >>> > ==================================================================== > > >>> --- maven/components/branches/maven-2.0.x/maven-project/src/test/ > > >>> java/org/apache/maven/project/MavenProjectTest.java (original) > > >>> +++ maven/components/branches/maven-2.0.x/maven-project/src/test/ > > >>> java/org/apache/maven/project/MavenProjectTest.java Wed Feb 13 > > >>> 22:40:35 2008 > > >>> @@ -21,15 +21,13 @@ > > >>> > > >>> import java.io.File; > > >>> import java.io.IOException; > > >>> -import java.util.Map; > > >>> -import java.util.Iterator; > > >>> import java.util.List; > > >>> +import java.util.Map; > > >>> > > >>> +import org.apache.maven.artifact.versioning.ManagedVersionMap; > > >>> +import org.apache.maven.model.DependencyManagement; > > >>> import org.apache.maven.model.Model; > > >>> import org.apache.maven.model.Parent; > > >>> -import org.apache.maven.model.DependencyManagement; > > >>> -import org.apache.maven.model.Dependency; > > >>> -import org.apache.maven.artifact.versioning.ManagedVersionMap; > > >>> > > >>> public class MavenProjectTest > > >>> extends AbstractMavenProjectTestCase > > >>> @@ -90,20 +88,20 @@ > > >>> + MavenProject.EMPTY_PROJECT_VERSION, > > >>> project.getId() ); > > >>> } > > >>> > > >>> - public void testCopyConstructor() > > >>> + public void testClone() > > >>> throws Exception > > >>> { > > >>> File f = getFileForClasspathResource( "canonical-pom.xml" > ); > > >>> MavenProject projectToClone = getProject( f ); > > >>> > > >>> - MavenProject clonedProject = new > > >>> MavenProject( projectToClone ); > > >>> + MavenProject clonedProject = (MavenProject) > > >>> projectToClone.clone(); > > >>> assertEquals( "maven-core", clonedProject.getArtifactId() > ); > > >>> Map clonedMap = clonedProject.getManagedVersionMap(); > > >>> assertNotNull("ManagedVersionMap not copied", clonedMap); > > >>> assertTrue("ManagedVersionMap is not empty", > > >>> clonedMap.isEmpty()); > > >>> } > > >>> > > >>> - public void testCopyConstructorWithDependencyManagement() > > >>> + public void testCloneWithDependencyManagement() > > >>> throws Exception > > >>> { > > >>> File f = getFileForClasspathResource( > "dependencyManagement- > > >>> pom.xml" ); > > >>> @@ -118,7 +116,7 @@ > > >>> assertNotNull("No ManagedVersionMap", map); > > >>> assertTrue("ManagedVersionMap is empty", !map.isEmpty()); > > >>> > > >>> - MavenProject clonedProject = new > > >>> MavenProject( projectToClone ); > > >>> + MavenProject clonedProject = (MavenProject) > > >>> projectToClone.clone(); > > >>> assertEquals( "maven-core", clonedProject.getArtifactId() > ); > > >>> Map clonedMap = clonedProject.getManagedVersionMap(); > > >>> assertNotNull("ManagedVersionMap not copied", clonedMap); > > >>> @@ -146,13 +144,13 @@ > > >>> assertEquals( "..", pathAdjustment ); > > >>> } > > >>> > > >>> - public void testCopyConstructorWithDistributionManagement() > > >>> throws Exception > > >>> + public void testCloneWithDistributionManagement() throws > > >>> Exception > > >>> { > > >>> > > >>> File f = > > >>> getFileForClasspathResource( "distributionManagement-pom.xml" ); > > >>> MavenProject projectToClone = getProject( f ); > > >>> > > >>> - MavenProject clonedProject = new > > >>> MavenProject( projectToClone ); > > >>> + MavenProject clonedProject = (MavenProject) > > >>> projectToClone.clone(); > > >>> assertNotNull( "clonedProject - distributionManagement", > > >>> clonedProject.getDistributionManagementArtifactRepository() ); > > >>> } > > >>> } > > >>> > > >>> > > >> > > >> -- > > >> Brett Porter > > >> [EMAIL PROTECTED] > > >> http://blogs.exist.com/bporter/ > > >> > > >> > > >> > --------------------------------------------------------------------- > > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > > >> For additional commands, e-mail: [EMAIL PROTECTED] > > >> > > >> > > > > > > > > > > > > -- > > > I could give you my word as a Spaniard. > > > No good. I've known too many Spaniards. > > > -- The Princess Bride > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > -- > > Brett Porter > > [EMAIL PROTECTED] > > http://blogs.exist.com/bporter/ > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > -- > I could give you my word as a Spaniard. > No good. I've known too many Spaniards. > -- The Princess Bride > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- I could give you my word as a Spaniard. No good. I've known too many Spaniards. -- The Princess Bride --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]