<settings>
<pluginGroups>
<pluginGroup>org.mule.tools</pluginGroup>
</pluginGroups>
...
</settings>
Creating Project Archetypes
Mule provides Maven archetypes that you can use as code templates for your Mule projects. These templates include a set of implementation notes and "todo" pointers that help you get started quickly. The Mule project archetype will help you generate a tailored boilerplate project in seconds.
Follow the instructions below to create template files for a new project, including all the necessary Java boilerplate and detailed implementation instructions.
Configuring Maven
Add the following to the file settings.xml
(usually in your Maven conf
or $HOME/.m2
directory) so that Maven will allow you to execute Mule plug-ins.
settings.xml |
---|
Using the Archetype
First, open a command shell and change to the directory where you want to create your project.
> cd yourDir
Next, you will execute the archetype and generate the code. If this is your first time running this command, Maven will download the archetype for you.
> mvn mule-project-archetype:create -DartifactId=xxx -DmuleVersion=3.1.1
At minimum, you pass in two system parameters:
-
artifactId
: The short name for the project (such as 'myApp'). This must be a single word in lower case with no spaces, periods, hyphens, etc. -
muleVersion
: The version of the Mule project archetype you want to use. This will also be the default Mule version used for the generated artifact.
Running the archetype
Maven uses by default the latest available version of the archetype. This can cause problems if you want to create a project for an earlier version of Mule. In this case, run the mule-project-archetype specifying the full version of the plugin like this:
mvn org.mule.tools:mule-project-archetype:3.1.1:create ...
artifactId
The artifactId can contain characters such as underscore or hyphen. However, the plug-in will convert the name into a usable form suitable for Java. For example, if the argument is specified as -DartifactId=My#Awesome-Mule_Project, the project will be created in a directory of that name, but the project name will be MyAwesomeMuleProject and the package name will be .myawesomemuleproject
The plug-in will ask various questions (described below) and then generate the files. You can also use this plug-in without user prompts by entering all the arguments at the command line.
After you have answered all the questions, the archetype creates a directory using the project name you specified that includes a POM file for building with Maven, a Mule configuration file (src\main\resources\mule-config.xml
) that includes the namespaces for the transports and modules you specified and has placeholder elements for creating your first service, and a package.html
file under src\main\java
using the package path you specified. Lastly, it creates some template files under src\test
to help you get started creating a unit test for the project. A new MULE-README.txt
file will be created in the root of your project explaining what files were created.
The Questions Explained
The plug-in prompts you to answer several questions about the project you are writing. These may vary according to the options you select. An example of the output is shown below.
Provide a description of what the project does:
You should provide an accurate description of the project with any high-level details of what you can or cannot do with it. This text will be used where a description of the project is required.
Which version of Mule is this project targeted at?
The version of Mule you want to use for your project. This will default to the archetype version passed in on the command line.
What is the base Java package path for this project?
This should be a Java package path for you project, such as com/mycompany/project. Note that you must use slashes for separators, not periods.
Example Console Output
[INFO] description:
********************************************************************************
Provide a description of what the project does:
[default:]
********************************************************************************
[INFO] muleVersion:
********************************************************************************
Which version of Mule is this module targeted at?
[default: 3.1.0]
********************************************************************************
[INFO] package:
********************************************************************************
What is the base Java package path for this project? (i.e. com/mycompany/project):
[default:]
********************************************************************************
[INFO] transports:
********************************************************************************
Which Mule transports do you want to include in this project?
(options: axis,cxf,ejb,file,ftp,http,https,imap,imaps,jbpm,jdbc,
jetty,jms,multicast,pop3,pop3s,quartz,rmi,servlet,smtp,
smtps,servlet,ssl,tls,stdio,tcp,udp,vm,xmpp):
[default: cxf,file,http,jdbc,jms,stdio,vm]
********************************************************************************
[INFO] modules:
********************************************************************************
Which Mule modules do you want to include in this project?
(options: bulders,client,jaas,jbossts,management,ognl,pgp,scripting,
spring-extras,sxc,xml):
[default: client,management,scripting,sxc,xml]
********************************************************************************
Command Line Options
By default, this plug-in runs in interactive mode, but it’s possible to run it in 'silent' mode by using the following option:
-DinteractiveMode=false
The following options can be passed in:
Name | Example | Default Value |
---|---|---|
groupId |
-DgroupId=org.mule.applicationxxx |
org.mule.application.<artifactId> |
packagePath |
-DpackagePath=org/mule/application |
none |
transports |
-Dtransports=http,vm |
cxf,file,http,jdbc,jms,stdio,vm |
muleVersion |
-DmuleVersion=3.1.0 |
none |
packageName |
-DpackageName=myPkg |
none |
description |
-Ddescription="some text" |
none |
modules |
-Dmodules=xml,scripting |
client,management,scripting,sxc,xml |
basedir |
-Dbasedir=/projects/mule/tools |
<current dir> |
package |
-Dpackage=org/mule/application/myPkg |
none |
artifactId |
-DartifactId=myMuleProject |
<artifactId> |
version |
-Dversion=1.0-SNAPSHOT |
<muleVersion> |