com.atlassian.bamboo.clover.build
Class CloverGrailsBuildTaskActions

java.lang.Object
  extended by com.atlassian.bamboo.clover.build.CloverGrailsBuildTaskActions
All Implemented Interfaces:
PrePostTaskActions, BambooPluginModule

public class CloverGrailsBuildTaskActions
extends Object
implements PrePostTaskActions

The pre-task action adds a Grails Clover Plugin dependency in BuildConfig.groovy or in pom.xml, if required. The post-task action will revert this change. Actions are active when an automatic Clover integration is enabled for a Job. Actions are active for Grails MIN_GRAILS_VERSION_SUPPORTED or newer.


Field Summary
protected  BuildLogger buildLogger
          Logging to build log
protected  Map<File,File> filesToRevert
          Map(original file, backup file) of files to be restored
static String GRAILS_CLOVER_PLUGIN_DEFAULT_VERSION
          Default Grails Clover Plugin version to be installed.
static String GRAILS_CLOVER_PLUGIN_VERSION_VARIABLE
          Name of a custom variable which can be configured for a plan in order to install a specific version of the Grails Clover Plugin.
static String MIN_GRAILS_VERSION_SUPPORTED
          Minimum version number of Grails supported by this action.
 
Constructor Summary
CloverGrailsBuildTaskActions()
           
 
Method Summary
protected  boolean addCloverToBuildConfigFile(CommonTaskContext context, File buildConfigFile)
          Add Clover dependencies the BuildConfig.groovy file.
protected  boolean addCloverToPomFile(CommonTaskContext context, File pomFile)
          Add Clover dependencies the pom.xml file.
protected  void backupFile(File original)
          Create backup of the original file
 TaskResult executeAfter(InternalTaskType task, TaskResult taskResult)
          Executes a custom action after the task is executed.
 void executeBefore(InternalTaskType task, CommonTaskContext context)
          Executes a custom action before the task is executed.
protected  File getBuildConfigFile(CommonTaskContext context)
          Returns location of BuildConfig file in the workspace.
protected  String getGrailsCloverPluginVersion(CommonTaskContext context)
          Return version number of the Grails Clover Plugin to be installed.
protected  File getPomFile(CommonTaskContext context)
          Returns location of pom.xml file in the workspace.
protected  boolean isRequiredGrailsSupported(CommonTaskContext context)
          Returns if the project to be build requires Grails version which is supported by this action (MIN_GRAILS_VERSION_SUPPORTED or later) - it checks the application.config file in the working directory.
protected  void restoreFilesFromBackup()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buildLogger

protected BuildLogger buildLogger
Logging to build log


MIN_GRAILS_VERSION_SUPPORTED

public static final String MIN_GRAILS_VERSION_SUPPORTED
Minimum version number of Grails supported by this action.

See Also:
Constant Field Values

GRAILS_CLOVER_PLUGIN_VERSION_VARIABLE

public static final String GRAILS_CLOVER_PLUGIN_VERSION_VARIABLE
Name of a custom variable which can be configured for a plan in order to install a specific version of the Grails Clover Plugin. If not set, then the default plugin version is installed (i.e. the latest one).

See Also:
Constant Field Values

GRAILS_CLOVER_PLUGIN_DEFAULT_VERSION

public static final String GRAILS_CLOVER_PLUGIN_DEFAULT_VERSION
Default Grails Clover Plugin version to be installed. Please note that although the Clover Core version number is available in com_atlassian_clover.CloverVersionInfo#RELEASE_NUM, the Grails plugin is not always released together with the Clover Core.

See Also:
Constant Field Values

filesToRevert

protected Map<File,File> filesToRevert
Map(original file, backup file) of files to be restored

Constructor Detail

CloverGrailsBuildTaskActions

public CloverGrailsBuildTaskActions()
Method Detail

executeBefore

public void executeBefore(@NotNull
                          InternalTaskType task,
                          @NotNull
                          CommonTaskContext context)
                   throws Exception
Description copied from interface: PrePostTaskActions
Executes a custom action before the task is executed.

Specified by:
executeBefore in interface PrePostTaskActions
Parameters:
task - a current task, it can be actually a subclass of TaskType (build plans), DeploymentTaskType (deployment plans) or CommonTaskType (build or deployment plans)
context - a current task context, can be actually a TaskContext (build plans) or DeploymentTaskContext (deployment plans), TODO can it be a CommonTaskContext? flow in TaskExecutorImpl suggests that it may happen - but under which conditions actually?
Throws:
Exception - in case when a pre-task action fails

executeAfter

public TaskResult executeAfter(@NotNull
                               InternalTaskType task,
                               @Nullable
                               TaskResult taskResult)
                        throws Exception
Description copied from interface: PrePostTaskActions
Executes a custom action after the task is executed.

Specified by:
executeAfter in interface PrePostTaskActions
Parameters:
task - a current task which was executed
taskResult - a result of a task execution; may be null in case task terminated abnormally
Returns:
TaskResult a result of a task execution (you may return the original result or modify it)
Throws:
Exception - in case when a post-task action fails

isRequiredGrailsSupported

protected boolean isRequiredGrailsSupported(@NotNull
                                            CommonTaskContext context)
Returns if the project to be build requires Grails version which is supported by this action (MIN_GRAILS_VERSION_SUPPORTED or later) - it checks the application.config file in the working directory.

Returns:
boolean true is supported, false otherwise

getGrailsCloverPluginVersion

@NotNull
protected String getGrailsCloverPluginVersion(@NotNull
                                                      CommonTaskContext context)
Return version number of the Grails Clover Plugin to be installed. User can override default version number by specifying the GRAILS_CLOVER_PLUGIN_VERSION_VARIABLE variable.

Parameters:
context - task context
Returns:
String plugin version number

getBuildConfigFile

@Nullable
protected File getBuildConfigFile(@NotNull
                                           CommonTaskContext context)
Returns location of BuildConfig file in the workspace.

Parameters:
context - task context
Returns:
File - location of BuildConfig.groovy file or null if not found

getPomFile

@Nullable
protected File getPomFile(@NotNull
                                   CommonTaskContext context)
Returns location of pom.xml file in the workspace.

Parameters:
context - task context
Returns:
File - location of pom.xml or null if not found

addCloverToBuildConfigFile

protected boolean addCloverToBuildConfigFile(@NotNull
                                             CommonTaskContext context,
                                             @NotNull
                                             File buildConfigFile)
Add Clover dependencies the BuildConfig.groovy file.

Parameters:
buildConfigFile - file to be modified
Returns:
boolean - true if integration was performed, false otherwise

addCloverToPomFile

protected boolean addCloverToPomFile(@NotNull
                                     CommonTaskContext context,
                                     @NotNull
                                     File pomFile)
Add Clover dependencies the pom.xml file.

Parameters:
pomFile - file to be modified
Returns:
boolean - true if integration was performed, false otherwise

backupFile

protected void backupFile(@NotNull
                          File original)
                   throws IOException
Create backup of the original file

Parameters:
original - source
Throws:
IOException

restoreFilesFromBackup

protected void restoreFilesFromBackup()


Copyright © 2015 Atlassian Software Systems Pty Ltd. All rights reserved.