2014年1月29日水曜日

Gradleを使ってEclipse 4.3+Groovy Eclipse+Gradle IDEをインストール

Gradleを使って、Eclipse 4.3+Groovy Eclipse+Gradle IDEをインストールするためのbuild.gradleは、以下の通り。

project.ext.tempDir = 'tmp'
project.ext.targetEclipseDir = 'd:/eclipseGroovy'
ant.condition(property: "os", value: "windows") { os(family: "windows") }
ant.condition(property: "os", value: "unix" ) { os(family: "unix") }
task clean << { delete 'tmp' }
task installEclipse << {
new File(tempDir).mkdirs()
ant.get(dest:tempDir, skipexisting:true){
url(url:"http://ftp.jaist.ac.jp/pub/eclipse/technology/epp/downloads/release/kepler/SR1/eclipse-rcp-kepler-SR1-win32-x86_64.zip")
}
ant.unzip(dest:tempDir, overwrite:"false"){
fileset(dir: project.tempDir){ include (name:'*.zip')}
}
ant.move(toDir: project.targetEclipseDir){
fileset(dir: "${tempDir}/eclipse")
}
// ant.copy(file:'files/eclipse.ini', toDir: targetEclipseDir)
}
def getCommandList(String command){
def commandList = [
"${targetEclipseDir}/eclipse",
"-application",
"org.eclipse.equinox.p2.director",
"-noSplash"
]+
command.replaceAll(/,[^\\]\n/, ',').replaceAll(/[^\\]\n/, ' ').split(/\s+/) +
[
"-vmargs",
"-Dlogback.configurationFile=logback.xml"
]
if(ant.properties.os == 'windows'){
commandList = ['cmd', '/c']+ commandList
}
commandList.flatten()
}
task installPlugins(type:Exec) {
ext.command = """\
-repository http://dist.springsource.org/snapshot/GRECLIPSE/e4.3/,^
http://dist.springsource.com/release/TOOLS/gradle^
-installIUs org.codehaus.groovy.eclipse.feature.feature.group,^
org.springsource.ide.eclipse.gradle.feature.feature.group^
-d ${targetEclipseDir}"""
commandLine getCommandList(command)
}
task uninstallPlugins(type:Exec) {
ext.command = """\
-repository http://dist.springsource.org/snapshot/GRECLIPSE/e4.3/,^
http://dist.springsource.com/release/TOOLS/gradle^
-uninstallIUs org.codehaus.groovy.eclipse.feature.feature.group,^
org.springsource.ide.eclipse.gradle.feature.feature.group^
-d ${targetEclipseDir}"""
commandLine getCommandList(command)
}
installPlugins.mustRunAfter installEclipse
task wrapper(type: Wrapper) { gradleVersion = '1.9' }
view raw build.gradle hosted with ❤ by GitHub

基本的な使い方については、『Gradleを使ってEclipseとEclipse Pluginをインストール』を参照のこと。『Gradleを使ってEclipseとEclipse Pluginをインストール』からの変更点は、以下の通り。

  • installEclipseタスクでインストールするEclipseを Kepler (4.3.1) SR1に変更 (12行目)
  • installPluginsタスクで使用するGroovyEclipseのリポジトリに、Eclipse 4.3のsnapshotを指定(44行目)
    • releaseを指定すると、Window -> Preferences -> Groovy にある、Use Monospace font for JUnitのチェックボックスのオンオフができない
  • uninstallPluginsタスクを追加。(54-63行目)
    • gradle uninstallPluginsで、Groovy EclipseとGradle IDEのアンインストールが可能。
    • リポジトリに、Eclipse本体のUpdate Siteを指定している点に注意。これを指定しないと、依存関係が解決できず、アンインストールが正常に終了しない。

2014年1月28日火曜日

Oracleでテーブルに存在しない複数行データを生成する

Oracleで、テーブルに存在しない複数行データを生成するSQLは、以下の通り。

SELECT
        CASE ROWNUM
            WHEN 1 THEN 'a'
            WHEN 2 THEN 'b'
            WHEN 3 THEN 'c'
        END AS COL
    FROM
        dual CONNECT BY ROWNUM <= 3;

EXISTS句などで、抽出条件となるSELECT文をテーブルを使わず書きたい時に便利。

関連リンク