[Jiemamy-notify:2346] commit [3349] mavenプラグインを、フェーズと関連付けるのをやめた。

アーカイブの一覧に戻る

svnno****@sourc***** svnno****@sourc*****
2009年 5月 4日 (月) 14:48:47 JST


Revision: 3349
          http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=3349
Author:   daisuke_m
Date:     2009-05-04 14:48:47 +0900 (Mon, 04 May 2009)

Log Message:
-----------
mavenプラグインを、フェーズと関連付けるのをやめた。

Modified Paths:
--------------
    eros/maven-jiemamy-plugin/trunk/src/main/java/org/jiemamy/maven/JiemamyMojo.java
    eros/maven-jiemamy-plugin/trunk/src/test/java/org/jiemamy/maven/CleanDatabaseMojoTest.java
    metis/jiemamy-tutorial/trunk/pom.xml

Added Paths:
-----------
    eros/maven-jiemamy-plugin/trunk/src/main/java/org/jiemamy/maven/CleanMojo.java

Removed Paths:
-------------
    eros/maven-jiemamy-plugin/trunk/src/main/java/org/jiemamy/maven/CleanDatabaseMojo.java


-------------- next part --------------
Deleted: eros/maven-jiemamy-plugin/trunk/src/main/java/org/jiemamy/maven/CleanDatabaseMojo.java
===================================================================
--- eros/maven-jiemamy-plugin/trunk/src/main/java/org/jiemamy/maven/CleanDatabaseMojo.java	2009-05-03 09:02:57 UTC (rev 3348)
+++ eros/maven-jiemamy-plugin/trunk/src/main/java/org/jiemamy/maven/CleanDatabaseMojo.java	2009-05-04 05:48:47 UTC (rev 3349)
@@ -1,137 +0,0 @@
-/*
- * Copyright 2007-2009 Jiemamy Project and the Others.
- * Created on 2009/04/12
- *
- * This file is part of Jiemamy.
- *
- * Licensed 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.jiemamy.maven;
-
-import java.io.IOException;
-import java.net.URL;
-import java.sql.Connection;
-import java.sql.Driver;
-import java.sql.SQLException;
-import java.util.Properties;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-
-import org.jiemamy.Jiemamy;
-import org.jiemamy.composer.ImportException;
-import org.jiemamy.composer.importer.DefaultDatabaseImportConfig;
-import org.jiemamy.dialect.Dialect;
-import org.jiemamy.exception.DriverNotFoundException;
-import org.jiemamy.utils.DatabaseCleaner;
-import org.jiemamy.utils.DriverUtil;
-import org.jiemamy.utils.JmIOUtil;
-
-/**
- * Goal which clean Database.
- * 
- * @goal cleanDatabase
- * @phase process-resources
- * @author daisuke
- */
-public class CleanDatabaseMojo extends AbstractMojo {
-	
-	private static final String DIALECT = "org.jiemamy.dialect.generic.GenericDialect";
-	
-	/**
-	 * @parameter
-	 * @required
-	 */
-	private String username;
-	
-	/**
-	 * @parameter
-	 * @required
-	 */
-	private String password;
-	
-	/**
-	 * @parameter
-	 * @required
-	 */
-	private String driver;
-	
-	/**
-	 * @parameter
-	 * @required
-	 */
-	private String uri;
-	
-
-	public void execute() throws MojoExecutionException {
-		Jiemamy jiemamy = Jiemamy.newInstance();
-		jiemamy.getFactory().getRootModel().setDialectClassName(DIALECT);
-		DefaultDatabaseImportConfig config = new DefaultDatabaseImportConfig();
-		
-		Connection connection = null;
-		try {
-			config.setDriverClassName(driver);
-			config.setUsername(username);
-			config.setPassword(password);
-			config.setImportDataSet(false);
-			config.setDialect((Dialect) Class.forName(DIALECT).newInstance());
-			config.setUri(uri);
-			
-			Properties props = new Properties();
-			props.setProperty("user", config.getUsername());
-			props.setProperty("password", config.getPassword());
-			
-			URL[] paths = config.getDriverJarPaths();
-			String className = config.getDriverClassName();
-			
-			Driver driver = DriverUtil.getDriverInstance(paths, className);
-			
-			connection = driver.connect(config.getUri(), props);
-			
-			if (connection == null) {
-				getLog().error("connection failed");
-				throw new MojoExecutionException("connection failed");
-			}
-			
-			DatabaseCleaner databaseCleaner = new DatabaseCleaner();
-			config.setDialect(jiemamy.getDialect(jiemamy.getFactory().getRootModel()));
-//			config.setSchema(jiemamy.getFactory().getRootModel().getSchemaName());
-			
-			databaseCleaner.clean(config);
-		} catch (DriverNotFoundException e) {
-			// TODO Auto-generated catch block
-			throw new MojoExecutionException("Driver not found: " + config.getDriverClassName(), e);
-		} catch (InstantiationException e) {
-			// TODO Auto-generated catch block
-			throw new MojoExecutionException("", e);
-		} catch (IllegalAccessException e) {
-			// TODO Auto-generated catch block
-			throw new MojoExecutionException("", e);
-		} catch (IOException e) {
-			// TODO Auto-generated catch block
-			throw new MojoExecutionException("", e);
-		} catch (SQLException e) {
-			// TODO Auto-generated catch block
-			throw new MojoExecutionException("", e);
-		} catch (ClassNotFoundException e) {
-			// TODO Auto-generated catch block
-			throw new MojoExecutionException("", e);
-		} catch (ImportException e) {
-			// TODO Auto-generated catch block
-			throw new MojoExecutionException("", e);
-		} finally {
-			JmIOUtil.closeQuietly(connection);
-		}
-	}
-	
-}

Copied: eros/maven-jiemamy-plugin/trunk/src/main/java/org/jiemamy/maven/CleanMojo.java (from rev 3348, eros/maven-jiemamy-plugin/trunk/src/main/java/org/jiemamy/maven/CleanDatabaseMojo.java)
===================================================================
--- eros/maven-jiemamy-plugin/trunk/src/main/java/org/jiemamy/maven/CleanMojo.java	                        (rev 0)
+++ eros/maven-jiemamy-plugin/trunk/src/main/java/org/jiemamy/maven/CleanMojo.java	2009-05-04 05:48:47 UTC (rev 3349)
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2007-2009 Jiemamy Project and the Others.
+ * Created on 2009/04/12
+ *
+ * This file is part of Jiemamy.
+ *
+ * Licensed 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.jiemamy.maven;
+
+import java.io.IOException;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.Driver;
+import java.sql.SQLException;
+import java.util.Properties;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import org.jiemamy.Jiemamy;
+import org.jiemamy.composer.ImportException;
+import org.jiemamy.composer.importer.DefaultDatabaseImportConfig;
+import org.jiemamy.dialect.Dialect;
+import org.jiemamy.exception.DriverNotFoundException;
+import org.jiemamy.utils.DatabaseCleaner;
+import org.jiemamy.utils.DriverUtil;
+import org.jiemamy.utils.JmIOUtil;
+
+/**
+ * Goal which clean Database.
+ * 
+ * @goal clean
+ * @author daisuke
+ */
+public class CleanMojo extends AbstractMojo {
+	
+	private static final String DIALECT = "org.jiemamy.dialect.generic.GenericDialect";
+	
+	/**
+	 * @parameter
+	 * @required
+	 */
+	private String username;
+	
+	/**
+	 * @parameter
+	 * @required
+	 */
+	private String password;
+	
+	/**
+	 * @parameter
+	 * @required
+	 */
+	private String driver;
+	
+	/**
+	 * @parameter
+	 * @required
+	 */
+	private String uri;
+	
+
+	public void execute() throws MojoExecutionException {
+		Jiemamy jiemamy = Jiemamy.newInstance();
+		jiemamy.getFactory().getRootModel().setDialectClassName(DIALECT);
+		DefaultDatabaseImportConfig config = new DefaultDatabaseImportConfig();
+		
+		Connection connection = null;
+		try {
+			config.setDriverClassName(driver);
+			config.setUsername(username);
+			config.setPassword(password);
+			config.setImportDataSet(false);
+			config.setDialect((Dialect) Class.forName(DIALECT).newInstance());
+			config.setUri(uri);
+			
+			Properties props = new Properties();
+			props.setProperty("user", config.getUsername());
+			props.setProperty("password", config.getPassword());
+			
+			URL[] paths = config.getDriverJarPaths();
+			String className = config.getDriverClassName();
+			
+			Driver driver = DriverUtil.getDriverInstance(paths, className);
+			
+			connection = driver.connect(config.getUri(), props);
+			
+			if (connection == null) {
+				getLog().error("connection failed");
+				throw new MojoExecutionException("connection failed");
+			}
+			
+			DatabaseCleaner databaseCleaner = new DatabaseCleaner();
+			config.setDialect(jiemamy.getDialect(jiemamy.getFactory().getRootModel()));
+//			config.setSchema(jiemamy.getFactory().getRootModel().getSchemaName());
+			
+			databaseCleaner.clean(config);
+		} catch (DriverNotFoundException e) {
+			// TODO Auto-generated catch block
+			throw new MojoExecutionException("Driver not found: " + config.getDriverClassName(), e);
+		} catch (InstantiationException e) {
+			// TODO Auto-generated catch block
+			throw new MojoExecutionException("", e);
+		} catch (IllegalAccessException e) {
+			// TODO Auto-generated catch block
+			throw new MojoExecutionException("", e);
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			throw new MojoExecutionException("", e);
+		} catch (SQLException e) {
+			// TODO Auto-generated catch block
+			throw new MojoExecutionException("", e);
+		} catch (ClassNotFoundException e) {
+			// TODO Auto-generated catch block
+			throw new MojoExecutionException("", e);
+		} catch (ImportException e) {
+			// TODO Auto-generated catch block
+			throw new MojoExecutionException("", e);
+		} finally {
+			JmIOUtil.closeQuietly(connection);
+		}
+	}
+	
+}


Property changes on: eros/maven-jiemamy-plugin/trunk/src/main/java/org/jiemamy/maven/CleanMojo.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: eros/maven-jiemamy-plugin/trunk/src/main/java/org/jiemamy/maven/JiemamyMojo.java
===================================================================
--- eros/maven-jiemamy-plugin/trunk/src/main/java/org/jiemamy/maven/JiemamyMojo.java	2009-05-03 09:02:57 UTC (rev 3348)
+++ eros/maven-jiemamy-plugin/trunk/src/main/java/org/jiemamy/maven/JiemamyMojo.java	2009-05-04 05:48:47 UTC (rev 3349)
@@ -37,7 +37,6 @@
  * Goal which execute Exporter.
  * 
  * @goal jiemamy
- * @phase process-resources
  * @author daisuke
  */
 public class JiemamyMojo extends AbstractMojo {

Modified: eros/maven-jiemamy-plugin/trunk/src/test/java/org/jiemamy/maven/CleanDatabaseMojoTest.java
===================================================================
--- eros/maven-jiemamy-plugin/trunk/src/test/java/org/jiemamy/maven/CleanDatabaseMojoTest.java	2009-05-03 09:02:57 UTC (rev 3348)
+++ eros/maven-jiemamy-plugin/trunk/src/test/java/org/jiemamy/maven/CleanDatabaseMojoTest.java	2009-05-04 05:48:47 UTC (rev 3349)
@@ -30,7 +30,7 @@
 public class CleanDatabaseMojoTest {
 	
 	/** テスト対象 */
-	private CleanDatabaseMojo cleanDatabaseMojo;
+	private CleanMojo cleanDatabaseMojo;
 	
 
 	/**
@@ -40,7 +40,7 @@
 	 */
 	@Before
 	public void setUp() throws Exception {
-		cleanDatabaseMojo = new CleanDatabaseMojo();
+		cleanDatabaseMojo = new CleanMojo();
 		
 //		HashMap<String, Object> parameter = new HashMap<String, Object>();
 //		parameter.put(SqlExporter.OUTPUT_FILE, outputFile);

Modified: metis/jiemamy-tutorial/trunk/pom.xml
===================================================================
--- metis/jiemamy-tutorial/trunk/pom.xml	2009-05-03 09:02:57 UTC (rev 3348)
+++ metis/jiemamy-tutorial/trunk/pom.xml	2009-05-04 05:48:47 UTC (rev 3349)
@@ -25,34 +25,27 @@
 				</configuration>
 			</plugin>
 			<plugin>
+				<!-- jiemamyプラグインの設定 -->
+				<!-- 	cleanゴール = DB上に存在するエンティティ等を全削除する -->
+				<!-- 	jiemamyゴール = データファイルからSQLを生成する -->
 				<groupId>org.jiemamy</groupId>
 				<artifactId>maven-jiemamy-plugin</artifactId>
-				<executions>
-					<execution>
-						<id>clean-schema</id>
-						<phase>process-resources</phase>
-						<goals>
-							<goal>cleanDatabase</goal>
-						</goals>
-					</execution>
-					<execution>
-						<id>create-sql</id>
-						<phase>process-resources</phase>
-						<goals>
-							<goal>jiemamy</goal>
-						</goals>
-						<configuration>
-							<inputFile>./src/database/jiemamy.jer</inputFile>
-							<parameter>
-								<outputFile>./target/jiemamy.sql</outputFile>
-								<drop>false</drop>
-								<schema>false</schema>
-								<overwrite>true</overwrite>
-								<dataSetIndex>0</dataSetIndex>
-							</parameter>
-						</configuration>
-					</execution>
-				</executions>
+				<configuration>
+					<!-- jiemamy:clean用設定 -->
+					<username>${database.username}</username>
+					<password>${database.password}</password>
+					<driver>${database.driver}</driver>
+					<uri>${database.uri}</uri>
+					<!-- jiemamy:jiemamy用設定 -->
+					<inputFile>./src/database/jiemamy.jer</inputFile>
+					<parameter>
+						<outputFile>./target/jiemamy.sql</outputFile>
+						<drop>false</drop>
+						<schema>false</schema>
+						<overwrite>true</overwrite>
+						<dataSetIndex>0</dataSetIndex>
+					</parameter>
+				</configuration>
 				<dependencies>
 					<dependency>
 						<groupId>org.jiemamy</groupId>
@@ -65,40 +58,16 @@
 						<version>8.3-603.jdbc3</version>
 					</dependency>
 				</dependencies>
-				<configuration>
-					<username>${database.username}</username>
-					<password>${database.password}</password>
-					<driver>${database.driver}</driver>
-					<uri>${database.uri}</uri>
-				</configuration>
 			</plugin>
 			<plugin>
+				<!-- sqlプラグインの設定(生成されたSQLを実行) -->
 				<groupId>org.codehaus.mojo</groupId>
 				<artifactId>sql-maven-plugin</artifactId>
-				<executions>
-					<!-- 最後に先ほど生成されたSQLを実行 --> 
-					<execution>
-						<id>create-schema</id>
-						<phase>process-resources</phase>
-						<goals>
-							<goal>execute</goal>
-						</goals>
-						<configuration>
-							<autocommit>true</autocommit>
-							<srcFiles>
-								<srcFile>./target/jiemamy.sql</srcFile>
-							</srcFiles>
-						</configuration>
-					</execution>
-				</executions>
-				<dependencies>
-					<dependency>
-						<groupId>postgresql</groupId>
-						<artifactId>postgresql</artifactId>
-						<version>8.2-504.jdbc3</version>
-					</dependency>
-				</dependencies>
 				<configuration>
+					<autocommit>true</autocommit>
+					<srcFiles>
+						<srcFile>./target/jiemamy.sql</srcFile>
+					</srcFiles>
 					<username>${database.username}</username>
 					<password>${database.password}</password>
 					<settingsKeys>sensibleKey</settingsKeys>
@@ -106,9 +75,16 @@
 					<url>${database.uri}</url>
 					<skip>${maven.test.skip}</skip>
 				</configuration>
+				<dependencies>
+					<dependency>
+						<groupId>postgresql</groupId>
+						<artifactId>postgresql</artifactId>
+						<version>8.2-504.jdbc3</version>
+					</dependency>
+				</dependencies>
 			</plugin>
-			<!-- compileフェーズにおけるコンパイラの設定 -->
 			<plugin>
+				<!-- compileフェーズにおけるコンパイラの設定 -->
 				<artifactId>maven-compiler-plugin</artifactId>
 				<configuration>
 					<source>1.5</source>
@@ -116,8 +92,8 @@
                     <encoding>UTF-8</encoding>
 				</configuration>
 			</plugin>
-			<!-- packageフェーズで、source jarも作成する -->
 			<plugin>
+				<!-- packageフェーズで、source jarも作成する -->
 				<artifactId>maven-source-plugin</artifactId>
 				<executions>
 					<execution>
@@ -129,8 +105,8 @@
 					</execution>
 				</executions>
 			</plugin>
-			<!-- jettyにデプロイ -->
             <plugin>
+				<!-- jettyにデプロイ -->
                 <groupId>org.mortbay.jetty</groupId>
                 <artifactId>maven-jetty-plugin</artifactId>
             </plugin>



Jiemamy-notify メーリングリストの案内
アーカイブの一覧に戻る