appFuse2.x第七篇--Maven Plugins

There are a number of Maven Plugins that AppFuse uses to simplify the development process (listed in alphabetical order).

 

  • AppFuse Maven Plugin: This plugin is a replacement for AppGen in AppFuse 1.x. It's used for code generation, as well as other AppFuse-related tasks. See the list below for current enhancement ideas.
  • Cargo Maven Plugin: Used to start and stop containers before and after running integration tests (i.e. with Canoo WebTest or Selenium).
  • DbUnit Maven Plugin: This plugin is a wrapper around DbUnit and is used to populate the database with sample data before running tests.
  • Hibernate3 Maven Plugin: Used to create the database schema when using Hibernate or JPA for the DAO framework.
  • Maven Jetty Plugin: Used to run an embedded Jetty instance from Maven.
  • Maven WarPath Plugin: Used to provide features to Maven so WARs can have dependencies.
  • Native2Ascii Maven Plugin: Converts i18n bundles from native to ascii format.
  • SQL Maven Plugin: Used to create the database schema when using iBATIS for the DAO framework.
  • Tomcat Maven Plugin: Similar to the Maven Jetty Plugin - can start an embedded Tomcat instance to deploy your project or manage a remote instance.

For more plugins, see available Maven plugins and the Maven 2 Plugins Project (also known as Mojo).

About the AppFuse Maven Plugin

This release marks the first release of the AppFuse Maven Plugin (AMP). This plugin currently does two things: 1) code generation for CRUD and 2) allows you to convert your project to use AppFuse's source instead of using its binary dependencies. For more information on this plugin, see http://static.appfuse.org/plugins/appfuse-maven-plugin.

Generating CRUD with AMP

In the AppFuse 2.0 M5 release, you can run the following command to generate CRUD screens/classes for a POJO:

appfuse:gen -Dentity=Name

If you don't specify the entity name, you're prompted for it. After generating the code, you can install it using:

appfuse:install -Dentity=Name

Your entity must be defined in your hibernate.cfg.xml file for this to work. 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 should/should not generate stuff based on the packaging type (jar vs. war). In a future release, we hope to combine "gen" and "install" into a single command.

There's also a goal that allows you to generate model objects from database tables:

appfuse:gen-model

This goal does not install the generated files into your source tree, so you'll need to manually copy it. If you want to generate CRUD for the object, you'll also want to add it to your hibernate.cfg.xml.

We hope to combine these commands in a future release.

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-SNAPSHOT, 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. Known issues with "full-source" include:

  1. It only supports basic archetypes. It will likely only take a couple of hours to add modular project support, so this feature will be in the next release.
  2. It doesn't do package renaming. We plan to add this as part of the next release.

What the full-source plugin does:

  1. Exports all sources from Subversion into your project. It reads the dao.framework and web.framework properties to determine what you need.
  2. Removes warpath plugin from pom.xml.
  3. 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.
  4. Reads properties from the root AppFuse pom.xml and adds the ones that don't exist to your project. Since these are stored in a java.util.Properties, I was unable to sort them alphabetically.
 

Goals available:

GoalDescription
appfuse:gen-coreGenerates Java classes for DAOs and Managers from set of annotated POJOs
appfuse:gen-webGenerates Java classes for DAOs and Managers from set of annotated POJOs
appfuse:genGenerates Java classes from set of annotated POJOs
appfuse:hbmtemplateGeneric exporter that can be controlled by a user provided template or class.
appfuse:gen-modelGenerates Java classes from set of *.hbm.xml files
appfuse:installThis mojo is used to "install" generated artifacts (Java files, XML files) into an AppFuse project.
appfuse:full-sourceThis mojo is used to "install" source artifacts from Subversion into an AppFuse project.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值