Permalink
Browse files

initial commit

  • Loading branch information...
0 parents commit e47b653a1d09e9dccedc5ba0d613bc2c5ad369d1 Burt Beckwith committed Jan 4, 2013
Showing with 5,428 additions and 0 deletions.
  1. +47 −0 .classpath
  2. +6 −0 .gitignore
  3. +32 −0 .project
  4. +44 −0 DatabaseMigrationJaxbGrailsPlugin.groovy
  5. +1 −0 application.properties
  6. +63 −0 build.xml
  7. +5 −0 doc.sh
  8. +25 −0 grails-app/conf/BuildConfig.groovy
  9. +7 −0 grails-app/conf/Config.groovy
  10. +14 −0 grails-app/conf/DataSource.groovy
  11. +29 −0 grails-app/migrations/changelog.groovy
  12. +1 −0 grails-app/migrations/changelog.sql
  13. +17 −0 grails-app/migrations/changelog.xml
  14. +9 −0 release.sh
  15. +1 −0 src/docs/guide/1 Introduction to the Database Migration JAXB Plugin.gdoc
  16. +4 −0 src/docs/guide/1.1 History.gdoc
  17. +17 −0 src/docs/guide/2 Getting Started.gdoc
  18. +114 −0 src/docs/guide/3 Usage.gdoc
  19. +44 −0 src/groovy/grails/plugin/databasemigration/jaxb/JaxbChangeLogMarshaller.groovy
  20. +74 −0 src/groovy/grails/plugin/databasemigration/jaxb/JaxbChangeLogParser.groovy
  21. +49 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/AddAutoIncrement.groovy
  22. +39 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/AddColumn.groovy
  23. +61 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/AddDefaultValue.groovy
  24. +65 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/AddForeignKeyConstraint.groovy
  25. +57 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/AddLookupTable.groovy
  26. +41 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/AddNotNullConstraint.groovy
  27. +45 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/AddPrimaryKey.groovy
  28. +57 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/AddUniqueConstraint.groovy
  29. +47 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/AlterSequence.groovy
  30. +69 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/And.groovy
  31. +33 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/ChangeLogPropertyDefined.groovy
  32. +37 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/ChangeSetExecuted.groovy
  33. +88 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/Column.groovy
  34. +37 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/ColumnExists.groovy
  35. +59 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/Constraints.groovy
  36. +55 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/CreateIndex.groovy
  37. +39 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/CreateProcedure.groovy
  38. +51 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/CreateSequence.groovy
  39. +51 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/CreateTable.groovy
  40. +41 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/CreateView.groovy
  41. +85 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/CustomChange.groovy
  42. +68 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/CustomPrecondition.groovy
  43. +774 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/DatabaseChangeLog.groovy
  44. +29 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/Dbms.groovy
  45. +47 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/Delete.groovy
  46. +32 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/DropAllForeignKeyConstraints.groovy
  47. +35 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/DropColumn.groovy
  48. +41 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/DropDefaultValue.groovy
  49. +35 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/DropForeignKeyConstraint.groovy
  50. +40 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/DropIndex.groovy
  51. +41 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/DropNotNullConstraint.groovy
  52. +37 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/DropPrimaryKey.groovy
  53. +47 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/DropSequence.groovy
  54. +35 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/DropTable.groovy
  55. +41 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/DropUniqueConstraint.groovy
  56. +33 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/DropView.groovy
  57. +67 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/ExecuteCommand.groovy
  58. +55 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/FkCascadeActionOptions.groovy
  59. +37 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/ForeignKeyConstraintExists.groovy
  60. +41 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/IndexExists.groovy
  61. +39 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/Insert.groovy
  62. +133 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/LoadData.groovy
  63. +137 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/LoadUpdateData.groovy
  64. +52 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/MergeColumns.groovy
  65. +41 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/ModifyDataType.groovy
  66. +68 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/Not.groovy
  67. +613 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/ObjectFactory.groovy
  68. +32 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/OnChangeLogPreconditionErrorOrFail.groovy
  69. +34 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/OnChangeLogPreconditionOnSqlOutput.groovy
  70. +36 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/OnChangeSetPreconditionErrorOrFail.groovy
  71. +32 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/OnChangeSetValidationFail.groovy
  72. +68 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/Or.groovy
  73. +37 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/PrimaryKeyExists.groovy
  74. +41 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/RenameColumn.groovy
  75. +35 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/RenameTable.groovy
  76. +35 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/RenameView.groovy
  77. +142 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/Rollback.groovy
  78. +29 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/RunningAs.groovy
  79. +33 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/SequenceExists.groovy
  80. +52 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/Sql.groovy
  81. +33 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/SqlCheck.groovy
  82. +49 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/SqlFile.groovy
  83. +28 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/Stop.groovy
  84. +33 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/TableExists.groovy
  85. +29 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/TagDatabase.groovy
  86. +53 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/Update.groovy
  87. +33 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/ViewExists.groovy
  88. +9 −0 src/groovy/org/liquibase/xml/ns/dbchangelog/package-info.java
  89. +31 −0 src/java/grails/plugin/databasemigration/jaxb/JaxbChangelogGenerator.java
  90. +43 −0 test/integration/grails/plugin/databasemigration/jaxb/CreateDepartment2Table.groovy
  91. +77 −0 test/integration/grails/plugin/databasemigration/jaxb/CreateDepartmentTable.java
  92. +126 −0 test/integration/grails/plugin/databasemigration/jaxb/ParserTests.groovy
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/groovy"/>
+ <classpathentry kind="src" path="src/java"/>
+ <classpathentry kind="src" path="src/docs"/>
+ <classpathentry kind="src" path="grails-app/conf"/>
+ <classpathentry kind="src" path="grails-app/migrations"/>
+ <classpathentry kind="src" path="test/integration"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry excluding="BuildConfig.groovy|*DataSource.groovy|UrlMappings.groovy|Config.groovy|BootStrap.groovy|spring/resources.groovy" kind="src" path=".link_to_grails_plugins/database-migration-1.3.2/grails-app/conf">
+ <attributes>
+ <attribute name="org.grails.ide.eclipse.core.SOURCE_FOLDER" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path=".link_to_grails_plugins/database-migration-1.3.2/grails-app/controllers">
+ <attributes>
+ <attribute name="org.grails.ide.eclipse.core.SOURCE_FOLDER" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path=".link_to_grails_plugins/database-migration-1.3.2/grails-app/views">
+ <attributes>
+ <attribute name="org.grails.ide.eclipse.core.SOURCE_FOLDER" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path=".link_to_grails_plugins/database-migration-1.3.2/src/groovy">
+ <attributes>
+ <attribute name="org.grails.ide.eclipse.core.SOURCE_FOLDER" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path=".link_to_grails_plugins/release-2.2.0/src/groovy">
+ <attributes>
+ <attribute name="org.grails.ide.eclipse.core.SOURCE_FOLDER" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path=".link_to_grails_plugins/release-2.2.0/src/java">
+ <attributes>
+ <attribute name="org.grails.ide.eclipse.core.SOURCE_FOLDER" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path=".link_to_grails_plugins/rest-client-builder-1.0.3/src/groovy">
+ <attributes>
+ <attribute name="org.grails.ide.eclipse.core.SOURCE_FOLDER" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.grails.ide.eclipse.core.CLASSPATH_CONTAINER"/>
+ <classpathentry kind="output" path="target/eclipseclasses"/>
+</classpath>
@@ -0,0 +1,6 @@
+*.log
+/target
+/docs
+/grails-*.zip
+/plugin.xml
+.settings
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>grails-database-migration-jaxb</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.grails.ide.eclipse.core.nature</nature>
+ <nature>org.eclipse.jdt.groovy.core.groovyNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+ </natures>
+ <linkedResources>
+ <link>
+ <name>.link_to_grails_plugins</name>
+ <type>2</type>
+ <location>/home/burt/workspace/grails/plugins/grails-database-migration-jaxb/target/plugins</location>
+ </link>
+ </linkedResources>
+</projectDescription>
@@ -0,0 +1,44 @@
+/* Copyright 2013 SpringSource.
+ *
+ * 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.
+ */
+
+import grails.plugin.databasemigration.GrailsChangeLogParser
+import grails.plugin.databasemigration.jaxb.JaxbChangeLogParser
+import liquibase.parser.ChangeLogParserFactory
+
+class DatabaseMigrationJaxbGrailsPlugin {
+ String version = '0.1'
+ String grailsVersion = '2.0 > *'
+ String author = 'Burt Beckwith'
+ String authorEmail = 'beckwithb@vmware.com'
+ String title = 'Grails JAXB Database Migration Plugin'
+ String description = 'Adds support for migrations using JAXB classes'
+ String documentation = 'http://grails-plugins.github.com/grails-database-migration-jaxb/'
+
+ List pluginExcludes = [
+ 'docs/**',
+ 'src/docs/**',
+ 'grails-app/migrations/**'
+ ]
+
+ String license = 'APACHE'
+ def organization = [name: 'SpringSource', url: 'http://www.springsource.org/']
+ def issueManagement = [system: 'Github', url: 'https://github.com/grails-plugins/grails-database-migration-jaxb/issues']
+ def scm = [url: 'https://github.com/grails-plugins/grails-database-migration-jaxb']
+
+ def doWithApplicationContext = { ctx ->
+ // adds support for compiled JAXB .class files
+ ChangeLogParserFactory.instance.register new JaxbChangeLogParser(new GrailsChangeLogParser(ctx))
+ }
+}
@@ -0,0 +1 @@
+app.grails.version=2.0.4
@@ -0,0 +1,63 @@
+<project name='database-migration-jaxb' default='package'>
+
+ <condition property='grails' value='grails.bat'>
+ <os family='windows' />
+ </condition>
+ <property name='grails' value='grails' />
+
+ <macrodef name='grails'>
+ <attribute name='action' />
+ <attribute name='environment' default='dev' />
+ <element name='args' optional='true' />
+ <sequential>
+ <exec executable='${grails}' failonerror='true'>
+ <args />
+ <arg value='@{environment}' />
+ <arg value='@{action}' />
+ </exec>
+ </sequential>
+ </macrodef>
+
+ <target name='clean' description='Cleans generated resources'>
+ <grails action='clean' />
+ <delete><fileset dir='.' includes='*.log*' /></delete>
+ <delete><fileset dir='target' includes='*.log*' /></delete>
+
+ <mkdir dir='grails-app/conf/spring' />
+ </target>
+
+ <target name='test' description='Run unit tests' depends='clean'>
+ <delete file='target/stacktrace.log' />
+ <delete dir='target/cli-output' />
+ <delete dir='target/testdb' />
+
+ <grails action='test-app' environment='test' />
+
+ <delete dir='target/cli-output' />
+ <delete dir='target/testdb' />
+ </target>
+
+ <target name='package' description='Package the plugin'
+ depends='test, doPackage, post-package-cleanup' />
+
+ <target name='doPackage'>
+ <grails action='package-plugin' />
+ </target>
+
+ <target name='post-package-cleanup' description='Deletes unneeded folders'>
+ <delete dir='grails-app/conf/hibernate' />
+ <delete dir='grails-app/conf/spring' />
+ <delete dir='grails-app/controllers' />
+ <delete dir='grails-app/domain' />
+ <delete dir='grails-app/i18n' />
+ <delete dir='grails-app/services' />
+ <delete dir='grails-app/taglib' />
+ <delete dir='grails-app/utils' />
+ <delete dir='grails-app/views' />
+ <delete dir='lib' />
+ <delete dir='scripts' />
+ <delete dir='test/unit' />
+ <delete dir='web-app' />
+ </target>
+
+</project>
5 doc.sh
@@ -0,0 +1,5 @@
+rm -rf docs
+grails doc --pdf
+rm -rf docs/manual/api
+rm -rf docs/manual/gapi
+grails add-tracking
@@ -0,0 +1,25 @@
+grails.project.work.dir = 'target'
+grails.project.target.level = 1.7
+grails.project.docs.output.dir = 'docs/manual' // for backwards-compatibility, the docs are checked into gh-pages branch
+
+grails.project.dependency.resolution = {
+
+ inherits 'global'
+ log 'warn'
+
+ repositories {
+ grailsCentral()
+ }
+
+ plugins {
+ build ':release:2.2.0', ':rest-client-builder:1.0.3', {
+ export = false
+ }
+
+ compile ":hibernate:$grailsVersion", {
+ export = false
+ }
+
+ compile ':database-migration:1.3.2'
+ }
+}
@@ -0,0 +1,7 @@
+log4j = {
+ error 'org.codehaus.groovy.grails',
+ 'org.springframework',
+ 'org.hibernate',
+ 'net.sf.ehcache.hibernate'
+ debug 'grails.plugin.databasemigration'
+}
@@ -0,0 +1,14 @@
+dataSource {
+ pooled = true
+ driverClassName = 'org.h2.Driver'
+ username = 'sa'
+ password = ''
+ dbCreate = 'update'
+ url = 'jdbc:h2:mem:testDb'
+}
+
+hibernate {
+ cache.use_second_level_cache = false
+ cache.use_query_cache = false
+ cache.provider_class = 'org.hibernate.cache.EhCacheProvider'
+}
@@ -0,0 +1,29 @@
+databaseChangeLog = {
+
+ changeSet(author: 'burt', id: 't1') {
+ createTable(tableName: 't1') {
+ column(autoIncrement: true, name: 'id', type: 'BIGINT') {
+ constraints(nullable: false, primaryKey: true)
+ }
+ column(name: 'name', type: 'VARCHAR(255)') {
+ constraints(nullable: false)
+ }
+ }
+ }
+
+ include file: 'changelog.xml'
+
+ include file: 'grails.plugin.databasemigration.jaxb.CreateDepartmentTable.class'
+
+ include file: 'grails.plugin.databasemigration.jaxb.CreateDepartment2Table.class'
+
+ changeSet(author: 'burt', id: 'change_t2') {
+ addColumn(tableName: 't2') {
+ column(name: 'new_col', type: 'varchar(123)') {
+ constraints(nullable: false)
+ }
+ }
+ }
+
+ include file: 'changelog.sql'
+}
@@ -0,0 +1 @@
+create table ssqqll (id varchar(255) not null, bytes binary(100000) not null, primary key (id));
@@ -0,0 +1,17 @@
+<?xml version='1.0' encoding='UTF-8' standalone='no'?>
+<databaseChangeLog xmlns='http://www.liquibase.org/xml/ns/dbchangelog'
+ xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+ xsi:schemaLocation='http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd'>
+
+ <changeSet author='burt' id='t2'>
+ <createTable tableName='t2'>
+ <column autoIncrement='true' name='id' type='BIGINT'>
+ <constraints nullable='false' primaryKey='true' />
+ </column>
+ <column name='name' type='VARCHAR(255)'>
+ <constraints nullable='false' />
+ </column>
+ </createTable>
+ </changeSet>
+
+</databaseChangeLog>
@@ -0,0 +1,9 @@
+rm -rf target/release
+mkdir target/release
+cd target/release
+git clone git@github.com:grails-plugins/grails-database-migration-jaxb.git
+cd grails-database-migration-jaxb
+grails clean
+grails compile
+#grails publish-plugin --noScm --snapshot --stacktrace
+grails publish-plugin --noScm --stacktrace
@@ -0,0 +1 @@
+The Database Migration JAXB plugin extends the Database Migration plugin to add the ability to write changelogs in Java or Groovy code using JAXB classes.
@@ -0,0 +1,4 @@
+h4. History
+
+* January 5, 2013
+** initial 0.1 release
@@ -0,0 +1,17 @@
+h4. The first step is to add a dependency for the plugin in @BuildConfig.groovy@:
+
+{code}
+plugins {
+ ...
+ runtime ':database-migration-jaxb:0.1'
+}
+{code}
+
+This should pull in the @database-migration@ plugin transitively but you can also explicitly add in a dependency for that, in particular if you want to use a newer version than the plugin requires:
+
+{code}
+plugins {
+ ...
+ runtime ':database-migration:1.3.2'
+}
+{code}
Oops, something went wrong.

0 comments on commit e47b653

Please sign in to comment.