A tiny maven plugin for generating front-end model class based on backend Java Bean.
- Download source code,and run maven install.
cd pojo-mapping
mvn clean install -DskipTests
- Edit maven settings(~/.m2/settings.xml or ${MAVEN_HOME}/conf/settings.xml).
Add groupId to pluginGroups
so that the plugin prefix, which is pojo-mapping
, can be used in command line.
<pluginGroups>
<!-- add this line -->
<pluginGroup>com.morrisz.tools</pluginGroup>
</pluginGroups>
- Run
genModel
goal in project root.
mvn pojo-mapping:genModel -Dclass=com.foo.Foo
The generated front-end model would be printed to the logger like this:
/**
* Generated by pojo-mapping 1.0.0
*/
Ext.define('change.me.Foo', {
extend: 'Ext.data.Model',
idProperty: 'id',
fields: [
{name: 'firstName'},
{name: 'address'},
{name: 'lastName'}
]
});
Since it uses reflection, the class com.foo.Foo should be compiled first.
# or:
mvn pojo-mapping:genModel -Dclass=com.foo.Foo -Dstyle=extjs -Dout=./foo.js
arguments | required | desc. |
---|---|---|
class | true | the model class |
style | false | only extjs style is supported(for now, I guess...) |
out | false | output file, defaults to maven logger |