首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用gradle运行GroovyFX应用程序

用gradle运行GroovyFX应用程序
EN

Stack Overflow用户
提问于 2014-09-15 18:41:56
回答 1查看 383关注 0票数 1

我有下一个示例(从groovyfx站点),它是一个简单的窗口。

代码语言:javascript
复制
import static groovyx.javafx.GroovyFX.start

start {
  stage(title: 'GroovyFX Hello World', visible: true) {
    scene(fill: BLACK, width: 700, height: 250) {
      hbox(padding: 60) {
        text(text: 'Groovy', font: '80pt sanserif') {
          fill linearGradient(endX: 0, stops: [PALEGREEN, SEAGREEN])
        }
        text(text: 'FX', font: '80pt sanserif') {
          fill linearGradient(endX: 0, stops: [CYAN, DODGERBLUE])
          effect dropShadow(color: DODGERBLUE, radius: 25, spread: 0.25)
        }
      }
    }
  }
}

如何使用gradle run运行它?

我的build.gradle

代码语言:javascript
复制
 apply plugin: 'groovy'

 sourceCompatibility = 1.8
 targetCompatibility = 1.8

 project.ext.set('javafxHome', System.env['JAVAFX_HOME'])

 repositories {
   mavenCentral()
 }

 configurations {
   ivy
 }

 dependencies {
   ivy "org.apache.ivy:ivy:2.3.0"
   compile 'org.codehaus.groovy:groovy-all:2.3.6'
   compile 'org.codehaus.groovyfx:groovyfx:0.4.0'
   compile files("${javafxHome}/rt/lib/jfxrt.jar")
 }


tasks.withType(GroovyCompile) {
  groovyClasspath += configurations.ivy
}

我可能会从IDE运行它,但是如何使用cli运行它,然后如何构建带有主类路径的jar呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-16 09:07:32

它在以下配置中工作。

结构:

  • build.gradle
  • 钢筋混凝土/
      • groovy
        • Main.groovy

build.gradle

代码语言:javascript
复制
apply plugin: 'groovy'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
  mavenCentral()
}

configurations {
  ivy
}

dependencies {
  ivy "org.apache.ivy:ivy:2.3.0"
  compile 'org.codehaus.groovy:groovy-all:2.3.6'
  compile 'org.codehaus.groovyfx:groovyfx:0.4.0'
  compile files("${System.getenv('JAVA_HOME')}/jre/lib/ext/jfxrt.jar")
}

tasks.withType(GroovyCompile) {
  groovyClasspath += configurations.ivy
}

task run(type: JavaExec) {
    main = 'Main'
    classpath sourceSets.main.runtimeClasspath
}

Main.groovy

代码语言:javascript
复制
import static groovyx.javafx.GroovyFX.start

start {
  stage(title: 'GroovyFX Hello World', visible: true) {
    scene(fill: BLACK, width: 700, height: 250) {
      hbox(padding: 60) {
        text(text: 'Groovy', font: '80pt sanserif') {
          fill linearGradient(endX: 0, stops: [PALEGREEN, SEAGREEN])
        }
        text(text: 'FX', font: '80pt sanserif') {
          fill linearGradient(endX: 0, stops: [CYAN, DODGERBLUE])
          effect dropShadow(color: DODGERBLUE, radius: 25, spread: 0.25)
        }
      }
    }
  }
}

你已经看过网站了吗?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25854705

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档