Anonymous avatar Anonymous committed 751b803

first import

Comments (0)

Files changed (6)

+-*- markdown -*-
+
+# Changes and TODO
+
+## TODO (Please contribute feedback, ideas, code, documentation, donation...)
+
+- [TODO] DSL for specifying change-set in Clojure and convert to XML at runtime
+
+
+## 0.1 / 2010-Nov-?? (GMT + 5:30)
+
+- Proxy commands to Liquibase (from the plugin)
+- Pull in Liquibase and Open Source JDBC Drivers as Maven dependencies
+- Command for displaying comprehensive sample properties (liquibase.properties)
+- Help command
+-*- markdown -*-
+
+# Lein-LB v0.1
+
+Leiningen plugin for Liquibase: http://www.liquibase.org/ a database change management software.
+
+
+## Usage
+
+Leiningen dependency details are here: [http://clojars.org/org.bituf/lein-lb](http://clojars.org/org.bituf/lein-lb)
+
+
+## Building/Installation
+
+lein deps
+lein install
+
+
+## License
+
+Copyright (C) 2010 Shantanu Kumar (kumar.shantanu at gmail dot com)
+
+Distributed under the Apache 2 License.
+
+
+# Tutorial
+
+Include Lein-LB as a dev dependency in project.clj:
+
+    :dev-dependencies [[org.bituf/lein-lb "0.1-SNAPSHOT"]]
+
+And then
+
+    lein deps
+    lein lb
+
+Ideally you would need to s
+(defproject org.bituf/lein-lb "0.1-SNAPSHOT"
+  :description "Leiningen plugin for Liquibase: http://www.liquibase.org/"
+  :dependencies [[org.bituf/oss-jdbc           "0.1"]
+                 [org.liquibase/liquibase-core "2.0-rc6"]]
+  :dev-dependencies [[org.clojure/clojure         "1.2.0"]
+                     [org.clojure/clojure-contrib "1.2.0"]])

src/leiningen/lb.clj

+(ns leiningen.lb
+  (:require [clojure.contrib.duck-streams :as ds]))
+
+(def *version* "0.1-SNAPSHOT (uses Liquibase 2.0-RC6)")
+
+;; DSL
+
+(defn help
+  []
+  (println
+    (str "
+Lein-LB - Lein Liquibase plugin " *version* "
+
+For help on Liquibase commands:
+
+    $ lein lb help
+
+Lein-LB commands (they all begin with a colon):
+    :help               prints this help screen
+    :sample-properties  prints sample properties to put in liquibase.properties
+"
+      )))
+
+
+(defn sample-props
+  []
+  (let [filename "/liquibase.properties"
+        istream  (.getResourceAsStream String filename)
+        owriter  (java.io.StringWriter.)]
+    ;; InputStream resourceAsStream = getClass().getResourceAsStream("/mypackage/mysubpackage/myfile.txt");
+    (ds/copy istream owriter)
+    (println (.toString owriter))))
+
+
+(defn execute-liquibase-cmd
+  "Execute Liquibase as if using command-line arguments (String array)"
+  [argv]
+  (liquibase.integration.commandline.Main/main argv))
+
+
+;; ----- Leiningen plugin command -----
+
+(defn lb
+  [& args]
+  (let [argc (count args)
+        argv (into-array String args)
+        cmd  (first args)]
+    ;; check for lein-lb commands
+    (cond
+      (empty? args)                (help)
+      (= cmd ":help")              (help)
+      (= cmd ":sample-properties") (sample-props)
+      :else                        (execute-liquibase-cmd argv))))

src/liquibase.properties

+###
+### liquibase.properties (uncomment lines as required)
+###
+### More details here: http://www.liquibase.org/manual/command_line
+###
+
+
+## ----- Required Parameters -----
+
+## Migration file
+#changeLogFile=<path and filename>
+
+## Database username
+#username=<value>
+
+## Database password
+#password=<value>
+
+## Database URL
+#url=<value>
+
+
+## ----- Optional Parameters -----
+
+## Classpath containing migration files and JDBC Driver
+#classpath=<value>
+
+## Database driver class name
+#driver=<jdbc.driver.ClassName>
+
+
+## custom liquibase.database.Database implementation to use
+#databaseClass=<database.ClassName>
+
+## Default database schema to use
+#defaultSchemaName=<name>
+
+## ChangeSet contexts to execute
+#contexts=<value>
+
+## File with default option values (default: ./liquibase.properties)
+#defaultsFile=</path/to/file.properties>
+
+## Include the system classpath in the Liquibase classpath (default: true)
+#includeSystemClasspath=<true|false>
+
+## Prompt if non-localhost databases (default: false)
+#promptForNonLocalDatabase=<true|false>
+
+## Execution log level (debug, info, warning, severe, off)
+#logLevel=<level>
+
+## Log file
+#logFile=<file>
+
+## Overrides current date time function used in SQL. Useful for
+## unsupported databases.
+#currentDateTimeFunction=<value>
+
+
+## ----- Required Diff Parameters -----
+
+## Reference Database username
+#referenceUsername=<value>
+
+## Reference Database password
+#referencePassword=<value>
+
+## Reference Database URL
+#referenceUrl=<value>
+
+
+## ----- Optional Diff Parameters -----
+
+## Reference Database driver class name
+#referenceDriver=<jdbc.driver.ClassName>
+
+## Output data as CSV in the given directory
+#dataOutputDirectory=DIR

test/leiningen/test/lb.clj

+(ns leiningen.test.lb
+  (:use [leiningen.lb] :reload)
+  (:use [clojure.test]))
+
+(deftest replace-me ;; FIXME: write
+  (is false "No tests have been written."))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.