net.sf.ant4eclipse.ant.task.project
Class ExecuteBuildersTask

java.lang.Object
  extended by Task
      extended by net.sf.ant4eclipse.ant.task.project.AbstractProjectBasedTask
          extended by net.sf.ant4eclipse.ant.task.project.ExecuteBuildersTask

public class ExecuteBuildersTask
extends AbstractProjectBasedTask

ExecuteBuildersTask -- Calls for each builder defined in the project's .project file an Ant target. The dependend targets of a target for a builder are executed too. A target is not executed if it's if or unless conditions are not satisfied. TODO Allow to execute each target in an own project (as in the antcall-task) TODO Support different kind of triggers TODO Support arguments of builders


Field Summary
static java.lang.String CURRENT_BUILDCOMMAND_NAME
          This property contains the name of the buildcommand that is currently executed.
static java.lang.String DEFAULT_TARGET_NAME
          This target name is executed if no other target for a builder could be found.
 
Constructor Summary
ExecuteBuildersTask()
           
 
Method Summary
 void execute()
          
 java.lang.String getDefaultTargetName()
           
protected  Target getTarget(java.lang.String targetName)
          Returns the target with the given targetName or null if no such target exists in the current project
protected  java.lang.String getTargetNameForBuildCommand(BuildCommand buildCommand, java.lang.String defaultTargetName)
          Returns the target for a buildCommand.
 void setDefaultTargetName(java.lang.String defaultTargetName)
           
 
Methods inherited from class net.sf.ant4eclipse.ant.task.project.AbstractProjectBasedTask
ensureJavaProject, getEclipseProject, getWorkspace, hasText, isProjectNameSet, isProjectSet, isWorkspaceSet, requireWorkspaceAndProjectNameOrProjectSet, requireWorkspaceSet, setInitialiseWorkspace, setProject, setProjectName, setWorkspace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TARGET_NAME

public static final java.lang.String DEFAULT_TARGET_NAME
This target name is executed if no other target for a builder could be found.

See Also:
Constant Field Values

CURRENT_BUILDCOMMAND_NAME

public static final java.lang.String CURRENT_BUILDCOMMAND_NAME
This property contains the name of the buildcommand that is currently executed.

A usage for this property could be the default-builder target that wants to know which builder was defined in the .project but has no target defined

See Also:
Constant Field Values
Constructor Detail

ExecuteBuildersTask

public ExecuteBuildersTask()
Method Detail

getDefaultTargetName

public java.lang.String getDefaultTargetName()

setDefaultTargetName

public void setDefaultTargetName(java.lang.String defaultTargetName)

execute

public void execute()
             throws BuildException

Throws:
BuildException

getTargetNameForBuildCommand

protected java.lang.String getTargetNameForBuildCommand(BuildCommand buildCommand,
                                                        java.lang.String defaultTargetName)
Returns the target for a buildCommand.

The name for a target is determined in the following order:

  1. if a property called builder.full-buildcommand-name.target is defined, it's value will be used as the target name
  2. if a property called builder.buildcommand-name.target is defined, it's value will be used as the target name
  3. If a target exists in the current project, that is called exactly as the build command's name, this target will be executed
  4. If a target exists in the current project, that is called as the buildcommand-name this target will be executed
  5. If defaultTargetName is not null and exists in the project this target will be executed. If defaultTargetName is not null, but the target does not exists this task fails
  6. If a target exists with the name specified in DEFAULT_TARGET_NAME this target will be executed
  7. In all other cases null is returned

Note: full-buildcommand-name is the complete name of a buildCommand as defined in a .project-file, like org.eclipse.jdt.core.javabuilder while buildcommand-name is the "unqualified" name of a builder, like javabuilder.

Returns:
The target for this buildCommand or null if no target could be found that command.

getTarget

protected Target getTarget(java.lang.String targetName)
Returns the target with the given targetName or null if no such target exists in the current project