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

COVERAGE SUMMARY FOR SOURCE FILE [AntBuildExecutor.java]

nameclass, %method, %block, %line, %
AntBuildExecutor.java100% (1/1)25%  (1/4)3%   (5/166)6%   (2/34)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AntBuildExecutor100% (1/1)25%  (1/4)3%   (5/166)6%   (2/34)
build (Project, BuildDefinition, File): ContinuumBuildExecutionResult 0%   (0/1)0%   (0/113)0%   (0/19)
getEnvironments (BuildDefinition): Map 0%   (0/1)0%   (0/47)0%   (0/12)
updateProjectFromCheckOut (File, Project, BuildDefinition): void 0%   (0/1)0%   (0/1)0%   (0/1)
AntBuildExecutor (): void 100% (1/1)100% (5/5)100% (2/2)

1package org.apache.maven.continuum.execution.ant;
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 org.apache.maven.continuum.execution.AbstractBuildExecutor;
23import org.apache.maven.continuum.execution.ContinuumBuildExecutionResult;
24import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
25import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
26import org.apache.maven.continuum.execution.ContinuumBuildExecutorException;
27import org.apache.maven.continuum.installation.InstallationService;
28import org.apache.maven.continuum.model.project.BuildDefinition;
29import org.apache.maven.continuum.model.project.Project;
30import org.apache.maven.continuum.model.system.Installation;
31import org.apache.maven.continuum.model.system.Profile;
32import org.codehaus.plexus.util.StringUtils;
33 
34import java.io.File;
35import java.util.Collections;
36import java.util.Enumeration;
37import java.util.HashMap;
38import java.util.Map;
39import java.util.Properties;
40 
41/**
42 * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
43 * @version $Id: AntBuildExecutor.java 579348 2007-09-25 18:48:15Z evenisse $
44 */
45public class AntBuildExecutor
46    extends AbstractBuildExecutor
47    implements ContinuumBuildExecutor
48{
49    // ----------------------------------------------------------------------
50    //
51    // ----------------------------------------------------------------------
52 
53    public static final String CONFIGURATION_EXECUTABLE = "executable";
54 
55    public static final String CONFIGURATION_TARGETS = "targets";
56 
57    public static final String ID = ContinuumBuildExecutorConstants.ANT_BUILD_EXECUTOR;
58 
59    // ----------------------------------------------------------------------
60    //
61    // ----------------------------------------------------------------------
62 
63    public AntBuildExecutor()
64    {
65        super( ID, true );
66    }
67 
68    // ----------------------------------------------------------------------
69    // ContinuumBuilder Implementation
70    // ----------------------------------------------------------------------
71 
72    public ContinuumBuildExecutionResult build( Project project, BuildDefinition buildDefinition, File buildOutput )
73        throws ContinuumBuildExecutorException
74    {
75        String executable = getInstallationService().getExecutorConfigurator( InstallationService.ANT_TYPE )
76            .getExecutable();
77 
78        StringBuffer arguments = new StringBuffer();
79 
80        String buildFile = getBuildFileForProject( project, buildDefinition );
81 
82        if ( !StringUtils.isEmpty( buildFile ) )
83        {
84            arguments.append( "-f " ).append( buildFile ).append( " " );
85        }
86 
87        arguments.append( StringUtils.clean( buildDefinition.getArguments() ) ).append( " " );
88 
89        Properties props = getContinuumSystemProperties( project );
90        for ( Enumeration itr = props.propertyNames(); itr.hasMoreElements(); )
91        {
92            String name = (String) itr.nextElement();
93            String value = props.getProperty( name );
94            arguments.append( "\"-D" ).append( name ).append( "=" ).append( value ).append( "\" " );
95        }
96 
97        arguments.append( StringUtils.clean( buildDefinition.getGoals() ) );
98 
99        Map<String, String> environments = getEnvironments( buildDefinition );
100        String antHome = environments.get( getInstallationService().getEnvVar( InstallationService.ANT_TYPE ) );
101        if ( StringUtils.isNotEmpty( antHome ) )
102        {
103            executable = antHome + File.separator + "bin" + File.separator + executable;
104            setResolveExecutable( false );
105        }
106 
107        return executeShellCommand( project, executable, arguments.toString(), buildOutput, environments );
108    }
109 
110    protected Map<String, String> getEnvironments( BuildDefinition buildDefinition )
111    {
112        Profile profile = buildDefinition.getProfile();
113        if ( profile == null )
114        {
115            return Collections.EMPTY_MAP;
116        }
117        Map<String, String> envVars = new HashMap<String, String>();
118        String javaHome = getJavaHomeValue( buildDefinition );
119        if ( !StringUtils.isEmpty( javaHome ) )
120        {
121            envVars.put( getInstallationService().getEnvVar( InstallationService.JDK_TYPE ), javaHome );
122        }
123        Installation builder = profile.getBuilder();
124        if ( builder != null )
125        {
126            envVars.put( getInstallationService().getEnvVar( InstallationService.ANT_TYPE ), builder.getVarValue() );
127        }
128        envVars.putAll( getEnvironmentVariables( buildDefinition ) );
129        return envVars;
130 
131    }
132 
133    public void updateProjectFromCheckOut( File workingDirectory, Project p, BuildDefinition buildDefinition )
134        throws ContinuumBuildExecutorException
135    {
136    }
137}

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