« prev index next »

6. Code generation

Principle

The code generation step is performed by the generate goal of the celerio-maven-plugin, a Maven plugin provided by Jaxio.

The code generation step is driven by several factors:

Source code generation is driven by several
factors

As for database schema extraction, the code generation step does not need to be performed at each build. To prevent useless generation , the simplest approach is to declare a Maven profile dedicated to code generation. As an example you can use the pom.xml that the Celerio bootstrap goal produces.

Details of celerio-maven-plugin

Full name

This plugin uses the metadata.xml file produced by the dbmetadata-maven-plugin:extract-metadata goal.

Attributes

skip

xmlConfiguration

xmlTemplatePacksOverride

xmlMetadata

outputDirectory

Simple Usage

In your pom.xml create a dedicated profile to execute the plugin, then run:

mvn -Pgen generate-sources

Here is the gen profile detail:

	<profile>
		<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
		<!-- Generate the code using Celerio -->
		<!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
		<id>gen</id>
		<build>
			<defaultGoal>generate-sources</defaultGoal>
			<plugins>
				<plugin>
					<groupId>com.jaxio.celerio</groupId>
					<artifactId>celerio-maven-plugin</artifactId>
					<version>${celerio-maven-plugin.version}</version>
					<executions>
						<execution>
							<id>Generates files using the extracted database schema.</id>
							<goals>
								<goal>generate</goal>
							</goals>
						</execution>
					</executions>
					<dependencies>
						<dependency>
							<groupId>com.jaxio.celerio.packs</groupId>
							<artifactId>pack-backend-jpa</artifactId>
							<version>1.0.0</version>
						</dependency>
					</dependencies>
				</plugin>
			</plugins>
		</build>
	</profile>

Advanced: Where to generate ?

By default, the files that Celerio generate are rooted in the folder where your pom.xml resides (the Maven ${baseDir} folder).

You can configure it to be a different folder using the ${celerio-maven-plugin.outputDir} expression.

Note The location of a generated file is defined in the generation template relatively to the Celerio outputDir.

The location of the generated Java file depend on the outputDir.

When Celerio outputDir is the same as Maven baseDir, the Java files are generated under:

Whereas when Celerio outputDir is different from Maven baseDir, the Java files are generate under:


© 2005-2015 Jaxio | @jaxiosoft | Legal