01: package org.geotools.maven.xmlcodegen;
02:
03: import org.apache.maven.plugin.MojoExecutionException;
04: import org.apache.maven.plugin.MojoFailureException;
05: import org.eclipse.xsd.XSDSchema;
06:
07: /**
08: * Generates an instance of {@link org.opengis.feature.type.Schema } from an xml schema.
09: *
10: * @goal generateSchema
11: *
12: * @author Justin Deoliveira, The Open Planning Project
13: *
14: */
15: public class SchemaGeneratorMojo extends AbstractGeneratorMojo {
16:
17: /**
18: * Flag controlling wether complex types from the schema should be included.
19: * @parameter expression="true"
20: */
21: boolean includeComplexTypes;
22: /**
23: * Flag controlling wether simple types from the schema should be included.
24: * @parameter expression="true"
25: */
26: boolean includeSimpleTypes;
27:
28: public void execute() throws MojoExecutionException,
29: MojoFailureException {
30: XSDSchema schema = schema();
31: if (schema == null)
32: return;
33:
34: SchemaGenerator generator = new SchemaGenerator(schema);
35:
36: generator.setComplexTypes(includeComplexTypes);
37: generator.setSimpleTypes(includeSimpleTypes);
38: generator.setOverwriting(overwriteExistingFiles);
39: generator.setLocation(outputDirectory.getAbsolutePath());
40:
41: try {
42: generator.generate();
43: } catch (Exception e) {
44: getLog().error(e);
45: }
46: }
47:
48: }
|