blob: 40c6c291040c92f38a548a847d1895f277d09200 [file] [log] [blame]
package org.apache.maven.continuum.execution.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 org.apache.maven.continuum.execution.AbstractBuildExecutor;
import org.apache.maven.continuum.execution.ContinuumBuildExecutionResult;
import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
import org.apache.maven.continuum.execution.ContinuumBuildExecutorConstants;
import org.apache.maven.continuum.execution.ContinuumBuildExecutorException;
import org.apache.maven.continuum.installation.InstallationService;
import org.apache.maven.continuum.model.project.BuildDefinition;
import org.apache.maven.continuum.model.project.Project;
import org.apache.maven.continuum.model.scm.ScmResult;
import org.apache.maven.continuum.model.system.Installation;
import org.apache.maven.continuum.model.system.Profile;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
* @version $Id$
*/
public class ShellBuildExecutor
extends AbstractBuildExecutor
implements ContinuumBuildExecutor
{
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
public static final String CONFIGURATION_EXECUTABLE = "executable";
public static final String ID = ContinuumBuildExecutorConstants.SHELL_BUILD_EXECUTOR;
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
public ShellBuildExecutor()
{
super( ID, false );
}
// ----------------------------------------------------------------------
// ContinuumBuilder implementation
// ----------------------------------------------------------------------
public ContinuumBuildExecutionResult build( Project project, BuildDefinition buildDefinition,
File buildOutput, List<Project> projectsWithCommonScmRoot,
String projectScmRootUrl )
throws ContinuumBuildExecutorException
{
// TODO: this should be validated earlier?
String executable = getBuildFileForProject( project, buildDefinition );
return executeShellCommand( project, executable, buildDefinition.getArguments(), buildOutput, getEnvironments(
buildDefinition ), null, null );
}
protected Map<String, String> getEnvironments( BuildDefinition buildDefinition )
{
Profile profile = buildDefinition.getProfile();
if ( profile == null )
{
return Collections.EMPTY_MAP;
}
Map<String, String> envVars = new HashMap<String, String>();
String javaHome = getJavaHomeValue( buildDefinition );
if ( !StringUtils.isEmpty( javaHome ) )
{
envVars.put( getInstallationService().getEnvVar( InstallationService.JDK_TYPE ), javaHome );
}
Installation builder = profile.getBuilder();
if ( builder != null )
{
envVars.put( builder.getVarName(), builder.getVarValue() );
}
envVars.putAll( getEnvironmentVariables( buildDefinition ) );
return envVars;
}
public void updateProjectFromCheckOut( File workingDirectory, Project project, BuildDefinition buildDefinition,
ScmResult scmResult )
throws ContinuumBuildExecutorException
{
}
}