1

(開発中の) grails プラグインと、grails プラグインをテストするために使用するテスト アプリがあるとします。プラグインの _Install.groovy スクリプトをテストしようとしていますが、毎回かなりのプロセスです。

次のプロセスを自動化するために gant または bash を使用する方法をお勧めしますか?

  1. プラグインのバージョンを上げる
  2. プラグインをパッケージ化する
  3. プラグインがテスト アプリに既にインストールされているかどうかを確認し、インストールされている場合は削除します。
  4. プラグインを再インストールします。

とても有難い、

4

1 に答える 1

0

私にとっての答えは、groovy/GANT スクリプトを作成し、コマンド ラインから実行することでした。

私のプラグインにはscriptsディレクトリがあり、そこに というスクリプトを作成しましたDeploy.groovy

コマンドの実行

grails deploy

このスクリプトを自動的に実行します。このスクリプトは、組み込みの grails ターゲットを使用してプラグインをパッケージ化し、コマンドラインから grails コマンドを実行します。

plugin-home/scripts/Deploy.groovy

includeTargets << grailsScript("PackagePlugin_")
includeTool << gant.tools.Execute


target(main: "This is the script that tries to test what's going on...") {

    println ("1. Package the plugin")
    packagePlugin()

    println ("2. Confirm the directory")
    execute.shell("cd ~/quirk-projects/admin-cms-plugin-test && pwd")

    println ("3. Remove the plugin ")
    execute.shell("cd ~/quirk-projects/admin-cms-plugin-test && grails uninstall-plugin grails-admin-cms-plugin")

    println ("4. Install the plugin ")
    execute.shell("cd ~/quirk-projects/admin-cms-plugin-test && grails install-plugin ../admin-cms-plugin/grails-admin-cms-plugin-0.1.zip")

    println ("5. Run Application")
    execute.shell("cd ~/quirk-projects/admin-cms-plugin-test && grails run-app")

    println ("6. Your plugin is ready for testing...")

}

setDefaultTarget(main)

インクリメントするには、ソース ファイルを編集してバージョン番号をインクリメントするだけのスクリプトを作成しました。

plugin-home/scripts/_Events.groovy

eventCompileStart = { kind ->

    println("Incrementing Version Number for next time")

    def version = metadata.'version'

    if (!version) {
        version = '1'
    } else {
        version = version.toInteger() + 1
    }
    metadata.'version' = version.toString()
    metadata.persist()

    def file = new File("${basedir}/AdminCmsPluginGrailsPlugin.groovy")
    def script = file.text
    def array = script.split("\n")
    for (int i = 0 ; i < array.length; i++) {
        if (array[i].indexOf("def version") > -1) {
            array[i] = "    def version = 0." + version
        }
    }

    def newScript = array.join(System.getProperty("line.separator"))

    file.text = newScript


}
于 2013-04-03T14:50:43.383 に答える