EMMA Coverage Report (generated Sun Sep 18 11:34:27 PHT 2011)
[all classes][org.apache.maven.continuum.core.action]

COVERAGE SUMMARY FOR SOURCE FILE [DeployArtifactContinuumAction.java]

nameclass, %method, %block, %line, %
DeployArtifactContinuumAction.java100% (1/1)100% (2/2)11%  (10/88)20%  (4/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DeployArtifactContinuumAction100% (1/1)100% (2/2)11%  (10/88)20%  (4/20)
execute (Map): void 100% (1/1)8%   (7/85)16%  (3/19)
DeployArtifactContinuumAction (): void 100% (1/1)100% (3/3)100% (1/1)

1package 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 
22import java.io.File;
23import java.util.List;
24import java.util.Map;
25 
26import org.apache.continuum.model.repository.LocalRepository;
27import org.apache.maven.artifact.Artifact;
28import org.apache.maven.artifact.deployer.ArtifactDeployer;
29import org.apache.maven.artifact.repository.ArtifactRepository;
30import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
31import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
32import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
33import org.apache.maven.continuum.configuration.ConfigurationService;
34import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
35import org.apache.maven.continuum.execution.manager.BuildExecutorManager;
36import org.apache.maven.continuum.execution.maven.m2.MavenBuilderHelper;
37import org.apache.maven.continuum.model.project.BuildDefinition;
38import org.apache.maven.continuum.model.project.Project;
39import org.apache.maven.continuum.project.ContinuumProjectState;
40import org.apache.maven.continuum.utils.WorkingDirectoryService;
41 
42/**
43 * @author <a href="mailto:brett@apache.org">Brett Porter</a>
44 * @version $Id: DeployArtifactContinuumAction.java 771177 2009-05-04 05:02:26Z evenisse $
45 * @plexus.component role="org.codehaus.plexus.action.Action"
46 * role-hint="deploy-artifact"
47 */
48public class DeployArtifactContinuumAction
49    extends AbstractContinuumAction
50{
51    /**
52     * @plexus.requirement
53     */
54    private ConfigurationService configurationService;
55 
56    /**
57     * @plexus.requirement
58     */
59    private BuildExecutorManager buildExecutorManager;
60 
61    /**
62     * @plexus.requirement
63     */
64    private WorkingDirectoryService workingDirectoryService;
65 
66    /**
67     * @plexus.requirement
68     */
69    private ArtifactDeployer artifactDeployer;
70 
71    /**
72     * @plexus.requirement
73     */
74    private MavenBuilderHelper builderHelper;
75 
76    /**
77     * @plexus.requirement
78     */
79    private ArtifactRepositoryFactory artifactRepositoryFactory;
80 
81    public void execute( Map context )
82        throws Exception
83    {
84        // ----------------------------------------------------------------------
85        // Get parameters from the context
86        // ----------------------------------------------------------------------
87 
88        File deploymentRepositoryDirectory = configurationService.getDeploymentRepositoryDirectory();
89 
90        if ( deploymentRepositoryDirectory != null )
91        {
92 
93            Project project = getProject( context );
94 
95            ContinuumBuildExecutor buildExecutor = buildExecutorManager.getBuildExecutor( project.getExecutorId() );
96 
97            // ----------------------------------------------------------------------
98            // This is really a precondition for this action to execute
99            // ----------------------------------------------------------------------
100 
101            if ( project.getState() == ContinuumProjectState.OK )
102            {
103                BuildDefinition buildDefinition = getBuildDefinition( context );
104 
105                List<Artifact> artifacts = buildExecutor.getDeployableArtifacts( project,
106                                                                                 workingDirectoryService.getWorkingDirectory(
107                                                                                     project ), buildDefinition );
108 
109                LocalRepository repository = project.getProjectGroup().getLocalRepository();
110 
111                builderHelper.setLocalRepository( repository );
112 
113                ArtifactRepository localRepository = builderHelper.getLocalRepository();
114 
115                for ( Artifact artifact : artifacts )
116                {
117                    ArtifactRepositoryLayout repositoryLayout = new DefaultRepositoryLayout();
118 
119                    if ( !deploymentRepositoryDirectory.exists() )
120                    {
121                        deploymentRepositoryDirectory.mkdirs();
122                    }
123 
124                    String location = deploymentRepositoryDirectory.toURL().toExternalForm();
125 
126                    ArtifactRepository deploymentRepository =
127                        artifactRepositoryFactory.createDeploymentArtifactRepository( "deployment-repository", location,
128                                                                                      repositoryLayout, true );
129 
130                    artifactDeployer.deploy( artifact.getFile(), artifact, deploymentRepository, localRepository );
131                }
132            }
133        }
134    }
135}

[all classes][org.apache.maven.continuum.core.action]
EMMA 2.0.5312 (C) Vladimir Roubtsov