Scarab commit: svn commit: r11160 - branches/20120417_mavenPort: extensions/scarab-maven-plugin extensions/scarab-maven-plugin/src extensions/scarab-maven-plugin/src/main extensions/scarab-maven-plugin/src/main/java extensions/scarab-maven-plugin/src/main/java/org extensions/scarab-maven-plugin/src/main/java/org/tigris extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration extensions/scarab-maven-plugin/src/main/resources extensions/scarab-maven-plugin/src/main/resources/META-INF extensions/scarab-maven-plugin/src/main/resources/META-INF/maven src/java/org/tigris/scarab/util/build
[email protected] Tue, 17 Apr 2012 01:25:22 -0700 (PDT)
| Newsgroups | gmane.comp.java.scarab.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mcoss
Date: 2012-04-17 01:25:22-0700
New Revision: 11160
Added:
branches/20120417_mavenPort/extensions/scarab-maven-plugin/
branches/20120417_mavenPort/extensions/scarab-maven-plugin/build-install.bat
branches/20120417_mavenPort/extensions/scarab-maven-plugin/pom.xml
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/XSLTransformer.java
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/AntPropertyFileGenerator.java
- copied, changed from r11156, /branches/20120417_mavenPort/src/java/org/tigris/scarab/util/build/AntPropertyFileGenerator.java
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/CreateBasicPropertyFileMojo.java
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/DBInitMojo.java
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/ImportJiraTemplatesMojo.java
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/PropertyFileGenerator.java
- copied, changed from r11156, /branches/20120417_mavenPort/src/java/org/tigris/scarab/util/build/PropertyFileGenerator.java
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/AbstractMigrateMojo.java
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/Migrate1a20To1b20.java
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/Migrate1b19To1b20.java
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/Migrate1b20To1b21.java
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/Migrate1b21To1b22.java
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/resources/
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/resources/META-INF/
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/resources/META-INF/maven/
branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/resources/META-INF/maven/lifecycle.xml
Removed:
branches/20120417_mavenPort/src/java/org/tigris/scarab/util/build/AntPropertyFileGenerator.java
branches/20120417_mavenPort/src/java/org/tigris/scarab/util/build/PropertyFileGenerator.java
branches/20120417_mavenPort/src/java/org/tigris/scarab/util/build/PropertyGetter.java
Log:
ADD - Init version of scarab-maven-plugin added. Goals are: generation of properties, "create-db" and packaging as "war", migration tasks
Added: branches/20120417_mavenPort/extensions/scarab-maven-plugin/build-install.bat
Url: http://scarab.tigris.org/source/browse/scarab/branches/20120417_mavenPort/extensions/scarab-maven-plugin/build-install.bat?view=markup&pathrev=11160
==============================================================================
--- (empty file)
+++ branches/20120417_mavenPort/extensions/scarab-maven-plugin/build-install.bat 2012-04-17 01:25:22-0700
@@ -0,0 +1 @@
+mvn clean install
\ No newline at end of file
Added: branches/20120417_mavenPort/extensions/scarab-maven-plugin/pom.xml
Url: http://scarab.tigris.org/source/browse/scarab/branches/20120417_mavenPort/extensions/scarab-maven-plugin/pom.xml?view=markup&pathrev=11160
==============================================================================
--- (empty file)
+++ branches/20120417_mavenPort/extensions/scarab-maven-plugin/pom.xml 2012-04-17 01:25:22-0700
@@ -0,0 +1,76 @@
+<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>
+ <groupId>org.tigris.scarab</groupId>
+ <artifactId>scarab-maven-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <name>scarab-maven-plugin Maven Mojo</name>
+ <url>http://maven.apache.org</url>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>3.0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>oro</groupId>
+ <artifactId>oro</artifactId>
+ <version>2.0.8</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>file-management</artifactId>
+ <version>1.2</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+
+ <!--
+ Generate xdocs for goals
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <version>2.9</version>
+
+ <executions>
+ <execution>
+ <phase>pre-site</phase>
+ <goals>
+ <goal>xdoc</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!--
+ Basic configuration for maven site
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <version>3.0</version>
+ <configuration>
+ <siteDirectory>${basedir}/site</siteDirectory>
+ <xdocDirectory>${basedir}/site/xdocs</xdocDirectory>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
Added: branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/XSLTransformer.java
Url: http://scarab.tigris.org/source/browse/scarab/branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/XSLTransformer.java?view=markup&pathrev=11160
==============================================================================
--- (empty file)
+++ branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/XSLTransformer.java 2012-04-17 01:25:22-0700
@@ -0,0 +1,41 @@
+package org.tigris.scarab.util;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+
+/**
+ * XML Transformer.
+ * @author jhoechstaedter
+ *
+ */
+public class XSLTransformer{
+
+ /**
+ * XML transformation by XSLT style sheet.
+ * @param in : Instance of InputStream
+ * @param out : Instance of OutputStream
+ * @param xslPath : Transformation style sheet.
+ * @throws TransformerException
+ */
+ public void transform(InputStream in, OutputStream out, String xslPath) throws TransformerException{
+
+ TransformerFactory tFactory = TransformerFactory.newInstance();
+
+ Transformer transformer =
+ tFactory.newTransformer
+ (new javax.xml.transform.stream.StreamSource
+ (xslPath));
+
+ transformer.transform
+ (new javax.xml.transform.stream.StreamSource
+ (in),
+ new javax.xml.transform.stream.StreamResult
+ (out));
+
+ }
+
+}
Copied: branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/AntPropertyFileGenerator.java (from r11156, /branches/20120417_mavenPort/src/java/org/tigris/scarab/util/build/AntPropertyFileGenerator.java)
Url: http://scarab.tigris.org/source/browse/scarab/branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/AntPropertyFileGenerator.java?view=diff&pathrev=11160&r1=11156&r2=11160
==============================================================================
--- /branches/20120417_mavenPort/src/java/org/tigris/scarab/util/build/AntPropertyFileGenerator.java (original)
+++ branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/AntPropertyFileGenerator.java 2012-04-17 01:25:22-0700
@@ -46,11 +46,10 @@
* individuals on behalf of Collab.Net.
*/
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
/**
* This class is used as ant task backend for the generation
@@ -58,47 +57,63 @@
*
* @author <a href="mailto:[email protected]">Hussayn Dabbous</a>
* @version $Id$
+ *
+ * @goal generate-custom-properties
+ *
*/
-public class AntPropertyFileGenerator extends Task implements PropertyGetter
+public class AntPropertyFileGenerator extends AbstractMojo
{
-
- /**
- * Setter: set the path to the template file.
- * Throws an exception, if the template file does not exist.
- * @param theTemplatePath
- */
+
+ /**
+ * Output directory for generated configuration files.
+ * @parameter
+ */
+ private String configurationDirectory;
/**
* The reusable property file generator
*/
private PropertyFileGenerator generator = new PropertyFileGenerator();
- public void setTemplate(String theTemplatePath)
+ public void setTemplate() throws MojoExecutionException
{
- boolean status = generator.setTemplate(theTemplatePath);
+ boolean status = generator.setTemplate("project.properties");
if(!status)
{
- throw new BuildException("the template["
- + theTemplatePath
- + "] does not exist.");
+ throw new MojoExecutionException("the path ["
+ + configurationDirectory
+ + "] for project.properties is not writeable.");
}
}
+ public void setEmptyCustom() throws MojoExecutionException
+ {
+ boolean status = generator.setEmptyCustom(configurationDirectory + "/custom.properties");
+ if(!status)
+ {
+ throw new MojoExecutionException("the path ["
+ + configurationDirectory
+ + "] for custom.properties is not writeable.");
+ }
+ }
+
+
/**
* Setter: set the path to the final property file.
* Throws an exception, if the customFile exist,
* but can't be overwritten (due to permission settings).
* @param theCustomPath
+ * @throws MojoExecutionException
*/
- public void setCustom(String theCustomPath)
+ public void setCustom() throws MojoExecutionException
{
- boolean status = generator.setCustom(theCustomPath);
+ boolean status = generator.setCustom(configurationDirectory + "/defaultCustom.properties");
if(!status)
{
- throw new BuildException("custom file ["
- + generator.getCustom()
- + "] is not writable.");
+ throw new MojoExecutionException("defaultCustom file for ["
+ + configurationDirectory
+ + "] is not writeable.");
}
}
@@ -108,14 +123,15 @@
* Throws an exception, if the customFile exist,
* but can't be overwritten (due to permission settings).
* @param theCustomPath
+ * @throws MojoExecutionException
*/
- public void setProperties(String thePropertyFilePathes)
+ public void setProperties() throws MojoExecutionException
{
- boolean status = generator.setProperties(thePropertyFilePathes);
+ boolean status = generator.setProperties("build.properties:project.properties");
if(!status)
{
- throw new BuildException("problem with the propretyFilePathlist["
- + thePropertyFilePathes
+ throw new MojoExecutionException("problem with the propretyFilePathlist["
+ + ""
+ "] one file is not readable.");
}
@@ -141,22 +157,20 @@
*
*/
public void execute() {
- log("Create custom file: '" + generator.getCustom() + "'.");
- log("Using template : '" + generator.getTemplate() );
-
+
try {
- generator.execute(this);
- }
- catch (FileNotFoundException e)
- {
- throw new BuildException( "File not found: " + e.getMessage() );
- }
- catch (IOException e)
- {
- throw new BuildException("Error during read from ["
- + generator.getTemplate()
- + "]: "+e.getMessage());
- }
+ setEmptyCustom();
+ setTemplate();
+ setCustom();
+ setProperties();
+
+ getLog().info("Create custom file: '" + generator.getCustom() + "'.");
+ getLog().info("Using template : '" + generator.getTemplate() );
+
+ generator.execute();
+ } catch (Exception e) {
+ getLog().error(e.getMessage(), e);
+ }
}
@@ -173,7 +187,7 @@
String value = (String) def;
if (value==null || !value.startsWith("$"))
{
- result = getProject().getProperty(name);
+ result = (String) this.getPluginContext().get(name);
}
if(result == null)
{
Added: branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/CreateBasicPropertyFileMojo.java
Url: http://scarab.tigris.org/source/browse/scarab/branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/CreateBasicPropertyFileMojo.java?view=markup&pathrev=11160
==============================================================================
--- (empty file)
+++ branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/CreateBasicPropertyFileMojo.java 2012-04-17 01:25:22-0700
@@ -0,0 +1,34 @@
+package org.tigris.scarab.util.build;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.tigris.scarab.util.XSLTransformer;
+
+/**
+ * Mojo to create basic property files for Scarab from scarab_properties.xml, e.g. project.properties and minimal.properties.
+ *
+ * @goal update-properties
+ * @author jhoechstaedter
+ *
+ */
+public class CreateBasicPropertyFileMojo extends AbstractMojo{
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ XSLTransformer transformer = new XSLTransformer();
+ try {
+ transformer.transform(new FileInputStream(new File("scarab_properties.xml")), new FileOutputStream(new File("project.properties")), "project.xsl");
+ transformer.transform(new FileInputStream(new File("scarab_properties.xml")), new FileOutputStream(new File("minimal.properties")), "minimal.xsl");
+ transformer.transform(new FileInputStream(new File("scarab_properties.xml")), new FileOutputStream(new File("wizzard.properties")), "wizzard.xsl");
+ } catch (Exception e) {
+ getLog().error(e.getMessage(), e);
+ }
+
+ }
+
+}
Added: branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/DBInitMojo.java
Url: http://scarab.tigris.org/source/browse/scarab/branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/DBInitMojo.java?view=markup&pathrev=11160
==============================================================================
--- (empty file)
+++ branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/DBInitMojo.java 2012-04-17 01:25:22-0700
@@ -0,0 +1,310 @@
+package org.tigris.scarab.util.build;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * Goal for building Scarab's database.
+ * @goal create-db
+ * @execute lifecycle="sql-init" phase="process-resources"
+ * @author jhoechstaedter
+ *
+ */
+public class DBInitMojo extends AbstractMojo{
+
+ /**
+ * Type for DB, e.g, mysql, or hypersonic.
+ * @parameter
+ */
+ protected String dbType;
+
+ /**
+ * Full database URL, including all extensions.
+ * @parameter
+ */
+ protected String dbFullUrl;
+
+ /**
+ * Database URL for server without extensions and schema name.
+ * @parameter
+ */
+ protected String dbServerUrl;
+
+ /**
+ * DB Username
+ * @parameter
+ */
+ protected String dbUser;
+
+ /**
+ * DB Password
+ * @parameter
+ */
+ protected String dbPassword;
+
+ /**
+ * Driver name for jdbc connection.
+ * @parameter
+ */
+ protected String dbDriver;
+
+ /**
+ * Input directory for Scarab's content SQL files.
+ * @parameter expression="${project.build.directory}/sql-resources/source"
+ * @readonly
+ */
+ protected String sqlSrcDir;
+
+ /**
+ * Input directory for schema SQL files.
+ * @parameter expression="${project.build.directory}/sql-resources/schema"
+ * @readonly
+ */
+ protected String sqlSchemaDir;
+
+ /**
+ * Mode for db, e.g. "sample", "default" or "basic"
+ * @parameter default-value="basic" expression="${scarab.database.build.mode}"
+ */
+ protected String dbMode;
+
+ /**
+ * True if Scarab's database should not be dropped during build.
+ * @parameter default-value="true" expression="${scarab.database.build.drop}"
+ */
+ protected boolean dropSchema;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ Connection con = null;
+ Statement stmt = null;
+ try
+ {
+
+ getLog().info("Build database for type '" + dbType + "'");
+ if("hypersonic".equals(dbType)){
+ //configurations special for hypersonic's database build
+ dropSchema = false;
+ dbServerUrl = dbFullUrl;
+ }
+
+ getLog().info("scarab.database.build.drop=" + dropSchema);
+
+ if(dropSchema && !createDB()){
+ throw new MojoExecutionException("Failed to create database schema.");
+ }
+
+ con = getFullDatabaseConnection();
+ stmt = con.createStatement();
+ executeScripts(stmt, getSqlFiles());
+
+ }
+ catch(Exception e)
+ {
+ getLog().error(e.getMessage(), e);
+ }
+ finally{
+ if(stmt != null){
+ try {
+ stmt.close();
+ } catch (SQLException e) {
+ getLog().error(e.getMessage(), e);
+ }
+ }
+ if(con != null){
+ try {
+ con.close();
+ } catch (SQLException e) {
+ getLog().error(e.getMessage(), e);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * Creats database by script.
+ * @return
+ * @throws Exception
+ */
+ protected boolean createDB(){
+ Connection con = null;
+ Statement stmt = null;
+ boolean success = true;
+ try{
+ con = getServerConnection();
+ stmt = con.createStatement();
+ File scriptDir = new File(sqlSrcDir + "/" + dbType);
+ File[] schemaSqlFiles = {
+ new File(scriptDir, "create-db.sql")
+ };
+
+ executeScripts(stmt, new ArrayList(Arrays.asList(schemaSqlFiles)));
+ }
+ catch(Exception e){
+ success = false;
+ getLog().error(e.getMessage(), e);
+ }
+ finally{
+ if(stmt != null){
+ try {
+ stmt.close();
+ } catch (SQLException e) {
+ success = false;
+ getLog().error(e.getMessage(), e);
+ }
+ }
+ if(con != null){
+ try {
+ con.close();
+ } catch (SQLException e) {
+ success = false;
+ getLog().error(e.getMessage(), e);
+ }
+ }
+ }
+ return success;
+ }
+
+ /**
+ *
+ * @param con
+ * @param files
+ */
+ protected void executeScripts(Statement stmt, List files) throws Exception{
+ Iterator iterFiels = files.iterator();
+ while(iterFiels.hasNext()){
+ FileReader fr = new FileReader((File)iterFiels.next());
+
+ BufferedReader br = new BufferedReader(fr);
+ String s = new String();
+ StringBuffer sb = new StringBuffer();
+ while((s = br.readLine()) != null)
+ {
+ if(!s.trim().startsWith("--")){
+ s = s.endsWith(" ") ? s : s + " ";
+ sb.append(s);
+ }
+ }
+ br.close();
+
+ // here is our splitter ! We use ";" as a delimiter for each request
+ // then we are sure to have well formed statements
+ String[] inst = sb.toString().split(";");
+ for(int stmtIndex = 0; stmtIndex<inst.length; stmtIndex++)
+ {
+ try{
+ // we ensure that there is no spaces before or after the request string
+ // in order to not execute empty statements
+ if(!inst[stmtIndex].trim().equals(""))
+ {
+ stmt.executeUpdate(inst[stmtIndex]);
+ }
+
+ }catch(Exception e){
+
+ getLog().error("Could not execute line: " + inst[stmtIndex] + ", due to the following reason: " + e.getMessage());
+ }
+ }
+ }
+ }
+
+ /**
+ * Gets connection to server.
+ * @return
+ * @throws Exception
+ */
+ protected Connection getServerConnection() throws Exception{
+ Class.forName(dbDriver).newInstance();
+ getLog().info("Driver: " + dbDriver);
+ getLog().info("Url: " + dbServerUrl);
+ Connection con = DriverManager.getConnection(dbServerUrl, dbUser, dbPassword);
+ return con;
+ }
+
+ /**
+ * Gets fill database connection including suffixes.
+ * @return
+ * @throws Exception
+ */
+ protected Connection getFullDatabaseConnection() throws Exception{
+ Class.forName(dbDriver).newInstance();
+ getLog().info("Driver: " + dbDriver);
+ getLog().info("Url: " + dbFullUrl);
+ Connection con = DriverManager.getConnection(dbFullUrl, dbUser, dbPassword);
+ return con;
+ }
+
+ protected File getSourceDir() throws Exception{
+ File srcDir = new File(sqlSrcDir);
+ if(!srcDir.exists()){
+ throw new MojoExecutionException("Files for data in '" + sqlSrcDir + "' not found.");
+ }
+ return srcDir;
+ }
+
+ protected File getSchemDir() throws Exception{
+ File scriptSchemaDir = new File(sqlSchemaDir);
+ if(!scriptSchemaDir.exists()){
+ throw new MojoExecutionException("Files for schema in '" + sqlSchemaDir + "' not found.");
+ }
+ return scriptSchemaDir;
+ }
+
+ /**
+ * Get SQL file for schema and content.
+ * @return
+ * @throws Exception
+ */
+ protected List getSqlFiles() throws Exception{
+ File scriptDir = getSourceDir();
+ File scriptSchemaDir = getSchemDir();
+
+ getLog().info("scarab.database.build.mode=" + dbMode);
+
+ File[] schemaSqlFiles = {// sql schema files, generated by torque:sql
+ new File(scriptSchemaDir, "turbine-schema.sql"),
+ new File(scriptSchemaDir, "scarab-schema.sql"),
+ new File(scriptSchemaDir, "id_table-schema.sql")
+ };
+ File[] basicSqlFiles = {// content sql files from scr/sql
+ new File(scriptDir, "turbine-id-table-init.sql"),
+ new File(scriptDir, "scarab-id-table-init.sql"),
+ new File(scriptDir, "scarab-security.sql"),
+ new File(scriptDir, "scarab-required-data.sql"),
+ new File(scriptDir, "scarab-anonymous.sql")};
+
+ File[] preconfiguredSqlFiles = {
+ new File(scriptDir, "scarab-default-data.sql")
+ };
+ File[] sampleSqlFiles = {
+ new File(scriptDir, "scarab-sample-data.sql"),
+ };
+
+ List sqlFiles = null;
+ sqlFiles = new ArrayList(Arrays.asList(schemaSqlFiles));
+ sqlFiles.addAll(new ArrayList(Arrays.asList(basicSqlFiles)));
+ if(dbMode.equalsIgnoreCase("default")){
+ sqlFiles.addAll(new ArrayList(Arrays.asList(preconfiguredSqlFiles)));
+ }
+ else if(dbMode.equalsIgnoreCase("sample")){
+ sqlFiles.addAll(new ArrayList(Arrays.asList(preconfiguredSqlFiles)));
+ sqlFiles.addAll(new ArrayList(Arrays.asList(sampleSqlFiles)));
+ }
+
+ return sqlFiles;
+ }
+
+}
Added: branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/ImportJiraTemplatesMojo.java
Url: http://scarab.tigris.org/source/browse/scarab/branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/ImportJiraTemplatesMojo.java?view=markup&pathrev=11160
==============================================================================
--- (empty file)
+++ branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/ImportJiraTemplatesMojo.java 2012-04-17 01:25:22-0700
@@ -0,0 +1,34 @@
+package org.tigris.scarab.util.build;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+/**
+ * Imports jira templates into Scarab's database.
+ * @goal import-jira-templates
+ * @author jhoechstaedter
+ *
+ */
+public class ImportJiraTemplatesMojo extends DBInitMojo{
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ this.dropSchema = false;
+ super.execute();
+ }
+
+ @Override
+ protected List getSqlFiles() throws Exception {
+ File scriptDir = getSourceDir();
+
+ List basicSqlFiles = new ArrayList();
+ basicSqlFiles.add(new File(scriptDir, "scarab-jira-templates-data.sql"));
+
+ return basicSqlFiles;
+ }
+
+}
\ No newline at end of file
Copied: branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/PropertyFileGenerator.java (from r11156, /branches/20120417_mavenPort/src/java/org/tigris/scarab/util/build/PropertyFileGenerator.java)
Url: http://scarab.tigris.org/source/browse/scarab/branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/PropertyFileGenerator.java?view=diff&pathrev=11160&r1=11156&r2=11160
==============================================================================
--- /branches/20120417_mavenPort/src/java/org/tigris/scarab/util/build/PropertyFileGenerator.java (original)
+++ branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/PropertyFileGenerator.java 2012-04-17 01:25:22-0700
@@ -55,11 +55,14 @@
import java.io.Reader;
import java.io.Writer;
import java.util.Hashtable;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.Vector;
+import org.codehaus.plexus.util.FileUtils;
+
/**
* This class is used as ant task backend for the generation
* of a property file by use of a template file.
@@ -85,8 +88,15 @@
* online property settings.
*/
private File customFile;
+
+ private File propertyTypes;
/**
+ *
+ */
+ private File emptyCustomFile;
+
+ /**
* This Map contains the user specified properties
* defined in the list of property files given
* when the method setProperties() is called.
@@ -111,6 +121,28 @@
return status;
}
+ public boolean setEmptyCustom(String theCustomPath)
+ {
+ boolean status = true;
+ emptyCustomFile = new File(theCustomPath);
+ if(emptyCustomFile.exists())
+ {
+ status = emptyCustomFile.delete();
+ }
+ return status;
+ }
+
+ public boolean setPropertyTypes(String thePropertyTypePath)
+ {
+ boolean status = true;
+ propertyTypes = new File(thePropertyTypePath);
+ if(propertyTypes.exists())
+ {
+ status = propertyTypes.delete();
+ }
+ return status;
+ }
+
/**
* Return the absolute path to the templateFile, or null, if
* no template file has been set.
@@ -171,18 +203,17 @@
public boolean setProperties(String theUserPathes)
{
List filePathes = createPathList(theUserPathes);
-
- if(filePathes != null)
- {
- userProperties = new Hashtable();
- for(int index=0; index<filePathes.size(); index++)
- {
- File file = new File((String)filePathes.get(index));
+ userProperties = new Hashtable();
+ Iterator iterFilePathes = filePathes.iterator();
+ while(iterFilePathes.hasNext()){
+ System.out.println("read");
+ String filePath = (String)iterFilePathes.next();
+ File file = new File(filePath);
if(file.exists())
{
if(!file.canRead())
{
- throw new RuntimeException("No Read permission for file ["+filePathes.get(index)+"]");
+ throw new RuntimeException("No Read permission for file ["+filePath+"]");
}
try
{
@@ -190,10 +221,10 @@
}
catch (IOException e)
{
- throw new RuntimeException("Could not read file ["+filePathes.get(index)+"]");
+ throw new RuntimeException("Could not read file ["+filePath+"]");
}
}
- }
+
}
return true;
}
@@ -253,7 +284,7 @@
*/
private List createPathList(String theUserPathes)
{
- List result = null;
+ List result = new Vector();
StringTokenizer stok = new StringTokenizer(theUserPathes,":");
while(stok.hasMoreTokens())
{
@@ -263,11 +294,6 @@
// deal with windows drive letters, e.g. "c:scarab/build.properties"
path+=":"+stok.nextToken();
}
-
- if(result == null)
- {
- result = new Vector();
- }
result.add(path);
}
@@ -293,9 +319,10 @@
* </ul>
*
*/
- public void execute(PropertyGetter props) throws IOException {
+ public void execute() throws IOException {
-
+ createEmptyCustomPropertyFile();
+
Reader reader = new FileReader(templateFile);
Writer writer = new FileWriter(customFile);
BufferedReader br = new BufferedReader(reader);
@@ -313,7 +340,7 @@
}
else
{
- String resultLine = createResultLine(line, props);
+ String resultLine = createResultLine(line);
pw.println(resultLine);
}
}
@@ -323,6 +350,23 @@
}
/**
+ * Creates empty custom properties file.
+ */
+ private void createEmptyCustomPropertyFile(){
+
+ if(emptyCustomFile.exists()){
+ emptyCustomFile.delete();
+ }
+ try {
+ emptyCustomFile.createNewFile();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
* Read the current line and behave according to
* following rule set:
* <ul>
@@ -342,7 +386,7 @@
* @param props
* @return
*/
- private String createResultLine(String line, PropertyGetter props)
+ private String createResultLine(String line)
{
String propertyName = null;
String templateValue = null;
@@ -368,7 +412,7 @@
if(newValue == null)
{
- newValue = (String) props.getProperty(propertyName,templateValue);
+ newValue = templateValue;
if(newValue == null)
{
newValue = "";
@@ -376,7 +420,7 @@
}
else if(newValue.equalsIgnoreCase("**generated**"))
{
- String dbtype = (String)props.getProperty("scarab.database.type","hypersonic");
+ String dbtype = (String)userProperties.get("scarab.database.type");
if(dbtype.equals(""))
{
dbtype="hypersonic";
Added: branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/AbstractMigrateMojo.java
Url: http://scarab.tigris.org/source/browse/scarab/branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/AbstractMigrateMojo.java?view=markup&pathrev=11160
==============================================================================
--- (empty file)
+++ branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/AbstractMigrateMojo.java 2012-04-17 01:25:22-0700
@@ -0,0 +1,15 @@
+package org.tigris.scarab.util.build.migration;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.tigris.scarab.util.build.DBInitMojo;
+
+public class AbstractMigrateMojo extends DBInitMojo{
+
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ this.dropSchema = false;
+ super.execute();
+ }
+
+}
Added: branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/Migrate1a20To1b20.java
Url: http://scarab.tigris.org/source/browse/scarab/branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/Migrate1a20To1b20.java?view=markup&pathrev=11160
==============================================================================
--- (empty file)
+++ branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/Migrate1a20To1b20.java 2012-04-17 01:25:22-0700
@@ -0,0 +1,25 @@
+package org.tigris.scarab.util.build.migration;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @goal migrate-1a20-to-1b21
+ * @author jhoechstaedter
+ *
+ */
+public class Migrate1a20To1b20 extends AbstractMigrateMojo{
+
+ @Override
+ protected List getSqlFiles() throws Exception {
+ File scriptDir = getSourceDir();
+
+ List basicSqlFiles = new ArrayList();
+ basicSqlFiles.add(new File(scriptDir, this.dbType + "/upgrade/" + this.dbType + "-upgrade-1.0a20-1.0b20-1.sql"));
+
+ return basicSqlFiles;
+ }
+
+}
Added: branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/Migrate1b19To1b20.java
Url: http://scarab.tigris.org/source/browse/scarab/branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/Migrate1b19To1b20.java?view=markup&pathrev=11160
==============================================================================
--- (empty file)
+++ branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/Migrate1b19To1b20.java 2012-04-17 01:25:22-0700
@@ -0,0 +1,28 @@
+package org.tigris.scarab.util.build.migration;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @goal migrate-1b19-to-1b20
+ * @author jhoechstaedter
+ *
+ */
+public class Migrate1b19To1b20 extends AbstractMigrateMojo{
+
+ @Override
+ protected List getSqlFiles() throws Exception {
+ File scriptDir = getSourceDir();
+
+ List basicSqlFiles = new ArrayList();
+ basicSqlFiles.add(new File(scriptDir, this.dbType + "/upgrade/" + this.dbType + "-upgrade-1.0b19-1.0a20-1.sql"));
+ basicSqlFiles.add(new File(scriptDir, this.dbType + "/upgrade/" + this.dbType + "-upgrade-1.0b19-1.0b20-1.sql"));
+ basicSqlFiles.add(new File(scriptDir, this.dbType + "/upgrade/" + this.dbType + "-upgrade-1.0b19-1.0b20-2.sql"));
+ basicSqlFiles.add(new File(scriptDir, this.dbType + "/upgrade/" + this.dbType + "-upgrade-1.0b19-1.0b20-3.sql"));
+
+ return basicSqlFiles;
+ }
+
+}
Added: branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/Migrate1b20To1b21.java
Url: http://scarab.tigris.org/source/browse/scarab/branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/Migrate1b20To1b21.java?view=markup&pathrev=11160
==============================================================================
--- (empty file)
+++ branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/Migrate1b20To1b21.java 2012-04-17 01:25:22-0700
@@ -0,0 +1,27 @@
+package org.tigris.scarab.util.build.migration;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @goal migrate-1b20-to-1b21
+ * @author jhoechstaedter
+ *
+ */
+public class Migrate1b20To1b21 extends AbstractMigrateMojo{
+
+ @Override
+ protected List getSqlFiles() throws Exception {
+ File scriptDir = getSourceDir();
+
+ List basicSqlFiles = new ArrayList();
+ basicSqlFiles.add(new File(scriptDir, this.dbType + "/upgrade/" + this.dbType + "-upgrade-1.0b20-1.0b21-1.sql"));
+ basicSqlFiles.add(new File(scriptDir, this.dbType + "/upgrade/" + this.dbType + "-upgrade-1.0b20-1.0b21-2.sql"));
+ basicSqlFiles.add(new File(scriptDir, this.dbType + "/upgrade/" + this.dbType + "-upgrade-1.0b20-1.0b21-3.sql"));
+
+ return basicSqlFiles;
+ }
+
+}
Added: branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/Migrate1b21To1b22.java
Url: http://scarab.tigris.org/source/browse/scarab/branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/Migrate1b21To1b22.java?view=markup&pathrev=11160
==============================================================================
--- (empty file)
+++ branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/java/org/tigris/scarab/util/build/migration/Migrate1b21To1b22.java 2012-04-17 01:25:22-0700
@@ -0,0 +1,30 @@
+package org.tigris.scarab.util.build.migration;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @goal migrate-1b21-to-1b22
+ * @author jhoechstaedter
+ *
+ */
+public class Migrate1b21To1b22 extends AbstractMigrateMojo{
+
+ @Override
+ protected List getSqlFiles() throws Exception {
+ File scriptDir = getSourceDir();
+
+ List basicSqlFiles = new ArrayList();
+ basicSqlFiles.add(new File(scriptDir, "/upgrade/upgrade-0.22-resize_id_prefix.sql"));
+ basicSqlFiles.add(new File(scriptDir, "/upgrade/upgrade-0.22-fill_activity_type.sql"));
+ basicSqlFiles.add(new File(scriptDir, "/upgrade/upgrade-0.22-attributegroup-viewrole.sql"));
+ basicSqlFiles.add(new File(scriptDir, "/upgrade/upgrade-0.22-add-scarab-issues-email-references.sql"));
+ basicSqlFiles.add(new File(scriptDir, "/upgrade/upgrade-0.22-add-new-permissions.sql"));
+ basicSqlFiles.add(new File(scriptDir, "/upgrade/upgrade-0.22-global-booleans-to-long-form.sql"));
+
+ return basicSqlFiles;
+ }
+
+}
Added: branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/resources/META-INF/maven/lifecycle.xml
Url: http://scarab.tigris.org/source/browse/scarab/branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/resources/META-INF/maven/lifecycle.xml?view=markup&pathrev=11160
==============================================================================
--- (empty file)
+++ branches/20120417_mavenPort/extensions/scarab-maven-plugin/src/main/resources/META-INF/maven/lifecycle.xml 2012-04-17 01:25:22-0700
@@ -0,0 +1,122 @@
+<!--
+ Custom maven lifecycle phases for scarab-maven-plugin
+ -->
+
+<lifecycles>
+ <lifecycle><!-- lifecycle to generate sql files -->
+ <id>sql-init</id>
+ <phases>
+ <phase><!-- phase form default lifecycle to prepare and to process prerequisites/resource files -->
+ <id>process-resources</id>
+ <executions>
+ <execution>
+ <goals><!-- create sql schema files by torque plugin -->
+ <goal>org.apache.db.torque:torque-maven-plugin:sql</goal>
+ </goals>
+ <configuration>
+ <targetDatabase>${scarab.database.type}</targetDatabase>
+ <schemaDir>src/schema</schemaDir>
+ <outputDir>${project.build.directory}/sql-resources/schema</outputDir>
+ <reportFile>report.${project.artifact.artifactId}.om.generation</reportFile>
+ </configuration>
+ </execution>
+ <execution>
+ <goals> <!-- copy and filter script files for database content -->
+ <goal>resources:copy-resources</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/sql-resources/source</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/sql</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </phase>
+ </phases>
+ </lifecycle>
+ <lifecycle>
+ <id>prepare-xdocs</id>
+ <phases>
+ <phase><!-- phase form default lifecycle to prepare and to process prerequisites for site -->
+ <id>pre-site</id>
+ <executions>
+ <execution>
+ <goals><!-- create torque documentation files by torque plugin -->
+ <goal>org.apache.db.torque:torque-maven-plugin:documentation</goal>
+ </goals>
+ <configuration>
+ <targetDatabase>${scarab.database.type}</targetDatabase>
+ <schemaDir>src/schema</schemaDir>
+ <outputDir>${project.build.directory}/site/databases</outputDir>
+ <reportFile>report.${project.artifact.artifactId}.docs.generation</reportFile>
+ </configuration>
+ </execution>
+ <execution>
+ <goals><!-- create l10n locales check -->
+ <goal>check-l10n</goal>
+ </goals>
+ <configuration>
+ <refFile>src/conf/classes/ScarabBundle_en.properties</refFile>
+ <outFileName>site/xdocs/localeerrs.xml</outFileName>
+ <fileset>
+ <directory>src/conf/classes</directory>
+ <includes>
+ <include>ScarabBundle*.properties</include>
+ </includes>
+ <followSymlinks>false</followSymlinks>
+ </fileset>
+ <messageSettings>
+ <NotInReference>ERROR</NotInReference>
+ <NoTransAllowed>ERROR</NoTransAllowed>
+ <TranslationRequired>ERROR</TranslationRequired>
+ <TranslatedTwiceDiff>ERROR</TranslatedTwiceDiff>
+ <IllegalPattern>ERROR</IllegalPattern>
+ <DifferentAttributeCount>ERROR</DifferentAttributeCount>
+ <CantParseLine>ERROR</CantParseLine>
+ <DefinedTwice>ERROR</DefinedTwice>
+ <DefinedTwiceDiff>ERROR</DefinedTwiceDiff>
+ <TranslatedTwice>INFORMATION</TranslatedTwice>
+ <TranslationMissing>INFORMATION</TranslationMissing>
+ <NotTranslated>INFORMATION</NotTranslated>
+ </messageSettings>
+ </configuration>
+ </execution>
+ <execution>
+ <goals><!-- create l10n db locales check -->
+ <goal>check-l10n</goal>
+ </goals>
+ <configuration>
+ <refFile>src/conf/classes/InitDbScarabBundle_en.properties</refFile>
+ <outFileName>site/xdocs/localeerrs_db.xml</outFileName>
+ <fileset>
+ <directory>src/conf/classes</directory>
+ <includes>
+ <include>InitDbScarabBundle*.properties</include>
+ </includes>
+ <followSymlinks>false</followSymlinks>
+ </fileset>
+ <messageSettings>
+ <NotInReference>ERROR</NotInReference>
+ <NoTransAllowed>ERROR</NoTransAllowed>
+ <TranslationRequired>ERROR</TranslationRequired>
+ <TranslatedTwiceDiff>ERROR</TranslatedTwiceDiff>
+ <IllegalPattern>ERROR</IllegalPattern>
+ <DifferentAttributeCount>ERROR</DifferentAttributeCount>
+ <CantParseLine>ERROR</CantParseLine>
+ <DefinedTwice>ERROR</DefinedTwice>
+ <DefinedTwiceDiff>ERROR</DefinedTwiceDiff>
+ <TranslatedTwice>INFORMATION</TranslatedTwice>
+ <TranslationMissing>INFORMATION</TranslationMissing>
+ <NotTranslated>INFORMATION</NotTranslated>
+ </messageSettings>
+ </configuration>
+ </execution>
+ </executions>
+ </phase>
+ </phases>
+ </lifecycle>
+</lifecycles>
Removed: branches/20120417_mavenPort/src/java/org/tigris/scarab/util/build/AntPropertyFileGenerator.java
Url: http://scarab.tigris.org/source/browse/scarab/branches/20120417_mavenPort/src/java/org/tigris/scarab/util/build/AntPropertyFileGenerator.java?view=markup&pathrev=11159
Removed: branches/20120417_mavenPort/src/java/org/tigris/scarab/util/build/PropertyFileGenerator.java
Url: http://scarab.tigris.org/source/browse/scarab/branches/20120417_mavenPort/src/java/org/tigris/scarab/util/build/PropertyFileGenerator.java?view=markup&pathrev=11159
Removed: branches/20120417_mavenPort/src/java/org/tigris/scarab/util/build/PropertyGetter.java
Url: http://scarab.tigris.org/source/browse/scarab/branches/20120417_mavenPort/src/java/org/tigris/scarab/util/build/PropertyGetter.java?view=markup&pathrev=11159
------------------------------------------------------
http://scarab.tigris.org/ds/viewMessage.do?dsForumId=3577&dsMessageId=2949027