You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ep...@apache.org on 2006/09/04 11:31:57 UTC
svn commit: r439994 - in
/maven/continuum/branches/release-integration/continuum/continuum-release/src:
main/java/org/apache/maven/continuum/release/executors/
test/java/org/apache/maven/continuum/release/
test/java/org/apache/maven/continuum/release/e...
Author: epunzalan
Date: Mon Sep 4 02:31:56 2006
New Revision: 439994
URL: http://svn.apache.org/viewvc?view=rev&rev=439994
Log:
PR: CONTINUUM-727
adding missing classes
Added:
maven/continuum/branches/release-integration/continuum/continuum-release/src/main/java/org/apache/maven/continuum/release/executors/AbstractReleaseTaskExecutor.java (with props)
maven/continuum/branches/release-integration/continuum/continuum-release/src/main/java/org/apache/maven/continuum/release/executors/ReleaseTaskExecutor.java (with props)
maven/continuum/branches/release-integration/continuum/continuum-release/src/test/java/org/apache/maven/continuum/release/
maven/continuum/branches/release-integration/continuum/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/
maven/continuum/branches/release-integration/continuum/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/PrepareReleaseTaskExecutorTest.java (with props)
maven/continuum/branches/release-integration/continuum/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/PrepareReleaseTaskExecutorTest.xml (with props)
Added: maven/continuum/branches/release-integration/continuum/continuum-release/src/main/java/org/apache/maven/continuum/release/executors/AbstractReleaseTaskExecutor.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/release-integration/continuum/continuum-release/src/main/java/org/apache/maven/continuum/release/executors/AbstractReleaseTaskExecutor.java?view=auto&rev=439994
==============================================================================
--- maven/continuum/branches/release-integration/continuum/continuum-release/src/main/java/org/apache/maven/continuum/release/executors/AbstractReleaseTaskExecutor.java (added)
+++ maven/continuum/branches/release-integration/continuum/continuum-release/src/main/java/org/apache/maven/continuum/release/executors/AbstractReleaseTaskExecutor.java Mon Sep 4 02:31:56 2006
@@ -0,0 +1,198 @@
+package org.apache.maven.continuum.release.executors;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
+import org.apache.maven.continuum.release.ContinuumReleaseException;
+import org.apache.maven.continuum.release.ContinuumReleaseManager;
+import org.apache.maven.plugins.release.ReleaseManager;
+import org.apache.maven.plugins.release.config.ReleaseDescriptor;
+import org.apache.maven.profiles.DefaultProfileManager;
+import org.apache.maven.profiles.ProfileManager;
+import org.apache.maven.project.DuplicateProjectException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.project.ProjectSorter;
+import org.apache.maven.settings.MavenSettingsBuilder;
+import org.apache.maven.settings.Settings;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.taskqueue.execution.TaskExecutor;
+import org.codehaus.plexus.context.Context;
+import org.codehaus.plexus.context.ContextException;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+import org.codehaus.plexus.util.dag.CycleDetectedException;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @author Edwin Punzalan
+ */
+public abstract class AbstractReleaseTaskExecutor
+ implements ReleaseTaskExecutor, TaskExecutor, Contextualizable
+{
+ /**
+ * @plexus.requirement
+ */
+ protected ContinuumReleaseManager continuumReleaseManager;
+
+ /**
+ * @plexus.requirement
+ */
+ protected ReleaseManager releasePluginManager;
+
+ /**
+ * @plexus.requirement
+ */
+ private MavenProjectBuilder projectBuilder;
+
+ /**
+ * @plexus.requirement
+ */
+ private MavenSettingsBuilder settingsBuilder;
+
+ /**
+ * @plexus.configuration
+ */
+ private String localRepository;
+
+ private ProfileManager profileManager;
+
+ private PlexusContainer container;
+
+ private Settings settings;
+
+ protected List getReactorProjects( ReleaseDescriptor descriptor )
+ throws ContinuumReleaseException
+ {
+ Settings settings = getSettings();
+
+ List reactorProjects = new ArrayList();
+
+ MavenProject project;
+ try
+ {
+ project = projectBuilder.build( getProjectDescriptorFile( descriptor ),
+ getLocalRepository(), getProfileManager( settings ) );
+
+ reactorProjects.add( project );
+ }
+ catch ( ProjectBuildingException e )
+ {
+ throw new ContinuumReleaseException( "Failed to build project.", e );
+ }
+
+ for( Iterator modules = project.getModules().iterator(); modules.hasNext(); )
+ {
+ String moduleDir = modules.next().toString();
+
+ File pomFile = new File( project.getBasedir(), moduleDir + "/pom.xml" );
+
+ try
+ {
+ MavenProject reactorProject = projectBuilder.build( pomFile, getLocalRepository(),
+ getProfileManager( settings ) );
+
+ reactorProjects.add( reactorProject );
+ }
+ catch ( ProjectBuildingException e )
+ {
+ throw new ContinuumReleaseException( "Failed to build project.", e );
+ }
+ }
+
+ try
+ {
+ reactorProjects = new ProjectSorter( reactorProjects ).getSortedProjects();
+ }
+ catch ( CycleDetectedException e )
+ {
+ throw new ContinuumReleaseException( "Failed to sort projects.", e );
+ }
+ catch ( DuplicateProjectException e )
+ {
+ throw new ContinuumReleaseException( "Failed to sort projects.", e );
+ }
+
+ return reactorProjects;
+ }
+
+ protected Settings getSettings()
+ throws ContinuumReleaseException
+ {
+ if ( settings == null )
+ {
+ try
+ {
+ settings = settingsBuilder.buildSettings();
+ }
+ catch ( IOException e )
+ {
+ throw new ContinuumReleaseException( "Failed to get Maven Settings.", e );
+ }
+ catch ( XmlPullParserException e )
+ {
+ throw new ContinuumReleaseException( "Failed to get Maven Settings.", e );
+ }
+ }
+
+ return settings;
+ }
+
+ private File getProjectDescriptorFile( ReleaseDescriptor descriptor )
+ {
+ String parentPath = descriptor.getWorkingDirectory();
+
+ String pomFilename = descriptor.getPomFileName();
+ if ( pomFilename == null )
+ {
+ pomFilename = "pom.xml";
+ }
+
+ return new File( parentPath, pomFilename );
+ }
+
+ private ArtifactRepository getLocalRepository()
+ {
+ return new DefaultArtifactRepository( "local-repository", "file://" + localRepository,
+ new DefaultRepositoryLayout() );
+ }
+
+ private ProfileManager getProfileManager( Settings settings )
+ {
+ if ( profileManager == null )
+ {
+ profileManager = new DefaultProfileManager( container, settings );
+ }
+
+ return profileManager;
+ }
+
+ public void contextualize( Context context )
+ throws ContextException
+ {
+ container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
+ }
+}
Propchange: maven/continuum/branches/release-integration/continuum/continuum-release/src/main/java/org/apache/maven/continuum/release/executors/AbstractReleaseTaskExecutor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/continuum/branches/release-integration/continuum/continuum-release/src/main/java/org/apache/maven/continuum/release/executors/ReleaseTaskExecutor.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/release-integration/continuum/continuum-release/src/main/java/org/apache/maven/continuum/release/executors/ReleaseTaskExecutor.java?view=auto&rev=439994
==============================================================================
--- maven/continuum/branches/release-integration/continuum/continuum-release/src/main/java/org/apache/maven/continuum/release/executors/ReleaseTaskExecutor.java (added)
+++ maven/continuum/branches/release-integration/continuum/continuum-release/src/main/java/org/apache/maven/continuum/release/executors/ReleaseTaskExecutor.java Mon Sep 4 02:31:56 2006
@@ -0,0 +1,25 @@
+package org.apache.maven.continuum.release.executors;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * @author Edwin Punzalan
+ */
+public interface ReleaseTaskExecutor
+{
+ String ROLE = ReleaseTaskExecutor.class.getName();
+}
Propchange: maven/continuum/branches/release-integration/continuum/continuum-release/src/main/java/org/apache/maven/continuum/release/executors/ReleaseTaskExecutor.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/continuum/branches/release-integration/continuum/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/PrepareReleaseTaskExecutorTest.java
URL: http://svn.apache.org/viewvc/maven/continuum/branches/release-integration/continuum/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/PrepareReleaseTaskExecutorTest.java?view=auto&rev=439994
==============================================================================
--- maven/continuum/branches/release-integration/continuum/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/PrepareReleaseTaskExecutorTest.java (added)
+++ maven/continuum/branches/release-integration/continuum/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/PrepareReleaseTaskExecutorTest.java Mon Sep 4 02:31:56 2006
@@ -0,0 +1,55 @@
+package org.apache.maven.continuum.release.executors;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed 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.continuum.release.tasks.PrepareReleaseProjectTask;
+import org.apache.maven.plugins.release.config.ReleaseDescriptor;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.taskqueue.Task;
+import org.codehaus.plexus.taskqueue.execution.TaskExecutor;
+
+/**
+ * @author Edwin Punzalan
+ */
+public class PrepareReleaseTaskExecutorTest
+ extends PlexusTestCase
+{
+ private TaskExecutor taskExec;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ taskExec = (TaskExecutor) lookup( ReleaseTaskExecutor.ROLE, "prepare-release" );
+ }
+
+ public void testRelease()
+ throws Exception
+ {
+ ReleaseDescriptor descriptor = new ReleaseDescriptor();
+
+ taskExec.executeTask( getPrepareTask( "testRelease", descriptor ) );
+ }
+
+ protected Task getPrepareTask( String releaseId, ReleaseDescriptor descriptor )
+ {
+ Task task = new PrepareReleaseProjectTask( releaseId, descriptor );
+
+ return task;
+ }
+}
Propchange: maven/continuum/branches/release-integration/continuum/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/PrepareReleaseTaskExecutorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/continuum/branches/release-integration/continuum/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/PrepareReleaseTaskExecutorTest.xml
URL: http://svn.apache.org/viewvc/maven/continuum/branches/release-integration/continuum/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/PrepareReleaseTaskExecutorTest.xml?view=auto&rev=439994
==============================================================================
--- maven/continuum/branches/release-integration/continuum/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/PrepareReleaseTaskExecutorTest.xml (added)
+++ maven/continuum/branches/release-integration/continuum/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/PrepareReleaseTaskExecutorTest.xml Mon Sep 4 02:31:56 2006
@@ -0,0 +1,24 @@
+<components>
+<component>
+ <role>org.apache.maven.continuum.release.executors.ReleaseTaskExecutor</role>
+ <role-hint>prepare-release</role-hint>
+ <implementation>org.apache.maven.continuum.release.executors.PrepareReleaseTaskExecutor</implementation>
+ <requirements>
+ <requirement>
+ <role>org.apache.maven.continuum.release.ContinuumReleaseManager</role>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.plugins.release.ReleaseManager</role>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.project.MavenProjectBuilder</role>
+ </requirement>
+ <requirement>
+ <role>org.apache.maven.settings.MavenSettingsBuilder</role>
+ </requirement>
+ </requirements>
+ <configuration>
+ <local-repository>${plexus.home}/local-repository</local-repository>
+ </configuration>
+</component>
+</components>
\ No newline at end of file
Propchange: maven/continuum/branches/release-integration/continuum/continuum-release/src/test/java/org/apache/maven/continuum/release/executors/PrepareReleaseTaskExecutorTest.xml
------------------------------------------------------------------------------
svn:eol-style = native