読者です 読者をやめる 読者になる 読者になる

GroovyFXのデモをgradleを使って起動ができない・・・の対処

Groovy GroovyFX Gradle

GroovyFXのデモをgradleを使って起動ができない・・・



こういうことかな?

dependencies {
    groovy 'org.codehaus.groovy:groovy-all:1.8.0'
    compile 'asm:asm:3.2'
    compile files("${javafxHome}/rt/lib/jfxrt.jar")
    groovy files("${javafxHome}/rt/lib/jfxrt.jar")
}

実行!

[C:\usr\opt\GroovyFX\GroovyFX-0.1]gradle AnalogClockDemo
:compileJava UP-TO-DATE
:compileGroovy UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileDemoJava UP-TO-DATE
:compileDemoGroovy
>>> a serious error occurred: org/objectweb/asm/Opcodes
>>> stacktrace:
java.lang.NoClassDefFoundError: org/objectweb/asm/Opcodes
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:791)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:410)
        at groovy.lang.GroovyClassLoader.loadClass(GroovyClassLoader.java:696)
        at org.codehaus.groovy.transform.ASTTransformationCollectorCodeVisitor.addTransformsToClassNode(ASTTransformationCollectorCodeVisitor.java:97)
        at org.codehaus.groovy.transform.ASTTransformationCollectorCodeVisitor.visitAnnotations(ASTTransformationCollectorCodeVisitor.java:77)
        at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClass(ClassCodeVisitorSupport.java:47)
        at org.codehaus.groovy.transform.ASTTransformationCollectorCodeVisitor.visitClass(ASTTransformationCollectorCodeVisitor.java:59)
        at org.codehaus.groovy.transform.ASTTransformationVisitor$1.call(ASTTransformationVisitor.java:156)
        at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.j
FAILURE: Build failed with an exception.

NoClassDefFoundErrorのクラスが変わった。
jfxrt.jarは有効になったようだ。


asmも足りないようなので、追加。

dependencies {
    groovy  'org.codehaus.groovy:groovy-all:1.8.0'
    compile 'asm:asm:3.2'
    compile files("${javafxHome}/rt/lib/jfxrt.jar")
    groovy  files("${javafxHome}/rt/lib/jfxrt.jar")
    groovy  'asm:asm:3.2'
}


実行!!

[C:\usr\opt\GroovyFX\GroovyFX-0.1]gradle AnalogClockDemo
:compileJava UP-TO-DATE
:compileGroovy UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileDemoJava UP-TO-DATE
:compileDemoGroovy
:processDemoResources
:demoClasses
> Building > :AnalogClockDemo


よし、起動した。

差分
diff U3 C:/Documents and Settings/orangeclover/Local Settings/Temp/build.gradl-revBASE.svn001.tmp.gradle C:/usr/opt/GroovyFX/GroovyFX-0.1/build.gradle
--- C:/Documents and Settings/orangeclover/Local Settings/Temp/build.gradl-revBASE.svn001.tmp.gradle	Thu Dec 01 22:31:33 2011
+++ C:/usr/opt/GroovyFX/GroovyFX-0.1/build.gradle	Thu Dec 01 22:32:54 2011
@@ -33,6 +33,8 @@
     groovy 'org.codehaus.groovy:groovy-all:1.8.0'
     compile 'asm:asm:3.2'
     compile files("${javafxHome}/rt/lib/jfxrt.jar")
+    groovy files("${javafxHome}/rt/lib/jfxrt.jar")
+    groovy  'asm:asm:3.2'
 }
 
 uploadArchives {
build.gradle
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'signing'

// Set Maven coordinates
group = 'org.codehaus.groovy.modules.groovyfx'
archivesBaseName = "groovyfx"
version = '0.1-SNAPSHOT'

// Read environment and set properties
javafxHome = System.env['JAVAFX_HOME']
isRelease = !version.endsWith('SNAPSHOT')

// Define a source set for the non-standard src/demo directory
sourceSets {
    demo {
        compileClasspath += sourceSets.main.output
        runtimeClasspath += sourceSets.main.output
        groovy {
            srcDir = 'src/demo/groovy'
        }
        resources {
            srcDir = 'src/demo/resources'
        }
    }
}

repositories {
    mavenCentral()
}

dependencies {
    groovy 'org.codehaus.groovy:groovy-all:1.8.0'
    compile 'asm:asm:3.2'
    compile files("${javafxHome}/rt/lib/jfxrt.jar")
    groovy files("${javafxHome}/rt/lib/jfxrt.jar")
    groovy  'asm:asm:3.2'
}

uploadArchives {
    repositories.mavenDeployer {
        repository(url: 'https://nexus.codehaus.org/content/repositories/snapshots/') {
            authentication()
        }
        //repository(url: "file:///Users/dean/temp/m2")
        pom.project {
            name 'GroovyFX'
            url 'http://groovy.codehaus.org/GroovyFX'
            description 'Groovy bindings for JavaFX 2.x'
            packaging 'jar'
            licenses {
                license {
                    name 'The Apache Software License, Version 2.0'
                    url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    distribution 'repo'
                }
            }
            scm {
                developerConnection 'scm:https://svn.codehaus.org/gmod/groovyfx/'
                connection 'scm:http://svn.codehaus.org/gmod/groovyfx/'
                tag 'trunk'
                url 'http://fisheye.codehaus.org/browse/gmod/groovyfx/'
            }
            developers {
                developer { name 'Jim Clarke' }
                developer { name 'Dean Iverson' }
            }
        }
    }
}

// Add a dynamic task to run each of the demos in src/demo/groovy
new File('src/demo/groovy').eachFileMatch(~/.*Demo.groovy/) { file ->
    def taskName = file.name - '.groovy'
    task "$taskName"(type: JavaExec) {
        group = "Demo"
        description = "Run the $taskName program"
        main = taskName
        classpath sourceSets.main.runtimeClasspath + sourceSets.demo.runtimeClasspath
    }
}










Hans Dockter、Tim Berglund、Matthew Mccullough
参考価格 : ¥ 2,051


価格: ¥ 2,029


価格は記載時点のものです。購入前にAmazonでご確認ください。




今日からGroovyを始めるための4つのステップ






関谷 和愛、上原 潤二、須江 信洋、中野 靖治
価格: ¥ 3,360
価格は記載時点のものです。購入前にAmazonでご確認ください。





「プログラミングGROOVY」正誤表