From 74de0709deb6c40b1fce77256d9cc1cce9054483 Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Mon, 19 Sep 2005 21:24:40 +0000 Subject: [PATCH] Resolving: MNG-920, and setting the version of maven-release-plugin to a rev of -beta-1 instead of -SNAPSHOT, to allow locally installed versions to work without tweaking the version locally. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@290276 13f79535-47bb-0310-9956-ffa450edef68 --- .../it2002/project/subproject2/pom.xml | 12 + maven-plugins/maven-release-plugin/pom.xml | 2 +- maven-plugins/maven-surefire-plugin/pom.xml | 6 +- .../org/apache/maven/project/ModelUtils.java | 510 ++++++++++++++++++ 4 files changed, 526 insertions(+), 4 deletions(-) diff --git a/maven-core-it/it2002/project/subproject2/pom.xml b/maven-core-it/it2002/project/subproject2/pom.xml index b193c2940a..08a3f0e207 100644 --- a/maven-core-it/it2002/project/subproject2/pom.xml +++ b/maven-core-it/it2002/project/subproject2/pom.xml @@ -28,4 +28,16 @@ + + + env-test + + + env + test + + + + + diff --git a/maven-plugins/maven-release-plugin/pom.xml b/maven-plugins/maven-release-plugin/pom.xml index fc8031a09b..363e8e3e5a 100644 --- a/maven-plugins/maven-release-plugin/pom.xml +++ b/maven-plugins/maven-release-plugin/pom.xml @@ -8,7 +8,7 @@ maven-release-plugin maven-plugin Maven Release plugin - 2.0-beta-2-SNAPSHOT + 2.0-beta-1-rev1 org.apache.maven diff --git a/maven-plugins/maven-surefire-plugin/pom.xml b/maven-plugins/maven-surefire-plugin/pom.xml index fc71438e1d..db100deaa0 100644 --- a/maven-plugins/maven-surefire-plugin/pom.xml +++ b/maven-plugins/maven-surefire-plugin/pom.xml @@ -29,13 +29,13 @@ surefire surefire - 1.3 + 1.4-SNAPSHOT runtime surefire surefire-booter - 1.3 + 1.4-SNAPSHOT plexus @@ -44,4 +44,4 @@ runtime - \ No newline at end of file + diff --git a/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java b/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java index 9032f654ba..bfb2aece05 100644 --- a/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java +++ b/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java @@ -16,16 +16,32 @@ package org.apache.maven.project; * limitations under the License. */ +import org.apache.maven.model.Activation; +import org.apache.maven.model.ActivationFile; +import org.apache.maven.model.ActivationProperty; +import org.apache.maven.model.Build; +import org.apache.maven.model.BuildBase; +import org.apache.maven.model.Dependency; +import org.apache.maven.model.DependencyManagement; +import org.apache.maven.model.DistributionManagement; +import org.apache.maven.model.Exclusion; import org.apache.maven.model.Goal; import org.apache.maven.model.Model; import org.apache.maven.model.Parent; import org.apache.maven.model.Plugin; import org.apache.maven.model.PluginContainer; import org.apache.maven.model.PluginExecution; +import org.apache.maven.model.PluginManagement; +import org.apache.maven.model.Profile; +import org.apache.maven.model.Relocation; import org.apache.maven.model.ReportPlugin; import org.apache.maven.model.ReportSet; import org.apache.maven.model.Reporting; import org.apache.maven.model.Repository; +import org.apache.maven.model.RepositoryBase; +import org.apache.maven.model.RepositoryPolicy; +import org.apache.maven.model.Resource; +import org.apache.maven.model.Site; import org.apache.maven.project.inheritance.DefaultModelInheritanceAssembler; import org.apache.maven.project.inheritance.ModelInheritanceAssembler; import org.codehaus.plexus.util.xml.Xpp3Dom; @@ -470,11 +486,505 @@ public final class ModelUtils newModel.setGroupId( model.getGroupId() ); newModel.setPackaging( model.getPackaging() ); newModel.setModules( cloneModules( model.getModules() ) ); + + newModel.setProfiles( cloneProfiles( model.getProfiles() ) ); + assembler.copyModel( newModel, model ); return newModel; } + private static List cloneProfiles( List profiles ) + { + if ( profiles == null ) + { + return profiles; + } + + List newProfiles = new ArrayList( profiles.size() ); + + for ( Iterator it = profiles.iterator(); it.hasNext(); ) + { + Profile profile = (Profile) it.next(); + + Profile newProfile = new Profile(); + + newProfile.setId(profile.getId()); + + newProfile.setActivation( cloneProfileActivation( profile.getActivation() ) ); + + newProfile.setBuild( cloneProfileBuild( profile.getBuild() ) ); + + newProfile.setDependencies( cloneProfileDependencies( profile.getDependencies() ) ); + + DependencyManagement dm = profile.getDependencyManagement(); + + if ( dm != null ) + { + DependencyManagement newDM = new DependencyManagement(); + + newDM.setDependencies( cloneProfileDependencies( dm.getDependencies() ) ); + + newProfile.setDependencyManagement( newDM ); + } + + newProfile.setDistributionManagement( cloneProfileDistributionManagement( profile.getDistributionManagement() ) ); + + List modules = profile.getModules(); + + if ( modules != null && !modules.isEmpty() ) + { + newProfile.setModules( new ArrayList( modules ) ); + } + + newProfile.setPluginRepositories( cloneProfileRepositories( profile.getPluginRepositories() ) ); + + Properties props = profile.getProperties(); + + if ( props != null ) + { + newProfile.setProperties( new Properties( props ) ); + } + + newProfile.setReporting( cloneProfileReporting( profile.getReporting() ) ); + + newProfile.setReports( profile.getReports() ); + + newProfile.setRepositories( cloneProfileRepositories( profile.getRepositories() ) ); + + newProfile.setSource(profile.getSource() ); + + newProfiles.add( newProfile ); + } + + return newProfiles; + } + + private static Reporting cloneProfileReporting( Reporting reporting ) + { + Reporting newR = null; + + if ( reporting != null ) + { + newR = new Reporting(); + + newR.setOutputDirectory(reporting.getOutputDirectory()); + + List newP = null; + + List plugins = reporting.getPlugins(); + + if ( plugins != null ) + { + newP = new ArrayList( plugins.size() ); + + for ( Iterator it = plugins.iterator(); it.hasNext(); ) + { + ReportPlugin plugin = (ReportPlugin) it.next(); + + ReportPlugin newPlugin = new ReportPlugin(); + + newPlugin.setArtifactId(plugin.getArtifactId()); + newPlugin.setGroupId(plugin.getGroupId()); + newPlugin.setVersion(plugin.getVersion()); + newPlugin.setInherited(plugin.getInherited()); + newPlugin.setReportSets( cloneReportSets( plugin.getReportSets() ) ); + + // TODO: Implement deep-copy of configuration. + newPlugin.setConfiguration(plugin.getConfiguration()); + + newP.add( newPlugin ); + } + + newR.setPlugins(newP); + } + } + + return newR; + } + + private static List cloneReportSets( List sets ) + { + List newSets = null; + + if ( sets != null ) + { + newSets = new ArrayList( sets.size() ); + + for ( Iterator it = sets.iterator(); it.hasNext(); ) + { + ReportSet set = (ReportSet) it.next(); + + ReportSet newSet = new ReportSet(); + + // TODO: Deep-copy config. + newSet.setConfiguration(set.getConfiguration()); + + newSet.setId(set.getId()); + newSet.setInherited(set.getInherited()); + + newSet.setReports(new ArrayList( set.getReports() )); + + newSets.add( newSet ); + } + } + + return newSets; + } + + private static List cloneProfileRepositories( List repos ) + { + List newRepos = null; + + if ( repos != null ) + { + newRepos = new ArrayList( repos.size() ); + + for ( Iterator it = repos.iterator(); it.hasNext(); ) + { + Repository repo = (Repository) it.next(); + + Repository newRepo = new Repository(); + + newRepo.setChecksumPolicy(repo.getChecksumPolicy()); + newRepo.setId(repo.getId()); + newRepo.setLayout(repo.getLayout()); + newRepo.setName(repo.getName()); + newRepo.setSnapshotPolicy(repo.getSnapshotPolicy()); + + RepositoryPolicy releasePolicy = repo.getReleases(); + + if ( releasePolicy != null ) + { + RepositoryPolicy newPolicy = new RepositoryPolicy(); + newPolicy.setEnabled(releasePolicy.isEnabled()); + newPolicy.setChecksumPolicy(releasePolicy.getChecksumPolicy()); + newPolicy.setUpdatePolicy(releasePolicy.getUpdatePolicy()); + + newRepo.setReleases(newPolicy); + } + + RepositoryPolicy snapPolicy = repo.getSnapshots(); + + if ( snapPolicy != null ) + { + RepositoryPolicy newPolicy = new RepositoryPolicy(); + newPolicy.setEnabled(snapPolicy.isEnabled()); + newPolicy.setChecksumPolicy(snapPolicy.getChecksumPolicy()); + newPolicy.setUpdatePolicy(snapPolicy.getUpdatePolicy()); + + newRepo.setSnapshots(newPolicy); + } + + newRepo.setUrl(repo.getUrl()); + + newRepos.add( newRepo ); + } + } + + return newRepos; + } + + private static DistributionManagement cloneProfileDistributionManagement( DistributionManagement dm ) + { + DistributionManagement newDM = null; + + if ( dm != null ) + { + newDM = new DistributionManagement(); + + newDM.setDownloadUrl(dm.getDownloadUrl() ); + newDM.setStatus(dm.getStatus()); + + Relocation relocation = dm.getRelocation(); + + if ( relocation != null ) + { + Relocation newR = new Relocation(); + + newR.setArtifactId(relocation.getArtifactId()); + newR.setGroupId(relocation.getGroupId()); + newR.setMessage(relocation.getMessage()); + newR.setVersion(relocation.getVersion()); + + newDM.setRelocation(newR); + } + + RepositoryBase repo = dm.getRepository(); + + if ( repo != null ) + { + RepositoryBase newRepo = new RepositoryBase(); + + newRepo.setId(repo.getId()); + newRepo.setLayout(repo.getLayout()); + newRepo.setName(repo.getName()); + newRepo.setUrl(repo.getUrl()); + + newDM.setRepository(newRepo); + } + + Site site = dm.getSite(); + + if ( site != null ) + { + Site newSite = new Site(); + + newSite.setId(site.getId()); + newSite.setName(site.getName()); + newSite.setUrl(site.getUrl()); + + newDM.setSite(newSite); + } + + RepositoryBase sRepo = dm.getSnapshotRepository(); + + if ( sRepo != null ) + { + RepositoryBase newRepo = new RepositoryBase(); + + newRepo.setId(sRepo.getId()); + newRepo.setLayout(sRepo.getLayout()); + newRepo.setName(sRepo.getName()); + newRepo.setUrl(sRepo.getUrl()); + + newDM.setSnapshotRepository(newRepo); + } + } + + return newDM; + } + + private static List cloneProfileDependencies( List dependencies ) + { + List newDependencies = null; + + if ( dependencies != null ) + { + newDependencies = new ArrayList( dependencies.size() ); + + for ( Iterator it = dependencies.iterator(); it.hasNext(); ) + { + Dependency dep = (Dependency) it.next(); + + Dependency newDep = new Dependency(); + + newDep.setArtifactId(dep.getArtifactId()); + newDep.setClassifier(dep.getClassifier()); + newDep.setExclusions( cloneDependencyExclusions( dep.getExclusions() ) ); + newDep.setGroupId(dep.getGroupId()); + newDep.setScope(dep.getScope()); + newDep.setSystemPath(dep.getSystemPath()); + newDep.setType(dep.getType()); + newDep.setVersion(dep.getVersion()); + + newDependencies.add( newDep ); + } + } + + return newDependencies; + } + + private static List cloneDependencyExclusions( List ex ) + { + List newEx = null; + + if ( ex != null ) + { + newEx = new ArrayList( ex.size() ); + + for ( Iterator it = ex.iterator(); it.hasNext(); ) + { + Exclusion exclusion = (Exclusion) it.next(); + + Exclusion newExclusion = new Exclusion(); + + newExclusion.setArtifactId(exclusion.getArtifactId() ); + newExclusion.setGroupId( exclusion.getGroupId() ); + + newEx.add( newExclusion ); + } + } + + return newEx; + } + + private static BuildBase cloneProfileBuild( BuildBase build ) + { + BuildBase newBuild = null; + if ( build != null ) + { + newBuild = new BuildBase(); + + newBuild.setDefaultGoal(build.getDefaultGoal()); + newBuild.setDirectory(build.getDirectory()); + newBuild.setFinalName(build.getFinalName()); + + newBuild.setPluginManagement( cloneProfilePluginManagement( build.getPluginManagement() ) ); + newBuild.setPlugins( cloneProfilePlugins( build.getPlugins() ) ); + newBuild.setResources( cloneProfileResources( build.getResources() ) ); + newBuild.setTestResources( cloneProfileResources( build.getTestResources() ) ); + } + + return newBuild; + } + + private static List cloneProfileResources( List resources ) + { + List newResources = null; + + if ( resources != null ) + { + newResources = new ArrayList( resources.size() ); + + for ( Iterator it = resources.iterator(); it.hasNext(); ) + { + Resource resource = (Resource) it.next(); + + Resource newResource = new Resource(); + + newResource.setDirectory(resource.getDirectory()); + newResource.setExcludes(new ArrayList( resource.getExcludes())); + newResource.setFiltering(resource.isFiltering()); + newResource.setIncludes(new ArrayList( resource.getIncludes())); + newResource.setTargetPath(resource.getTargetPath()); + + newResources.add( newResource ); + } + } + + return newResources; + } + + private static PluginManagement cloneProfilePluginManagement( PluginManagement pluginManagement ) + { + PluginManagement newPM = null; + + if ( pluginManagement != null ) + { + newPM = new PluginManagement(); + + List plugins = pluginManagement.getPlugins(); + + newPM.setPlugins( cloneProfilePlugins( plugins ) ); + } + + return newPM; + } + + private static List cloneProfilePlugins( List plugins ) + { + List newPlugins = null; + + if ( plugins != null ) + { + newPlugins = new ArrayList( plugins.size() ); + + for ( Iterator it = plugins.iterator(); it.hasNext(); ) + { + Plugin plugin = (Plugin) it.next(); + + Plugin newPlugin = new Plugin(); + + newPlugin.setArtifactId(plugin.getArtifactId()); + newPlugin.setExtensions(plugin.isExtensions()); + newPlugin.setGroupId(plugin.getGroupId()); + newPlugin.setInherited(plugin.getInherited()); + newPlugin.setVersion(plugin.getVersion()); + + // TODO: Deep-copy this! + newPlugin.setConfiguration(plugin.getConfiguration()); + + List goals = plugin.getGoals(); + if ( goals != null && !goals.isEmpty() ) + { + List newGoals = new ArrayList( goals ); + + newPlugin.setGoals(newGoals); + } + + newPlugin.setExecutions( cloneExecutions( plugin.getExecutions() )); + + newPlugins.add( newPlugin ); + } + } + + return newPlugins; + } + + private static List cloneExecutions( List executions ) + { + List newExecs = null; + + if ( executions != null ) + { + newExecs = new ArrayList( executions.size() ); + + for ( Iterator it = executions.iterator(); it.hasNext(); ) + { + PluginExecution exec = (PluginExecution) it.next(); + + PluginExecution newExec = new PluginExecution(); + + // TODO: Deep-copy configs. + newExec.setConfiguration(exec.getConfiguration()); + + newExec.setId(exec.getId()); + newExec.setInherited(exec.getInherited()); + newExec.setPhase(exec.getPhase()); + + List goals = exec.getGoals(); + + if ( goals != null && !goals.isEmpty() ) + { + newExec.setGoals( new ArrayList( goals ) ); + } + + newExecs.add( newExec ); + } + } + + return newExecs; + } + + private static Activation cloneProfileActivation( Activation activation ) + { + Activation newActivation = null; + if ( activation != null ) + { + newActivation = new Activation(); + + newActivation.setActiveByDefault(activation.isActiveByDefault()); + + ActivationFile af = activation.getFile(); + + if ( af != null ) + { + ActivationFile afNew = new ActivationFile(); + afNew.setExists(af.getExists()); + afNew.setMissing(af.getMissing()); + + newActivation.setFile(afNew); + } + + newActivation.setJdk(activation.getJdk()); + + ActivationProperty ap = activation.getProperty(); + + if ( ap != null ) + { + ActivationProperty newAp = new ActivationProperty(); + + newAp.setName(ap.getName()); + newAp.setValue(ap.getValue()); + + newActivation.setProperty(newAp); + } + } + + return newActivation; + } + private static List cloneModules( List modules ) { if ( modules == null )