Author: ctan Date: Sun Mar 8 14:41:33 2009 New Revision: 751433 URL: http://svn.apache.org/viewvc?rev=751433&view=rev Log: [CONTINUUM-2043] release prepare and release perform on build agent TODO: - UI - Release Rollback Added: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/release/ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/release/distributed/ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/release/distributed/manager/ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/release/distributed/manager/DistributedReleaseManager.java (with props) continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/DefaultShellCommandHelper.java (with props) continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/ExecutionResult.java (with props) continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/ShellCommandHelper.java (with props) continuum/trunk/continuum-api/src/main/resources/ continuum/trunk/continuum-api/src/main/resources/META-INF/ continuum/trunk/continuum-api/src/main/resources/META-INF/spring-context.xml (with props) continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/CreateBuildProjectTaskAction.java (with props) continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentReleaseManager.java (with props) continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentReleaseManager.java (with props) continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/PrepareBuildProjectsTask.java (with props) continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/PrepareBuildProjectsTaskExecutor.java (with props) continuum/trunk/continuum-core/src/main/java/org/apache/continuum/release/ continuum/trunk/continuum-core/src/main/java/org/apache/continuum/release/distributed/ continuum/trunk/continuum-core/src/main/java/org/apache/continuum/release/distributed/DistributedReleaseUtil.java (with props) continuum/trunk/continuum-core/src/main/java/org/apache/continuum/release/distributed/manager/ continuum/trunk/continuum-core/src/main/java/org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManager.java (with props) continuum/trunk/continuum-release/src/main/mdo/ continuum/trunk/continuum-release/src/main/mdo/prepared-releases.mdo continuum/trunk/continuum-webapp/src/main/java/org/apache/continuum/web/action/AbstractReleaseAction.java (with props) Removed: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/shell/ continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/utils/shell/ Modified: continuum/trunk/continuum-api/pom.xml continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/release/ContinuumReleaseManager.java continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.java continuum/trunk/continuum-buildagent/continuum-buildagent-core/pom.xml continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateWorkingDirectoryAction.java continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/AbstractBuildExecutor.java continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/DefaultBuildAgentMavenOneMetadataHelper.java continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/manager/BuildContextManager.java continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/manager/DefaultBuildContextManager.java continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/installation/DefaultBuildAgentInstallationService.java continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentManager.java continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/DefaultBuildAgentManager.java continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/execution/BuildProjectTaskExecutor.java continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/manager/BuildAgentTaskQueueManager.java continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/taskqueue/manager/DefaultBuildAgentTaskQueueManager.java continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/utils/ContinuumBuildAgentUtil.java continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/resources/META-INF/plexus/components.xml continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/resources/META-INF/spring-context.xml continuum/trunk/continuum-buildagent/continuum-buildagent-webapp/src/main/java/org/apache/continuum/web/startup/BuildAgentStartup.java continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/distributed/executor/DistributedBuildProjectTaskExecutor.java continuum/trunk/continuum-builder/src/main/java/org/apache/continuum/builder/utils/ContinuumBuildConstant.java continuum/trunk/continuum-core/src/main/java/org/apache/continuum/builder/distributed/manager/DefaultDistributedBuildManager.java continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/scm/queue/PrepareBuildProjectsTaskExecutor.java continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-api/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportService.java continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-client/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportClient.java continuum/trunk/continuum-distributed/continuum-distributed-slave/continuum-distributed-slave-server/src/main/java/org/apache/continuum/distributed/transport/slave/SlaveBuildAgentTransportServer.java continuum/trunk/continuum-release/pom.xml continuum/trunk/continuum-release/src/main/java/org/apache/continuum/release/config/ContinuumReleaseDescriptor.java continuum/trunk/continuum-release/src/main/java/org/apache/continuum/release/phase/AbstractContinuumRunGoalsPhase.java continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/DefaultContinuumReleaseManager.java continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/tasks/AbstractReleaseProjectTask.java continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/tasks/PerformReleaseProjectTask.java continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/tasks/PrepareReleaseProjectTask.java continuum/trunk/continuum-release/src/main/java/org/apache/maven/continuum/release/tasks/RollbackReleaseProjectTask.java continuum/trunk/continuum-release/src/main/resources/META-INF/plexus/components.xml continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleaseCleanupAction.java continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleaseInProgressAction.java continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePerformAction.java continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleasePrepareAction.java continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleaseProjectAction.java continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleaseProjectGoalAction.java continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/ReleaseRollbackAction.java continuum/trunk/continuum-webapp/src/main/mdo/view-models.mdo continuum/trunk/continuum-webapp/src/main/resources/localization/Continuum.properties continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/releaseFinished.jsp continuum/trunk/continuum-webapp/src/main/webapp/WEB-INF/jsp/releaseInProgress.jsp Modified: continuum/trunk/continuum-api/pom.xml URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/pom.xml?rev=751433&r1=751432&r2=751433&view=diff ============================================================================== --- continuum/trunk/continuum-api/pom.xml (original) +++ continuum/trunk/continuum-api/pom.xml Sun Mar 8 14:41:33 2009 @@ -64,6 +64,17 @@ org.apache.archiva archiva-repository-layer ${archiva.version} + + + org.apache.maven.release + maven-release-manager + 1.0-alpha-3 + + + org.codehaus.plexus + plexus-container-default + + Added: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/release/distributed/manager/DistributedReleaseManager.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/release/distributed/manager/DistributedReleaseManager.java?rev=751433&view=auto ============================================================================== --- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/release/distributed/manager/DistributedReleaseManager.java (added) +++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/release/distributed/manager/DistributedReleaseManager.java Sun Mar 8 14:41:33 2009 @@ -0,0 +1,67 @@ +package org.apache.continuum.release.distributed.manager; + +/* + * 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 java.util.List; +import java.util.Map; +import java.util.Properties; + +import org.apache.continuum.model.repository.LocalRepository; +import org.apache.maven.continuum.model.project.Project; +import org.apache.maven.continuum.release.ContinuumReleaseException; +import org.apache.maven.shared.release.ReleaseResult; + +public interface DistributedReleaseManager +{ + Map getReleasePluginParameters( int projectId, String pomFilename ) + throws ContinuumReleaseException; + + List> processProject( int projectId, String pomFilename, boolean autoVersionSubmodules ) + throws ContinuumReleaseException; + + String releasePrepare( Project project, Properties releaseProperties, Map releaseVersion, + Map developmentVersion, Map environments ) + throws ContinuumReleaseException; + + ReleaseResult getReleaseResult( String releaseId ) + throws ContinuumReleaseException; + + Map getListener( String releaseId ) + throws ContinuumReleaseException; + + void removeListener( String releaseId ) + throws ContinuumReleaseException; + + String getPreparedReleaseName( String releaseId ) + throws ContinuumReleaseException; + + void releasePerform( String releaseId, String goals, String arguments, boolean useReleaseProfile, LocalRepository repository ) + throws ContinuumReleaseException; + + void releasePerformFromScm( int projectId, String goals, String arguments, boolean useReleaseProfile, LocalRepository repository, + String scmUrl, String scmUsername, String scmPassword, String scmTag, String scmTagBase, Map environments ) + throws ContinuumReleaseException; + + void releaseRollback( String releaseId, int projectId ) + throws ContinuumReleaseException; + + String releaseCleanup( String releaseId ) + throws ContinuumReleaseException; +} \ No newline at end of file Propchange: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/release/distributed/manager/DistributedReleaseManager.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/release/distributed/manager/DistributedReleaseManager.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/DefaultShellCommandHelper.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/DefaultShellCommandHelper.java?rev=751433&view=auto ============================================================================== --- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/DefaultShellCommandHelper.java (added) +++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/DefaultShellCommandHelper.java Sun Mar 8 14:41:33 2009 @@ -0,0 +1,232 @@ +package org.apache.continuum.utils.shell; + +/* + * 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 java.io.File; +import java.io.FileWriter; +import java.io.Writer; +import java.util.Arrays; +import java.util.Iterator; +import java.util.Map; + +import org.apache.maven.shared.release.ReleaseResult; +import org.apache.maven.shared.release.exec.MavenExecutorException; +import org.apache.maven.shared.release.exec.TeeConsumer; +import org.codehaus.plexus.util.StringUtils; +import org.codehaus.plexus.util.cli.CommandLineException; +import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.cli.Commandline; +import org.codehaus.plexus.util.cli.StreamConsumer; +import org.codehaus.plexus.util.cli.WriterStreamConsumer; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +/** + * @author Trygve Laugstøl + * @version $Id$ + */ +@Service("shellCommandHelper") +public class DefaultShellCommandHelper + implements ShellCommandHelper +{ + private Logger log = LoggerFactory.getLogger( DefaultShellCommandHelper.class ); + + // ---------------------------------------------------------------------- + // ShellCommandHelper Implementation + // ---------------------------------------------------------------------- + + public ExecutionResult executeShellCommand( File workingDirectory, String executable, String arguments, File output, + long idCommand, Map environments ) + throws Exception + { + Commandline cl = new Commandline(); + + Commandline.Argument argument = cl.createArgument(); + + argument.setLine( arguments ); + + return executeShellCommand( workingDirectory, executable, argument.getParts(), output, idCommand, + environments ); + } + + /** + * Make the command line + * + * @param workingDirectory + * @param executable + * @param arguments + * @param idCommand + * @param environments + * @return + * @throws Exception + */ + protected Commandline createCommandline( File workingDirectory, String executable, String[] arguments, + long idCommand, Map environments ) + throws Exception + { + Commandline cl = new Commandline(); + + cl.setPid( idCommand ); + + cl.addEnvironment( "MAVEN_TERMINATE_CMD", "on" ); + + if ( environments != null && !environments.isEmpty() ) + { + for ( Iterator iterator = environments.keySet().iterator(); iterator.hasNext(); ) + { + String key = iterator.next(); + String value = environments.get( key ); + cl.addEnvironment( key, value ); + } + } + + cl.addSystemEnvironment(); + + cl.setExecutable( executable ); + + cl.setWorkingDirectory( workingDirectory.getAbsolutePath() ); + + if ( arguments != null ) + { + for ( int i = 0; i < arguments.length; i++ ) + { + String argument = arguments[i]; + + cl.createArgument().setValue( argument ); + } + } + + return cl; + } + + public ExecutionResult executeShellCommand( File workingDirectory, String executable, String[] arguments, + File output, long idCommand, Map environments ) + throws Exception + { + + Commandline cl = createCommandline( workingDirectory, executable, arguments, idCommand, environments ); + + log.info( "Executing: " + cl ); + log.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); + log.debug( "EnvironmentVariables " + Arrays.asList( cl.getEnvironmentVariables() ) ); + + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + + //CommandLineUtils.StringStreamConsumer consumer = new CommandLineUtils.StringStreamConsumer(); + + Writer writer = new FileWriter( output ); + + StreamConsumer consumer = new WriterStreamConsumer( writer ); + + int exitCode = CommandLineUtils.executeCommandLine( cl, consumer, consumer ); + + writer.flush(); + + writer.close(); + + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + + return new ExecutionResult( exitCode ); + } + + public boolean isRunning( long idCommand ) + { + return CommandLineUtils.isAlive( idCommand ); + } + + public void killProcess( long idCommand ) + { + CommandLineUtils.killProcess( idCommand ); + } + + public void executeGoals( File workingDirectory, String executable, String goals, boolean interactive, String arguments, + ReleaseResult relResult, Map environments ) + throws Exception + { + Commandline cl = new Commandline(); + + Commandline.Argument argument = cl.createArgument(); + + argument.setLine( arguments ); + + executeGoals( workingDirectory, executable, goals, interactive, argument.getParts(), relResult, environments ); + } + + public void executeGoals( File workingDirectory, String executable, String goals, boolean interactive, String[] arguments, + ReleaseResult relResult, Map environments ) + throws Exception + { + if ( executable == null ) + { + executable = "mvn"; + } + + Commandline cl = createCommandline( workingDirectory, executable, arguments, -1, environments ); + + if ( goals != null ) + { + // accept both space and comma, so the old way still work + String[] tokens = StringUtils.split( goals, ", " ); + + for ( int i = 0; i < tokens.length; ++i ) + { + cl.createArgument().setValue( tokens[i] ); + } + } + + cl.createArgument().setValue( "--no-plugin-updates" ); + + if ( !interactive ) + { + cl.createArgument().setValue( "--batch-mode" ); + } + + StreamConsumer stdOut = new TeeConsumer( System.out ); + + StreamConsumer stdErr = new TeeConsumer( System.err ); + + try + { + relResult.appendInfo( "Executing: " + cl.toString() ); + log.info( "Executing: " + cl.toString() ); + + int result = CommandLineUtils.executeCommandLine( cl, stdOut, stdErr ); + + if ( result != 0 ) + { + throw new MavenExecutorException( "Maven execution failed, exit code: \'" + result + "\'", result, + stdOut.toString(), stdErr.toString() ); + } + } + catch ( CommandLineException e ) + { + throw new MavenExecutorException( "Can't run goal " + goals, stdOut.toString(), stdErr.toString(), e ); + } + finally + { + relResult.appendOutput( stdOut.toString() ); + } + } +} Propchange: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/DefaultShellCommandHelper.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/DefaultShellCommandHelper.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/ExecutionResult.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/ExecutionResult.java?rev=751433&view=auto ============================================================================== --- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/ExecutionResult.java (added) +++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/ExecutionResult.java Sun Mar 8 14:41:33 2009 @@ -0,0 +1,39 @@ +package org.apache.continuum.utils.shell; + +/* + * 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. + */ + +/** + * @author Trygve Laugstøl + * @version $Id$ + */ +public class ExecutionResult +{ + private int exitCode; + + public ExecutionResult( int exitCode ) + { + this.exitCode = exitCode; + } + + public int getExitCode() + { + return exitCode; + } +} Propchange: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/ExecutionResult.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/ExecutionResult.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/ShellCommandHelper.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/ShellCommandHelper.java?rev=751433&view=auto ============================================================================== --- continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/ShellCommandHelper.java (added) +++ continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/ShellCommandHelper.java Sun Mar 8 14:41:33 2009 @@ -0,0 +1,55 @@ +package org.apache.continuum.utils.shell; + +/* + * 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 java.io.File; +import java.util.Map; + +import org.apache.continuum.utils.shell.ExecutionResult; +import org.apache.maven.shared.release.ReleaseResult; + +/** + * @author Trygve Laugstøl + * @version $Id$ + */ +public interface ShellCommandHelper +{ + String ROLE = ShellCommandHelper.class.getName(); + + ExecutionResult executeShellCommand( File workingDirectory, String executable, String arguments, File output, + long idCommand, Map environments ) + throws Exception; + + ExecutionResult executeShellCommand( File workingDirectory, String executable, String[] arguments, File output, + long idCommand, Map environments ) + throws Exception; + + boolean isRunning( long idCommand ); + + void killProcess( long idCommand ); + + void executeGoals( File workingDirectory, String executable, String goals, boolean interactive, String arguments, + ReleaseResult relResult, Map environments ) + throws Exception; + + void executeGoals( File workingDirectory, String executable, String goals, boolean interactive, String[] arguments, + ReleaseResult relResult, Map environments ) + throws Exception; +} Propchange: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/ShellCommandHelper.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: continuum/trunk/continuum-api/src/main/java/org/apache/continuum/utils/shell/ShellCommandHelper.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java?rev=751433&r1=751432&r2=751433&view=diff ============================================================================== --- continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java (original) +++ continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/Continuum.java Sun Mar 8 14:41:33 2009 @@ -30,6 +30,7 @@ import org.apache.continuum.model.project.ProjectScmRoot; import org.apache.continuum.purge.ContinuumPurgeManager; import org.apache.continuum.purge.PurgeConfigurationService; +import org.apache.continuum.release.distributed.manager.DistributedReleaseManager; import org.apache.continuum.repository.RepositoryService; import org.apache.continuum.taskqueue.manager.TaskQueueManager; import org.apache.maven.continuum.builddefinition.BuildDefinitionService; @@ -680,4 +681,6 @@ throws ContinuumException; DistributedBuildManager getDistributedBuildManager(); + + DistributedReleaseManager getDistributedReleaseManager(); } Modified: continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/release/ContinuumReleaseManager.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/release/ContinuumReleaseManager.java?rev=751433&r1=751432&r2=751433&view=diff ============================================================================== --- continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/release/ContinuumReleaseManager.java (original) +++ continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/release/ContinuumReleaseManager.java Sun Mar 8 14:41:33 2009 @@ -46,11 +46,13 @@ * @param releaseVersions * @param developmentVersions * @param listener + * @param workingDirectory * @return * @throws ContinuumReleaseException */ String prepare( Project project, Properties releaseProperties, Map releaseVersions, - Map developmentVersions, ContinuumReleaseManagerListener listener ) + Map developmentVersions, ContinuumReleaseManagerListener listener, + String workingDirectory ) throws ContinuumReleaseException; /** @@ -61,12 +63,15 @@ * @param releaseVersions * @param developmentVersions * @param listener - * @param profile + * @param workingDirectory + * @param environments + * @param executable * @return * @throws ContinuumReleaseException */ String prepare( Project project, Properties releaseProperties, Map releaseVersions, - Map developmentVersions, ContinuumReleaseManagerListener listener, Profile profile ) + Map developmentVersions, ContinuumReleaseManagerListener listener, + String workingDirectory, Map environments, String executable ) throws ContinuumReleaseException; /** @@ -118,8 +123,6 @@ ContinuumReleaseManagerListener listener, LocalRepository repository ) throws ContinuumReleaseException; - Map getEnvironments( Profile profile ); - /** * Clean up the tagname to respect the scm provider policy. * Added: continuum/trunk/continuum-api/src/main/resources/META-INF/spring-context.xml URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-api/src/main/resources/META-INF/spring-context.xml?rev=751433&view=auto ============================================================================== --- continuum/trunk/continuum-api/src/main/resources/META-INF/spring-context.xml (added) +++ continuum/trunk/continuum-api/src/main/resources/META-INF/spring-context.xml Sun Mar 8 14:41:33 2009 @@ -0,0 +1,36 @@ + + + + + + + + + + \ No newline at end of file Propchange: continuum/trunk/continuum-api/src/main/resources/META-INF/spring-context.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: continuum/trunk/continuum-api/src/main/resources/META-INF/spring-context.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.java?rev=751433&r1=751432&r2=751433&view=diff ============================================================================== --- continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.java (original) +++ continuum/trunk/continuum-buildagent/continuum-buildagent-api/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentService.java Sun Mar 8 14:41:33 2009 @@ -44,4 +44,35 @@ String getProjectFileContent( int projectId, String directory, String filename ) throws ContinuumBuildAgentException; + + Map getReleasePluginParameters( int projectId, String pomFilename ) + throws ContinuumBuildAgentException; + + List> processProject( int projectId, String pomFilename, boolean autoVersionSubmodules ) + throws ContinuumBuildAgentException; + + String releasePrepare( Map project, Map properties, Map releaseVersion, Map developmentVersion, Map environments ) + throws ContinuumBuildAgentException; + + Map getReleaseResult( String releaseId ) + throws ContinuumBuildAgentException; + + Map getListener( String releaseId ) + throws ContinuumBuildAgentException; + + void removeListener( String releaseId ) + throws ContinuumBuildAgentException; + + String getPreparedReleaseName( String releaseId ) + throws ContinuumBuildAgentException; + + void releasePerform( String releaseId, String goals, String arguments, boolean useReleaseProfile, Map repository ) + throws ContinuumBuildAgentException; + + void releasePerformFromScm( String goals, String arguments, boolean useReleaseProfile, Map repository, String scmUrl, String scmUsername, + String scmPassword, String scmTag, String scmTagBase, Map environments ) + throws ContinuumBuildAgentException; + + String releaseCleanup( String releaseId ) + throws ContinuumBuildAgentException; } Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/pom.xml URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/pom.xml?rev=751433&r1=751432&r2=751433&view=diff ============================================================================== --- continuum/trunk/continuum-buildagent/continuum-buildagent-core/pom.xml (original) +++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/pom.xml Sun Mar 8 14:41:33 2009 @@ -36,7 +36,11 @@ org.apache.continuum - continuum-api + continuum-scm + + + org.apache.continuum + continuum-release org.apache.archiva @@ -50,10 +54,6 @@ org.apache.continuum - continuum-scm - - - org.apache.continuum continuum-distributed-master-client Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java?rev=751433&r1=751432&r2=751433&view=diff ============================================================================== --- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java (original) +++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/ContinuumBuildAgentServiceImpl.java Sun Mar 8 14:41:33 2009 @@ -20,9 +20,11 @@ */ import java.io.File; +import java.io.FileReader; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.regex.Matcher; @@ -32,8 +34,9 @@ import org.apache.continuum.buildagent.buildcontext.BuildContext; import org.apache.continuum.buildagent.buildcontext.manager.BuildContextManager; import org.apache.continuum.buildagent.configuration.BuildAgentConfigurationService; -import org.apache.continuum.buildagent.manager.BuildAgentManager; +import org.apache.continuum.buildagent.manager.BuildAgentReleaseManager; import org.apache.continuum.buildagent.model.Installation; +import org.apache.continuum.buildagent.taskqueue.PrepareBuildProjectsTask; import org.apache.continuum.buildagent.taskqueue.manager.BuildAgentTaskQueueManager; import org.apache.continuum.buildagent.utils.ContinuumBuildAgentUtil; import org.apache.continuum.buildagent.utils.WorkingCopyContentGenerator; @@ -44,8 +47,17 @@ import org.apache.maven.continuum.model.scm.ChangeSet; import org.apache.maven.continuum.model.scm.ScmResult; import org.apache.maven.continuum.project.ContinuumProjectState; +import org.apache.maven.continuum.release.ContinuumReleaseException; +import org.apache.maven.model.Model; +import org.apache.maven.model.Plugin; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.apache.maven.shared.release.ReleaseResult; +import org.apache.maven.shared.release.versions.DefaultVersionInfo; +import org.apache.maven.shared.release.versions.VersionInfo; +import org.codehaus.plexus.taskqueue.TaskQueueException; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; +import org.codehaus.plexus.util.xml.Xpp3Dom; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,36 +77,44 @@ /** * @plexus.requirement */ - private BuildAgentManager buildAgentManager; + private BuildAgentTaskQueueManager buildAgentTaskQueueManager; /** * @plexus.requirement */ - private BuildAgentTaskQueueManager buildAgentTaskQueueManager; + private BuildContextManager buildContextManager; /** * @plexus.requirement */ - private BuildContextManager buildContextManager; + private WorkingCopyContentGenerator generator; /** * @plexus.requirement */ - private WorkingCopyContentGenerator generator; + private BuildAgentReleaseManager buildAgentReleaseManager; public void buildProjects( List projectsBuildContext ) throws ContinuumBuildAgentException { List buildContextList = initializeBuildContext( projectsBuildContext ); + PrepareBuildProjectsTask task = createPrepareBuildProjectsTask( buildContextList ); + + if ( task == null ) + { + return; + } + try { - buildAgentManager.prepareBuildProjects( buildContextList ); + buildAgentTaskQueueManager.getPrepareBuildQueue().put( task ); } - catch ( ContinuumException e ) + catch ( TaskQueueException e ) { - throw new ContinuumBuildAgentException( e.getMessage(), e ); + throw new ContinuumBuildAgentException( "Error while enqueuing projects", e ); } + } public List getAvailableInstallations() @@ -169,11 +189,11 @@ { if ( buildResult.getStartTime() <= 0 ) { - result.put( ContinuumBuildAgentUtil.KEY_BUILD_START, new Long( buildContext.getBuildStartTime() ).toString() ); + result.put( ContinuumBuildAgentUtil.KEY_START_TIME, new Long( buildContext.getBuildStartTime() ).toString() ); } else { - result.put( ContinuumBuildAgentUtil.KEY_BUILD_START, new Long( buildResult.getStartTime() ).toString() ); + result.put( ContinuumBuildAgentUtil.KEY_START_TIME, new Long( buildResult.getStartTime() ).toString() ); } if ( buildResult.getError() == null ) @@ -186,13 +206,13 @@ } result.put( ContinuumBuildAgentUtil.KEY_BUILD_STATE, new Integer( buildResult.getState() ) ); - result.put( ContinuumBuildAgentUtil.KEY_BUILD_END, new Long( buildResult.getEndTime() ).toString() ); + result.put( ContinuumBuildAgentUtil.KEY_END_TIME, new Long( buildResult.getEndTime() ).toString() ); result.put( ContinuumBuildAgentUtil.KEY_BUILD_EXIT_CODE, buildResult.getExitCode() ); } else { - result.put( ContinuumBuildAgentUtil.KEY_BUILD_START, new Long( buildContext.getBuildStartTime() ).toString() ); - result.put( ContinuumBuildAgentUtil.KEY_BUILD_END, new Long( 0 ).toString() ); + result.put( ContinuumBuildAgentUtil.KEY_START_TIME, new Long( buildContext.getBuildStartTime() ).toString() ); + result.put( ContinuumBuildAgentUtil.KEY_END_TIME, new Long( 0 ).toString() ); result.put( ContinuumBuildAgentUtil.KEY_BUILD_STATE, new Integer( ContinuumProjectState.BUILDING ) ); result.put( ContinuumBuildAgentUtil.KEY_BUILD_ERROR, "" ); result.put( ContinuumBuildAgentUtil.KEY_BUILD_EXIT_CODE, new Integer( 0 ) ); @@ -284,6 +304,294 @@ } } + public Map getReleasePluginParameters( int projectId, String pomFilename ) + throws ContinuumBuildAgentException + { + Map releaseParameters = new HashMap(); + + String workingDirectory = buildAgentConfigurationService.getWorkingDirectory( projectId ).getPath(); + + MavenXpp3Reader pomReader = new MavenXpp3Reader(); + try + { + Model model = pomReader.read( new FileReader( new File( workingDirectory, pomFilename ) ) ); + + if ( model.getBuild() != null && model.getBuild().getPlugins() != null ) + { + for ( Plugin plugin : (List) model.getBuild().getPlugins() ) + { + if ( plugin.getGroupId() != null && plugin.getGroupId().equals( "org.apache.maven.plugins" ) && + plugin.getArtifactId() != null && plugin.getArtifactId().equals( "maven-release-plugin" ) ) + { + Xpp3Dom dom = (Xpp3Dom) plugin.getConfiguration(); + + if ( dom != null ) + { + Xpp3Dom configuration = dom.getChild( "releaseLabel" ); + if ( configuration != null ) + { + releaseParameters.put( ContinuumBuildAgentUtil.KEY_SCM_TAG, configuration.getValue() ); + } + else + { + releaseParameters.put( ContinuumBuildAgentUtil.KEY_SCM_TAG, "" ); + } + + configuration = dom.getChild( "tag" ); + if ( configuration != null ) + { + releaseParameters.put( ContinuumBuildAgentUtil.KEY_SCM_TAG, configuration.getValue() ); + } + else + { + releaseParameters.put( ContinuumBuildAgentUtil.KEY_SCM_TAG, "" ); + } + + + configuration = dom.getChild( "tagBase" ); + if ( configuration != null ) + { + releaseParameters.put( ContinuumBuildAgentUtil.KEY_SCM_TAGBASE, configuration.getValue() ); + } + else + { + releaseParameters.put( ContinuumBuildAgentUtil.KEY_SCM_TAGBASE, "" ); + } + + configuration = dom.getChild( "preparationGoals" ); + if ( configuration != null ) + { + releaseParameters.put( ContinuumBuildAgentUtil.KEY_PREPARE_GOALS, configuration.getValue() ); + } + else + { + releaseParameters.put( ContinuumBuildAgentUtil.KEY_PREPARE_GOALS, "" ); + } + + configuration = dom.getChild( "arguments" ); + if ( configuration != null ) + { + releaseParameters.put( ContinuumBuildAgentUtil.KEY_ARGUMENTS, configuration.getValue() ); + } + else + { + releaseParameters.put( ContinuumBuildAgentUtil.KEY_ARGUMENTS, "" ); + } + + configuration = dom.getChild( "scmCommentPrefix" ); + if ( configuration != null ) + { + releaseParameters.put( ContinuumBuildAgentUtil.KEY_SCM_COMMENT_PREFIX, configuration.getValue() ); + } + else + { + releaseParameters.put( ContinuumBuildAgentUtil.KEY_SCM_COMMENT_PREFIX, "" ); + } + + configuration = dom.getChild( "autoVersionSubmodules" ); + if ( configuration != null ) + { + releaseParameters.put( ContinuumBuildAgentUtil.KEY_AUTO_VERSION_SUBMODULES, Boolean.valueOf( configuration.getValue() ) ); + } + else + { + releaseParameters.put( ContinuumBuildAgentUtil.KEY_AUTO_VERSION_SUBMODULES, new Boolean( false ) ); + } + + configuration = dom.getChild( "addSchema" ); + if ( configuration != null ) + { + releaseParameters.put( ContinuumBuildAgentUtil.KEY_ADD_SCHEMA, Boolean.valueOf( configuration.getValue() ) ); + } + else + { + releaseParameters.put( ContinuumBuildAgentUtil.KEY_ADD_SCHEMA, new Boolean( false ) ); + } + + configuration = dom.getChild( "useReleaseProfile" ); + if ( configuration != null ) + { + releaseParameters.put( ContinuumBuildAgentUtil.KEY_USE_RELEASE_PROFILE, Boolean.valueOf( configuration.getValue() ) ); + } + else + { + releaseParameters.put( ContinuumBuildAgentUtil.KEY_USE_RELEASE_PROFILE, new Boolean( false ) ); + } + + configuration = dom.getChild( "goals" ); + if ( configuration != null ) + { + String goals = configuration.getValue(); + if ( model.getDistributionManagement() != null && + model.getDistributionManagement().getSite() != null ) + { + goals += "site-deploy"; + } + + releaseParameters.put( ContinuumBuildAgentUtil.KEY_GOALS, goals ); + } + else + { + releaseParameters.put( ContinuumBuildAgentUtil.KEY_GOALS, "" ); + } + } + } + } + } + } + catch ( Exception e ) + { + throw new ContinuumBuildAgentException( "Error getting release plugin parameters from pom file", e ); + } + + return releaseParameters; + } + + public List>processProject( int projectId, String pomFilename, boolean autoVersionSubmodules ) + throws ContinuumBuildAgentException + { + List> projects = new ArrayList>(); + + String workingDirectory = buildAgentConfigurationService.getWorkingDirectory( projectId ).getPath(); + + try + { + processProject( workingDirectory, pomFilename, autoVersionSubmodules, projects ); + } + catch ( Exception e ) + { + throw new ContinuumBuildAgentException( "Unable to process project " + projectId, e ); + } + + return projects; + } + + public String releasePrepare( Map project, Map properties, Map releaseVersion, Map developmentVersion, Map environments ) + throws ContinuumBuildAgentException + { + try + { + return buildAgentReleaseManager.releasePrepare( project, properties, releaseVersion, developmentVersion, environments ); + } + catch ( ContinuumReleaseException e ) + { + throw new ContinuumBuildAgentException( "Unable to prepare release", e ); + } + } + + public Map getReleaseResult( String releaseId ) + throws ContinuumBuildAgentException + { + ReleaseResult result = buildAgentReleaseManager.getReleaseResult( releaseId ); + + Map map = new HashMap(); + map.put( ContinuumBuildAgentUtil.KEY_START_TIME, new Long( result.getStartTime() ).toString() ); + map.put( ContinuumBuildAgentUtil.KEY_END_TIME, new Long( result.getEndTime() ).toString() ); + map.put( ContinuumBuildAgentUtil.KEY_RELEASE_RESULT_CODE, new Integer( result.getResultCode() ) ); + map.put( ContinuumBuildAgentUtil.KEY_RELEASE_OUTPUT, result.getOutput() ); + + return map; + } + + public Map getListener( String releaseId ) + throws ContinuumBuildAgentException + { + return buildAgentReleaseManager.getListener( releaseId ); + } + + public void removeListener( String releaseId ) + { + buildAgentReleaseManager.removeListener( releaseId ); + } + + public String getPreparedReleaseName( String releaseId ) + { + return buildAgentReleaseManager.getPreparedReleaseName( releaseId ); + } + + public void releasePerform( String releaseId, String goals, String arguments, boolean useReleaseProfile, Map repository ) + throws ContinuumBuildAgentException + { + try + { + buildAgentReleaseManager.releasePerform( releaseId, goals, arguments, useReleaseProfile, repository ); + } + catch ( ContinuumReleaseException e ) + { + throw new ContinuumBuildAgentException( "Unable to perform release " + releaseId, e ); + } + } + + public void releasePerformFromScm( String goals, String arguments, boolean useReleaseProfile, Map repository, String scmUrl, + String scmUsername, String scmPassword, String scmTag, String scmTagBase, + Map environments ) + throws ContinuumBuildAgentException + { + try + { + buildAgentReleaseManager.releasePerformFromScm( goals, arguments, useReleaseProfile, repository, scmUrl, scmUsername, + scmPassword, scmTag, scmTagBase, environments ); + } + catch ( ContinuumReleaseException e ) + { + throw new ContinuumBuildAgentException( "Unable to perform release from scm", e ); + } + } + + public String releaseCleanup( String releaseId ) + throws ContinuumBuildAgentException + { + return buildAgentReleaseManager.releaseCleanup( releaseId ); + } + + private void processProject( String workingDirectory, String pomFilename, boolean autoVersionSubmodules, List> projects ) + throws Exception + { + MavenXpp3Reader pomReader = new MavenXpp3Reader(); + Model model = pomReader.read( new FileReader( new File( workingDirectory, pomFilename ) ) ); + + if ( model.getGroupId() == null ) + { + model.setGroupId( model.getParent().getGroupId() ); + } + + if ( model.getVersion() == null ) + { + model.setVersion( model.getParent().getVersion() ); + } + + setProperties( model, projects ); + + if ( !autoVersionSubmodules ) + { + for ( Iterator modules = model.getModules().iterator(); modules.hasNext(); ) + { + processProject( workingDirectory + "/" + modules.next().toString(), "pom.xml", autoVersionSubmodules, projects ); + } + } + } + + private void setProperties( Model model, List> projects ) + throws Exception + { + Map params = new HashMap(); + + params.put( "key", model.getGroupId() + ":" + model.getArtifactId() ); + + if ( model.getName() == null ) + { + model.setName( model.getArtifactId() ); + } + params.put( "name", model.getName() ); + + VersionInfo version = new DefaultVersionInfo( model.getVersion() ); + + params.put( "release", version.getReleaseVersionString() ); + params.put( "dev", version.getNextVersion().getSnapshotVersionString() ); + + projects.add( params ); + } + private List initializeBuildContext( List projectsBuildContext ) { List buildContext = new ArrayList(); @@ -313,6 +621,7 @@ context.setOldScmResult( getScmResult( ContinuumBuildAgentUtil.getOldScmChanges( map ) ) ); context.setLatestUpdateDate( ContinuumBuildAgentUtil.getLatestUpdateDate( map ) ); context.setBuildAgentUrl( ContinuumBuildAgentUtil.getBuildAgentUrl( map ) ); + context.setMaxExecutionTime( ContinuumBuildAgentUtil.getMaxExecutionTime( map ) ); buildContext.add( context ); } @@ -381,4 +690,23 @@ } } } + + private PrepareBuildProjectsTask createPrepareBuildProjectsTask( List buildContexts ) + throws ContinuumBuildAgentException + { + if ( buildContexts != null && buildContexts.size() > 0 ) + { + BuildContext context = (BuildContext) buildContexts.get( 0 ); + PrepareBuildProjectsTask task = new PrepareBuildProjectsTask( buildContexts, + context.getTrigger(), + context.getProjectGroupId(), + context.getScmRootAddress() ); + return task; + } + else + { + log.info( "Nothing to build" ); + return null; + } + } } Added: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/CreateBuildProjectTaskAction.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/CreateBuildProjectTaskAction.java?rev=751433&view=auto ============================================================================== --- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/CreateBuildProjectTaskAction.java (added) +++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/CreateBuildProjectTaskAction.java Sun Mar 8 14:41:33 2009 @@ -0,0 +1,101 @@ +package org.apache.continuum.buildagent.action; + +/* + * 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 java.util.List; +import java.util.Map; + +import org.apache.continuum.buildagent.buildcontext.BuildContext; +import org.apache.continuum.buildagent.taskqueue.manager.BuildAgentTaskQueueManager; +import org.apache.continuum.buildagent.utils.ContinuumBuildAgentUtil; +import org.apache.continuum.taskqueue.BuildProjectTask; +import org.apache.continuum.taskqueue.manager.TaskQueueManagerException; +import org.apache.maven.continuum.ContinuumException; +import org.codehaus.plexus.action.AbstractAction; +import org.codehaus.plexus.taskqueue.TaskQueueException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @plexus.component role="org.codehaus.plexus.action.Action" role-hint="create-agent-build-project-task" + */ +public class CreateBuildProjectTaskAction + extends AbstractAction +{ + private Logger log = LoggerFactory.getLogger( this.getClass() ); + + /** + * @plexus.requirement + */ + private BuildAgentTaskQueueManager buildAgentTaskQueueManager; + + public void execute( Map context ) + throws Exception + { + List buildContexts = ContinuumBuildAgentUtil.getBuildContexts( context ); + + for ( BuildContext buildContext : buildContexts ) + { + BuildProjectTask buildProjectTask = new BuildProjectTask( buildContext.getProjectId(), + buildContext.getBuildDefinitionId(), + buildContext.getTrigger(), + buildContext.getProjectName(), + "", + buildContext.getScmResult() ); + buildProjectTask.setMaxExecutionTime( buildContext.getMaxExecutionTime() * 1000 ); + + try + { + if ( !buildAgentTaskQueueManager.isProjectInBuildQueue( buildProjectTask.getProjectId() ) ) + { + buildAgentTaskQueueManager.getBuildQueue().put( buildProjectTask ); + } + } + catch ( TaskQueueException e ) + { + log.error( "Error while enqueing build task for project " + buildContext.getProjectId(), e ); + throw new ContinuumException( "Error while enqueuing build task for project " + buildContext.getProjectId(), e ); + } + catch ( TaskQueueManagerException e ) + { + log.error( "Error while checking if project " + buildContext.getProjectId() + " is in build queue", e ); + throw new ContinuumException( "Error while checking if project " + buildContext.getProjectId() + " is in build queue", e ); + } + } + + try + { + boolean stop = false; + while ( !stop ) + { + if ( buildAgentTaskQueueManager.getCurrentProjectInBuilding() <= 0 && + !buildAgentTaskQueueManager.hasBuildTaskInQueue() ) + { + stop = true; + } + } + } + catch ( TaskQueueManagerException e ) + { + throw new ContinuumException( e.getMessage(), e ); + } + } + +} Propchange: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/CreateBuildProjectTaskAction.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/CreateBuildProjectTaskAction.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateWorkingDirectoryAction.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateWorkingDirectoryAction.java?rev=751433&r1=751432&r2=751433&view=diff ============================================================================== --- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateWorkingDirectoryAction.java (original) +++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/action/UpdateWorkingDirectoryAction.java Sun Mar 8 14:41:33 2009 @@ -29,7 +29,6 @@ import org.apache.continuum.buildagent.utils.ContinuumBuildAgentUtil; import org.apache.continuum.scm.ContinuumScm; import org.apache.continuum.scm.ContinuumScmConfiguration; -import org.apache.maven.continuum.model.project.BuildDefinition; import org.apache.maven.continuum.model.project.Project; import org.apache.maven.continuum.model.scm.ChangeFile; import org.apache.maven.continuum.model.scm.ChangeSet; Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/AbstractBuildExecutor.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/AbstractBuildExecutor.java?rev=751433&r1=751432&r2=751433&view=diff ============================================================================== --- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/AbstractBuildExecutor.java (original) +++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/AbstractBuildExecutor.java Sun Mar 8 14:41:33 2009 @@ -31,8 +31,8 @@ import org.apache.continuum.buildagent.installation.BuildAgentInstallationService; import org.apache.continuum.buildagent.manager.BuildAgentManager; import org.apache.continuum.buildagent.utils.ContinuumBuildAgentUtil; -import org.apache.continuum.buildagent.utils.shell.ExecutionResult; -import org.apache.continuum.buildagent.utils.shell.BuildAgentShellCommandHelper; +import org.apache.continuum.utils.shell.ExecutionResult; +import org.apache.continuum.utils.shell.ShellCommandHelper; import org.apache.maven.artifact.Artifact; import org.apache.maven.continuum.model.project.BuildDefinition; import org.apache.maven.continuum.model.project.Project; @@ -57,7 +57,7 @@ /** * @plexus.requirement */ - private BuildAgentShellCommandHelper buildAgentShellCommandHelper; + private ShellCommandHelper shellCommandHelper; /** * @plexus.requirement @@ -103,14 +103,14 @@ this.resolveExecutable = resolveExecutable; } - public void setBuildAgentShellCommandHelper( BuildAgentShellCommandHelper buildAgentShellCommandHelper ) + public void setShellCommandHelper( ShellCommandHelper shellCommandHelper ) { - this.buildAgentShellCommandHelper = buildAgentShellCommandHelper; + this.shellCommandHelper = shellCommandHelper; } - public BuildAgentShellCommandHelper getBuildAgentShellCommandHelper() + public ShellCommandHelper getShellCommandHelper() { - return buildAgentShellCommandHelper; + return shellCommandHelper; } public void setDefaultExecutable( String defaultExecutable ) @@ -267,7 +267,7 @@ try { - ExecutionResult result = getBuildAgentShellCommandHelper().executeShellCommand( workingDirectory, actualExecutable, + ExecutionResult result = getShellCommandHelper().executeShellCommand( workingDirectory, actualExecutable, arguments, output, project.getId(), environments ); @@ -479,12 +479,12 @@ public boolean isBuilding( Project project ) { return project.getState() == ContinuumProjectState.BUILDING || - getBuildAgentShellCommandHelper().isRunning( project.getId() ); + getShellCommandHelper().isRunning( project.getId() ); } public void killProcess( Project project ) { - getBuildAgentShellCommandHelper().killProcess( project.getId() ); + getShellCommandHelper().killProcess( project.getId() ); } public List getDeployableArtifacts( Project project, File workingDirectory, BuildDefinition buildDefinition ) Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/DefaultBuildAgentMavenOneMetadataHelper.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/DefaultBuildAgentMavenOneMetadataHelper.java?rev=751433&r1=751432&r2=751433&view=diff ============================================================================== --- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/DefaultBuildAgentMavenOneMetadataHelper.java (original) +++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/build/execution/maven/m1/DefaultBuildAgentMavenOneMetadataHelper.java Sun Mar 8 14:41:33 2009 @@ -19,9 +19,10 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Service; -@Service("buildAgentMavenOneMetadataHelper") +/** + * @plexus.component role="org.apache.continuum.buildagent.build.execution.maven.m1.BuildAgentMavenOneMetadataHelper" role-hint="default" + */ public class DefaultBuildAgentMavenOneMetadataHelper implements BuildAgentMavenOneMetadataHelper { Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java?rev=751433&r1=751432&r2=751433&view=diff ============================================================================== --- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java (original) +++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/BuildContext.java Sun Mar 8 14:41:33 2009 @@ -79,6 +79,8 @@ private String buildAgentUrl; + private int maxExecutionTime; + public int getProjectGroupId() { return projectGroupId; @@ -338,4 +340,14 @@ { return buildAgentUrl; } + + public void setMaxExecutionTime( int maxExecutionTime ) + { + this.maxExecutionTime = maxExecutionTime; + } + + public int getMaxExecutionTime() + { + return maxExecutionTime; + } } Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/manager/BuildContextManager.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/manager/BuildContextManager.java?rev=751433&r1=751432&r2=751433&view=diff ============================================================================== --- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/manager/BuildContextManager.java (original) +++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/manager/BuildContextManager.java Sun Mar 8 14:41:33 2009 @@ -29,10 +29,10 @@ public interface BuildContextManager { String ROLE = BuildContextManager.class.getName(); - - public void setBuildContextList(List buildContext); - + + public void setBuildContextList( List buildContext ); + public List getBuildContextList(); - - public BuildContext getBuildContext(int projectId); + + public BuildContext getBuildContext( int projectId ); } \ No newline at end of file Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/manager/DefaultBuildContextManager.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/manager/DefaultBuildContextManager.java?rev=751433&r1=751432&r2=751433&view=diff ============================================================================== --- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/manager/DefaultBuildContextManager.java (original) +++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/buildcontext/manager/DefaultBuildContextManager.java Sun Mar 8 14:41:33 2009 @@ -22,12 +22,11 @@ import java.util.List; import org.apache.continuum.buildagent.buildcontext.BuildContext; -import org.springframework.stereotype.Service; /** * @author Jan Steven Ancajas + * @plexus.component role="org.apache.continuum.buildagent.buildcontext.manager.BuildContextManager" role-hint="default" */ -@Service("buildContextManager") public class DefaultBuildContextManager implements BuildContextManager { @@ -37,7 +36,7 @@ { BuildContext context = null; - if (buildContexts!= null) + if ( buildContexts != null ) { for ( BuildContext item : buildContexts ) { Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/installation/DefaultBuildAgentInstallationService.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/installation/DefaultBuildAgentInstallationService.java?rev=751433&r1=751432&r2=751433&view=diff ============================================================================== --- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/installation/DefaultBuildAgentInstallationService.java (original) +++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/installation/DefaultBuildAgentInstallationService.java Sun Mar 8 14:41:33 2009 @@ -25,9 +25,10 @@ import org.apache.maven.continuum.execution.ExecutorConfigurator; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; -import org.springframework.stereotype.Service; -@Service("buildAgentInstallationService") +/** + * @plexus.component role="org.apache.continuum.buildagent.installation.BuildAgentInstallationService" role-hint="default" + */ public class DefaultBuildAgentInstallationService implements BuildAgentInstallationService, Initializable { Modified: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentManager.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentManager.java?rev=751433&r1=751432&r2=751433&view=diff ============================================================================== --- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentManager.java (original) +++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentManager.java Sun Mar 8 14:41:33 2009 @@ -19,19 +19,14 @@ * under the License. */ -import java.util.List; import java.util.Map; -import org.apache.continuum.buildagent.buildcontext.BuildContext; import org.apache.maven.continuum.ContinuumException; public interface BuildAgentManager { String ROLE = BuildAgentManager.class.getName(); - void prepareBuildProjects( List buildContextList ) - throws ContinuumException; - void returnBuildResult( Map result ) throws ContinuumException; @@ -46,4 +41,10 @@ boolean shouldBuild( Map context ) throws ContinuumException; + + void startPrepareBuild( Map context ) + throws ContinuumException; + + void endPrepareBuild( Map context ) + throws ContinuumException; } Added: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentReleaseManager.java URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentReleaseManager.java?rev=751433&view=auto ============================================================================== --- continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentReleaseManager.java (added) +++ continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentReleaseManager.java Sun Mar 8 14:41:33 2009 @@ -0,0 +1,50 @@ +package org.apache.continuum.buildagent.manager; + +/* + * 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 java.util.Map; + +import org.apache.maven.continuum.release.ContinuumReleaseException; +import org.apache.maven.shared.release.ReleaseResult; + +public interface BuildAgentReleaseManager +{ + String ROLE = BuildAgentReleaseManager.class.getName(); + + String releasePrepare( Map project, Map properties, Map releaseVersion, Map developmentVersion, Map environments ) + throws ContinuumReleaseException; + + ReleaseResult getReleaseResult( String releaseId ); + + Map getListener( String releaseId ); + + void removeListener( String releaseId ); + + String getPreparedReleaseName( String releaseId ); + + void releasePerform( String releaseId, String goals, String arguments, boolean useReleaseProfile, Map repository ) + throws ContinuumReleaseException; + + void releasePerformFromScm( String goals, String arguments, boolean useReleaseProfile, Map repository, String scmUrl, String scmUsername, + String scmPassword, String scmTag, String scmTagBase, Map environments ) + throws ContinuumReleaseException; + + String releaseCleanup( String releaseId ); +} Propchange: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentReleaseManager.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: continuum/trunk/continuum-buildagent/continuum-buildagent-core/src/main/java/org/apache/continuum/buildagent/manager/BuildAgentReleaseManager.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision