Working with skeletons of project
EasyAnt comes with a module named skeleton that allows you to create or install project skeletons. This could be pretty useful to quickstart a project.
By default, this module works in interactive mode, which means that easyant will ask you questions for every required property. But you can still give parameters on the command line using -Dproperty.
Interactive mode can be disabled by setting skeleton.interactive.mode=false.
How to create a new project using a project skeleton ?
Selecting from a list of all available skeletons
Since easyant 0.8 skeleton plugin provides a target allowing to chose a skeleton from a list. This target is named ":select"Example:
> easyant skeleton:select
skeleton-select:Then easyant will prompt you to set information related to the generated project like organisation name, module name revision.
[echo] Choose a skeleton in the following list:
[ea:searchmodule] 0: std-java-webapplication v0.1 (Skeleton for creating standard java web application)
[ea:searchmodule] 1: std-ant-plugin v0.1 (Skeleton for creating ant based plugin for easyant)
[ea:searchmodule] 2: std-java-application v0.1 (Skeleton for creating standard java application)
[ea:searchmodule] 3: std-skeleton v0.1 (Emtpy skeleton structure)
[ea:searchmodule] Choose a number: (0, 1, 2, 3)
[input] The path where the skeleton project will be unzipped [.]
[input] Organisation name of YOUR project
org.mycompany
[input] Module name of YOUR project
myProject
[input] Revision number of YOUR project [0.1]
Generate a project structure using skeleton's properties
EasyAnt also provides an alternative way to use skeletons. It can be used by settings properties.When runnning in interactive mode (default behavior) easyant will prompt you to set many properties to define which skeleton should be used and some properties related to the generated project (like organisation name, module name, and revision).
If you prefer to use it in that way you should use ":generate" target.
Example if your skeleton module is imported as "skeleton", you should use :
> easyant skeleton:generate
[input] Organisation name of the skeleton projectAfter a few seconds you get your future project ready.
org.apache.easyant.skeletons
[input] Module name of the skeleton project
std-java-skeleton
[input] Revision number of the skeleton project
0.1
[input] The path where the skeleton project will be unzipped [.]
.
[input] Organization name of YOUR project
org.mycompany
[input] Module name of YOUR project
myProject
[input] Revision number of YOUR project [0.1]
0.1
How can i create my own skeleton ?
Ask easyant to create a new skeleton by using ":newskeleton" target> easyant skeleton:newskeletonThen easyant will prompt you to set a few information like the skeleton organisation name, skeleton name, and the future revision.
[input] The path where the skeleton project will be unzipped [.]After a few second you get an ready to use structure for your skeleton.
[input] Organisation name of YOUR project [org.apache.easyant.skeletons]
[input] Module name of YOUR project
myskeleton
[input] Revision number of YOUR project [0.1]
.The module.ivy is the module descriptor of your skeleton.
|-- module.ivy
`-- src
|-- main
| `-- resources
| `-- module.ivy.tpl
`-- test
`-- antunit
`-- myskeleton-test.xml
src/main/resources is the content of your skeleton.
If you need to use pattern replacement, you must add a .tpl at the end of your file.
Example :
Supposing we want to create a project called "std-java-skeleton".
- we need to create a directory structure (src/main/java, src/main/resources etc...)
- then we will update module.ivy template namedmodule.ivy.tpl
This file will look like this<ivy-module version="2.0">
<info organisation="@project.organization.name@" module="@project.module.name@" revision="@project.revision.number@" status="integration" >
<ea:build organisation="org.apache.easyant.buildtypes" module="build-std-java" revision="0.2"/>
</info>
<configurations>
<conf name="default" visibility="public" description="runtime dependencies and master artifact can be used with this conf"/>
<conf name="test" visibility="private" description="this scope
indicates that the dependency is not required for normal use of
the application, and is only available for the test compilation
and execution phases."/>
</configurations>
<dependencies/>
</ivy-module>
- project.organisation
- project.module
- project.revision
.Optionnaly you can add a post install script that will be run after unpacking the skeleton. This is pretty usefull to enhance skeleton behavior and do some post processing.
|-- module.ivy
`-- src
|-- main
| `-- resources
| |-- module.ivy.tpl
| `-- src
| |-- main
| | `-- resources
| | `-- temp-plugin.ant.tpl
| `-- test
| `-- antunit
| `-- temp-plugin-test.xml.tpl
`-- test
`-- antunit
This post install script is named skeleton.postinstall.ant (but can be configured through "skeleton.postinstall.script" property).
List of existing project skeletons
Here you can find a list of skeletons provided by easyant distribution.Organisation | Module | Revision | Description |
org.apache.easyant.skeletons | std-java-application | 0.1 | Project skeleton used to create standard java application |
org.apache.easyant.skeletons | std-java-webapplication | 0.1 | Project skeleton used to create standard java web application |
org.apache.easyant.skeletons | std-ant-plugin | 0.1 | Project skeleton used to create easyant plugins |
org.apache.easyant.skeletons | std-skeleton | 0.1 | Project skeleton used to create new skeletons |