About the appfuse Maven plugin (AMP)
This plugin currently does two things:
- Code Generation for crud
- Customizing amp templates
- Converts your project to use appfuse's source
For more documentation on this plugin, see its Maven-generated site.
Generating crud with AMP
|
Stop and think before generating code! At first, I didn't want to add a code-generation feature like this because you end up with a 1-to-1 Relationship between tables/pojos, daos and managers. on most of my projects, I have far fewer daos and managers than pojos. |
Using this plugin, you can run the following command to generate crud Screens/classes for a pojo:
mvn appfuse:gen -Dentity=Name
If you don't specify the entity name, you're prompted for it. After generating the code, the plugin will install it for you as well, unless you specify-Ddisableinstallation = true. If you disable installation, you can install it using:
mvn appfuse:install -Dentity=Name
To remove the installed artifacts, use:
mvn appfuse:remove -Dentity=Name
If your entity is not defined in hibernate. cfg. XML, it will be added. in a modular project, these commands must be run in the "core" and "Web" modules. the plugin is smart enough to figure out when it shoshould/shoshould not generate stuff Based on the packaging type (jar. war ).
There's also a goal that allows you to generate model objects from database tables:
mvn appfuse:gen-model
Once you 've generated and installed the pojo, You Can generated crud for it usingAppfuse: GenCommand.
We hope to combineGenAndGen-ModelInto a single command.
Customizing amp templates
The freemarker templates that amp uses to generate code are packaged in the plugin itself. Since version 2.0.2, you can copy the code generation templates into your project using the following command:
appfuse:copy-templates
In previous versions, you can customize Templates using the following steps:
- Checkout the plugin from SVN (username:Guest, Password: <blank> ):
svn co https://appfuse.dev.java.net/svn/appfuse/trunk/plugins/appfuse-maven-plugin appfuse-maven-plugin
- Customize the templates inSrc/main/resources/appfuse.
- RunMVN install(Use-dmaven. Test. Skip = true if tests fail and you don't want to fix them ).
- Make sure your project matches the version number you just installed.
Installing appfuse's source into your project
The good news is creating an "old style" project is now pretty easy. If you create a new project using 2.0-m5 +, you can now use:
mvn appfuse:full-source
This goal will convert your project to use all of appfuse's source and remove all dependencies on appfuse. It will also refactor all package names and directories to match your project's groupid.
What the full-source plugin does:
- Exports all sources from subversion into your project. It reads the Dao. Framework and web. Framework properties to determine what you need.
- Removes warpath plugin from Pom. xml.
- Calculates Dependencies by reading Pom. xml files form the various appfuse modules. It replaces your dependencies with these new ones. The order of the dependencies added is alphabetical Based on groupid.
- Reads properties from the root appfuse Pom. xml and adds the ones that don't exist to your project.
- Renames packages to match your project's groupid.