View Javadoc

1   package org.apache.maven.continuum.core.action;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.Map;
23  
24  import org.apache.continuum.dao.BuildDefinitionDao;
25  import org.apache.continuum.dao.ProjectDao;
26  import org.apache.maven.continuum.ContinuumException;
27  import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
28  import org.apache.maven.continuum.execution.ContinuumBuildExecutorException;
29  import org.apache.maven.continuum.execution.manager.BuildExecutorManager;
30  import org.apache.maven.continuum.model.project.BuildDefinition;
31  import org.apache.maven.continuum.model.project.Project;
32  import org.apache.maven.continuum.store.ContinuumStoreException;
33  import org.apache.maven.continuum.utils.WorkingDirectoryService;
34  
35  /**
36   * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
37   * @version $Id: UpdateProjectFromWorkingDirectoryContinuumAction.java 771177 2009-05-04 05:02:26Z evenisse $
38   * @plexus.component role="org.codehaus.plexus.action.Action"
39   * role-hint="update-project-from-working-directory"
40   */
41  public class UpdateProjectFromWorkingDirectoryContinuumAction
42      extends AbstractContinuumAction
43  {
44      /**
45       * @plexus.requirement
46       */
47      private WorkingDirectoryService workingDirectoryService;
48  
49      /**
50       * @plexus.requirement
51       */
52      private BuildExecutorManager buildExecutorManager;
53  
54      /**
55       * @plexus.requirement
56       */
57      private BuildDefinitionDao buildDefinitionDao;
58  
59      /**
60       * @plexus.requirement
61       */
62      private ProjectDao projectDao;
63  
64      public void execute( Map context )
65          throws ContinuumStoreException, ContinuumException, ContinuumBuildExecutorException
66      {
67          Project project = getProject( context );
68  
69          project = projectDao.getProjectWithAllDetails( project.getId() );
70  
71          getLogger().info( "Updating project '" + project.getName() + "' from checkout." );
72  
73          BuildDefinition buildDefinition = buildDefinitionDao.getBuildDefinition( getBuildDefinitionId( context ) );
74  
75          // ----------------------------------------------------------------------
76          // Make a new descriptor
77          // ----------------------------------------------------------------------
78  
79          ContinuumBuildExecutor builder = buildExecutorManager.getBuildExecutor( project.getExecutorId() );
80  
81          builder.updateProjectFromCheckOut( workingDirectoryService.getWorkingDirectory( project ), project,
82                                             buildDefinition );
83  
84          // ----------------------------------------------------------------------
85          // Store the new descriptor
86          // ----------------------------------------------------------------------
87  
88          projectDao.updateProject( project );
89      }
90  }