empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From franci...@apache.org
Subject svn commit: r904827 - in /incubator/empire-db/trunk: ./ empire-db-codegen/src/main/java/org/apache/empire/db/codegen/ empire-db-examples/ empire-db-maven-plugin/ empire-db-maven-plugin/src/ empire-db-maven-plugin/src/main/ empire-db-maven-plugin/src/ma...
Date Sat, 30 Jan 2010 17:44:41 GMT
Author: francisdb
Date: Sat Jan 30 17:44:41 2010
New Revision: 904827

URL: http://svn.apache.org/viewvc?rev=904827&view=rev
Log:
EMPIREDB-64
Initial version of the empire-db maven (codegen) plugin + example project

Added:
    incubator/empire-db/trunk/empire-db-maven-plugin/
    incubator/empire-db/trunk/empire-db-maven-plugin/pom.xml
    incubator/empire-db/trunk/empire-db-maven-plugin/src/
    incubator/empire-db/trunk/empire-db-maven-plugin/src/main/
    incubator/empire-db/trunk/empire-db-maven-plugin/src/main/java/
    incubator/empire-db/trunk/empire-db-maven-plugin/src/main/java/org/
    incubator/empire-db/trunk/empire-db-maven-plugin/src/main/java/org/apache/
    incubator/empire-db/trunk/empire-db-maven-plugin/src/main/java/org/apache/empire/
    incubator/empire-db/trunk/empire-db-maven-plugin/src/main/java/org/apache/empire/db/
    incubator/empire-db/trunk/empire-db-maven-plugin/src/main/java/org/apache/empire/db/maven/
    incubator/empire-db/trunk/empire-db-maven-plugin/src/main/java/org/apache/empire/db/maven/CodeGenMojo.java
Modified:
    incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java
    incubator/empire-db/trunk/empire-db-examples/pom.xml
    incubator/empire-db/trunk/pom.xml

Modified: incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java?rev=904827&r1=904826&r2=904827&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java
(original)
+++ incubator/empire-db/trunk/empire-db-codegen/src/main/java/org/apache/empire/db/codegen/CodeGenApp.java
Sat Jan 30 17:44:41 2010
@@ -66,7 +66,7 @@
 		CodeGenWriter codeGen = new CodeGenWriter(config);
 		codeGen.generateCodeFiles(db);
 		
-		log.info("Code generation completed sucessfully!");
+		log.info("Code generation completed successfully!");
 	}
 	
 	/**

Modified: incubator/empire-db/trunk/empire-db-examples/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-examples/pom.xml?rev=904827&r1=904826&r2=904827&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db-examples/pom.xml (original)
+++ incubator/empire-db/trunk/empire-db-examples/pom.xml Sat Jan 30 17:44:41 2010
@@ -32,6 +32,7 @@
 		<module>empire-db-example-struts2</module>
 		<module>empire-db-example-cxf</module>
 		<module>empire-db-example-struts2-cxf</module>
+		<module>empire-db-example-codegen</module>
 	</modules>
 	<build>
 		<pluginManagement>

Added: incubator/empire-db/trunk/empire-db-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-maven-plugin/pom.xml?rev=904827&view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-maven-plugin/pom.xml (added)
+++ incubator/empire-db/trunk/empire-db-maven-plugin/pom.xml Sat Jan 30 17:44:41 2010
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<parent>
+		<artifactId>empire-db-parent</artifactId>
+		<groupId>org.apache.empire-db</groupId>
+		<version>2.0.6-incubating-SNAPSHOT</version>
+	</parent>
+	<groupId>org.apache.empire-db</groupId>
+	<artifactId>empire-db-maven-plugin</artifactId>
+	<packaging>maven-plugin</packaging>
+	<name>Apache Empire-db Maven Plugin</name>
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.empire-db</groupId>
+			<artifactId>empire-db-codegen</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.maven</groupId>
+			<artifactId>maven-plugin-api</artifactId>
+			<version>2.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.maven</groupId>
+			<artifactId>maven-core</artifactId>
+			<version>2.0</version>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<scope>test</scope>
+		</dependency>
+	</dependencies>
+</project>

Added: incubator/empire-db/trunk/empire-db-maven-plugin/src/main/java/org/apache/empire/db/maven/CodeGenMojo.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db-maven-plugin/src/main/java/org/apache/empire/db/maven/CodeGenMojo.java?rev=904827&view=auto
==============================================================================
--- incubator/empire-db/trunk/empire-db-maven-plugin/src/main/java/org/apache/empire/db/maven/CodeGenMojo.java
(added)
+++ incubator/empire-db/trunk/empire-db-maven-plugin/src/main/java/org/apache/empire/db/maven/CodeGenMojo.java
Sat Jan 30 17:44:41 2010
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.empire.db.maven;
+
+import java.io.File;
+
+import org.apache.empire.db.DBDatabase;
+import org.apache.empire.db.codegen.CodeGenConfig;
+import org.apache.empire.db.codegen.CodeGenParser;
+import org.apache.empire.db.codegen.CodeGenWriter;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * Codegen goal
+ * 
+ * @goal codegen
+ * 
+ * @phase generate-sources
+ */
+public class CodeGenMojo extends AbstractMojo {
+	
+	/**
+	 * @parameter expression="${project}" 
+	 * @readonly
+	 */
+	private MavenProject project;
+
+	/**
+	 * Location of the generated sources.
+	 * 
+	 * @parameter 
+	 *     expression="${empiredb.generatedsources}" 
+	 *     default-value="${project.build.directory}/generated-sources/empiredb"
+	 * @required
+	 */
+	private File targetDirectory;
+	
+	/**
+	 * JDBC url
+	 * 
+	 * @parameter expression="${empiredb.jdbcURL}"
+	 * @required
+	 */
+	private String jdbcURL;
+	
+	/**
+	 * JDBC Driver class
+	 * 
+	 * @parameter expression="${empiredb.jdbcClass}"
+	 * @required
+	 */
+	private String jdbcClass;
+	
+	/**
+	 * JDBC Database user
+	 * 
+	 * @parameter expression="${empiredb.jdbcUser}"
+	 */
+	private String jdbcUser;
+	
+	/**
+	 * JDBC Database password
+	 * 
+	 * @parameter expression="${empiredb.jdbcPwd}"
+	 */
+	private String jdbcPwd;
+
+	public void execute() throws MojoExecutionException {
+
+		CodeGenConfig config = new CodeGenConfig();
+		config.setJdbcURL(jdbcURL);
+		config.setJdbcClass(jdbcClass);
+		config.setJdbcUser(jdbcUser);
+		config.setJdbcPwd(jdbcPwd);
+		config.setTargetFolder(targetDirectory.getAbsolutePath());
+		
+		getLog().info("Generating code for " + jdbcURL + " ...");
+		
+		CodeGenParser parser = new CodeGenParser(config);
+		DBDatabase db = parser.loadDbModel();
+		
+		CodeGenWriter codeGen = new CodeGenWriter(config);
+		codeGen.generateCodeFiles(db);
+		
+		getLog().info("Code successfully generated in: " + targetDirectory);
+		
+		// we want the generate sources to be available in the project itself
+		// TODO see if this is correct by loking at other codegen plugins
+		// TODO add some code in the test project that uses the generated code
+		project.addCompileSourceRoot(targetDirectory.getAbsolutePath());
+		
+	}
+	
+}

Modified: incubator/empire-db/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/pom.xml?rev=904827&r1=904826&r2=904827&view=diff
==============================================================================
--- incubator/empire-db/trunk/pom.xml (original)
+++ incubator/empire-db/trunk/pom.xml Sat Jan 30 17:44:41 2010
@@ -22,7 +22,6 @@
 		<groupId>org.apache</groupId>
 		<artifactId>apache</artifactId>
 		<version>7</version>
-		<!-- TODO switch to apache parent 7 (see mail) -->
 	</parent>
 	
 	<groupId>org.apache.empire-db</groupId>
@@ -51,6 +50,7 @@
 				<module>empire-db</module>
 				<module>empire-db-struts2</module>
 				<module>empire-db-codegen</module>
+				<module>empire-db-maven-plugin</module>
 				<module>empire-db-examples</module>
 			</modules>
 		</profile>
@@ -61,6 +61,7 @@
 				<module>empire-db</module>
 				<module>empire-db-struts2</module>
 				<module>empire-db-codegen</module>
+				<module>empire-db-maven-plugin</module>
 				<module>empire-db-examples</module>
 			</modules>
 			<build>
@@ -217,6 +218,12 @@
 				<type>jar</type>
 			</dependency>
 			<dependency>
+				<groupId>org.apache.empire-db</groupId>
+				<artifactId>empire-db-codegen</artifactId>
+				<version>${project.version}</version>
+				<type>jar</type>
+			</dependency>
+			<dependency>
 				<groupId>commons-logging</groupId>
 				<artifactId>commons-logging</artifactId>
 				<version>1.0.4</version>
@@ -239,7 +246,7 @@
 			<dependency>
 				<groupId>hsqldb</groupId>
 				<artifactId>hsqldb</artifactId>
-				<version>1.8.0.7</version>
+				<version>1.8.0.10</version>
 			</dependency>
 			<dependency>
 				<groupId>org.apache.struts</groupId>
@@ -261,12 +268,12 @@
 			<dependency>
 				<groupId>junit</groupId>
 				<artifactId>junit</artifactId>
-				<version>4.6</version>
+				<version>4.7</version>
 			</dependency> 
 			<dependency>
 				<groupId>org.mockito</groupId>
 				<artifactId>mockito-core</artifactId>
-				<version>1.8.0</version>
+				<version>1.8.2</version>
 			</dependency> 
 		</dependencies>
 	</dependencyManagement>



Mime
View raw message