Name |
Ceylon Build Task API Platform Module |
---|---|
Description |
This module defines the base elements of Goal
A [[Goal]] represents an action that can be launched by the engine. It has a name and a tasks list.
Simple goal definitionHere is an example of how to define a simple Goal hello = Goal { name = "hello"; function(Context context) { context.writer.info("Hello World!"); return done; } }; Task definitionA [[Task]] is an operation that will be executed when the goal name is specified. It takes a [[Context]] in input and returns an [[Outcome]] object telling if task execution succeed or failed. Here is an example of a simple task that will display Outcome helloTask(Context context) { context.writer.info("Hello World!"); return done; } A task can also return a success / failure message Outcome myTask(Context context) { try { processMyXXXTask(); return Success("operation xxx done"); } catch (Exception exception) { return Failure("failed to do xxx", exception); } } Goal with multiple tasksA goal can have several tasks. Goal myGoal = Goal { name = "myGoal"; function(Context context) { context.writer.info("starting"); return done; }, function(Context context) { context.writer.info("running"); return done; }, function(Context context) { context.writer.info("stopping"); return done; } }; They will all be executed in order when goal execution is requested. If one of the tasks fails, execution will stop and failure will be reported. DependenciesA goal can also define dependencies to other goals. Dependencies will be executed (even if not explicitly requested) before all other goals in the execution list that depend on those. Goal compile = Goal { name = "compile"; function(Context context) { context.writer.info("compiling!"); return done; } }; Goal run = Goal { name = "run"; dependencies = [compile]; function(Context context) { context.writer.info("running!"); return done; } }; With the above code, requesting execution of Goals without tasksIt is possible to define a goal that don't have any tasks like below: Goal testGoal = Goal { name = "test"; }; Such a goal is useless, because it will not trigger any tasks execution. However, if dependencies are added it becomes a great way to group goals. Requesting the execution of a such goal will cause the execution (as for any goals) of all of its dependencies. The execution of those dependencies will be done in the order of declaration as long as dependencies between goals of the current execution list are satisfied. If they are not, goals will be re-ordered to satisfy dependencies. Here is an example: Goal compileGoal = Goal { name = "compile"; compile { modules = "my.module"; } }; Goal compileTestsGoal = Goal { name = "compile-tests"; compileTests { modules = "test.my.module"; } }; Goal runTestsGoal = Goal { name = "run-tests"; runModule { moduleName = "test.my.module"; version = "1.0.0"; } }; Goal testGoal = Goal { name = "test"; dependencies = [compileTestsGoal, runTestsGoal]; }; Execution of As a goals without tasks is like any other goal from a dependency point of view, it can be used as a dependency which enables interesting constructions like below: Goal fullBuild = Goal { name = "full-build"; dependencies = [compileGoal, test]; }; Execution of GoalSetA [[GoalSet]] is a set of goals that can be imported in a build configuration. For example, if a Here is an example of goal set definition from "Returns a `GoalSet` providing compile, tests-compile, test and doc goals for a ceylon module." shared GoalSet ceylonModule( "module name" String moduleName, "test module name" String testModuleName = "test.``moduleName``", "test module version" String testModuleVersion = "1.0.0", "rename function that will be applied to each goal name." String(String) rename = keepCurrentName()) { return GoalSet { Goal { name = rename("compile"); compile { modules = moduleName; } }, Goal { name = rename("tests-compile"); compile { modules = testModuleName; sourceDirectories = testSourceDirectory; } }, Goal { name = rename("test"); runModule { moduleName = testModuleName; version = testModuleVersion; } }, Goal { name = rename("doc"); document { modules = moduleName; } } }; } It can be used as following: GoalSet ceylonModuleA = ceylonModule { moduleName = "moduleA"; rename = suffix(".a"); }; GoalSet ceylonModuleB = ceylonModule { moduleName = "moduleB"; rename = suffix(".b"); }; This will import goals |
Rating | 5.00 (rated by 1 user) |
Last Published | Nov 11, 2013 |
Stats |
Downloads (JVM): 701 Downloads (JS): 0 Source downloads: 626 |
Module links |
Home Code repository Issue tracker Imported By Browse |
1.0.0 | JVM JVM: 1.0.0 (outdated) | Published Nov 11, 2013 |
Browse |
View docs |
The future of build!