IntelliJ IDEA的13 UI设计师和自动摇篮建设 [英] Intellij Idea 13 UI Designer and automatic Gradle building

查看:1150
本文介绍了IntelliJ IDEA的13 UI设计师和自动摇篮建设的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的IntelliJ UI设计器创建一个项目的形式。一切工作正常,当我有想法建筑,因为它处理编译形式对我来说,但我们最近转用摇篮构​​建它已经不可能产生一个可执行的JAR文件呢。

I've used the Intellij UI Designer to create forms for a project. Everything works fine when I'm building with idea as it handles compiling the forms for me, but as we recently switched to using Gradle for building it hasn't been possible to produce an executable jar file yet.

我的谷歌福引发我的几个职位,说明了一个Ant脚本需要编译(例如的链接链接2 ,<一个href=\"http://stackoverflow.com/questions/10482610/intellij-idea-gui-builder-no-java-$c$c-generated\">link3 ,这也是我在下面的结束: LINK4

My google-fu has led me to several posts that explains that an ant script is needed to compile (eg link, link2, link3 ,and the one i ended on following: link4)

我的项目是一个多模块的设置。

My project is a multi-module setup.

根的build.gradle

subprojects {
    apply plugin: 'java'
    apply plugin: 'idea'

    repositories {
        mavenCentral()
    }
}

supproject的build.gradle

apply plugin:'application'
mainClassName = "dk.OfferFileEditor.OfferFileEditorProgram"

configurations {
    antTask
}

dependencies {
    compile 'org.json:json:20140107'
    compile project(":Shared:HasOffers Api")

    //dependencies for java2c
    antTask files('../../lib/javac2-13.1.1.jar', '../../lib/asm4-all-13.1.1-idea.jar', '../../lib/forms_rt-13.1.1.jar')
    antTask group: 'org.jdom', name: 'jdom', version: '1.1'
}

task compileJava(overwrite: true, dependsOn: configurations.compile.getTaskDependencyFromProjectDependency(true, 'jar')) {
    doLast {
        println 'using java2c to compile'
        project.sourceSets.main.output.classesDir.mkdirs()
        ant.taskdef name: 'javac2', classname: 'com.intellij.ant.Javac2', classpath: configurations.antTask.asPath
        ant.javac2 srcdir: project.sourceSets.main.java.srcDirs.join(':'),
                classpath: project.sourceSets.main.compileClasspath.asPath,
                destdir: project.sourceSets.main.output.classesDir,
                source: sourceCompatibility,
                target: targetCompatibility,
                includeAntRuntime: false
    }
}

不过尽管编译是全成,一个空指针异常被抛出我第一次尝试访问UI设计器创建的领域之一。因此,一些没有被正确编译。

But even though the compilation is successfull, a Nullpointer exception is thrown the first time I try to access one of the fields the UI Designer created. So something is not being compiled correctly.

我可能错过了一些设置,但经过unsuccesfully浇几个小时到论坛和谷歌我还没有找到任何解决办法。

I'm probably missing some setting, but after unsuccesfully pouring several hours into forums and google I still haven't found any solution.

推荐答案

所以我做了这个有很多比需求更复杂的是。

So I made this a lot more complicated than needs be.

要使它工作,你需要改变你的项目两件事情。

To make it work you need to change two things in your project.

设置 - > GUI设计器 - >生成GUI为: Java源代码code

Settings -> GUI Designer -> Generate GUI into: Java source code

这使得IntelliJ IDEA的添加3种方法为你的表格底部:

This makes IntelliJ IDEA add 3 methods into the bottom of your forms:


  • $$$ setupUI $$$()

  • $$$ setupUI $$$()

  • $$$ getRootComponent $$$()

如果有遗漏的尝试更改设置后重新编译您的项目。

If they are missing try recompiling your project after you change the setting.

的IntelliJ有一个名为 forms_rt.jar 罐子,我发现矿{IntelliJ IDEA的根目录} \\ lib中。并更名为 forms_rt-13.1.1.jar

Intellij has a jar called forms_rt.jar, and I found mine in {IntelliJ IDEA Root}\lib. And renamed it to "forms_rt-13.1.1.jar"

这需要在编译时到您的项目被列入。如果你像我一样用摇篮,你可以把它复制到{项目的根} / lib和添加一个平面文件存储库,像这样:

This needs to be included during compile time to your project. If you are using Gradle as I did you could copy it to {project root}/lib and add a flatfile repository like so:

repositories {
    mavenCentral()
    flatDir dirs: "${rootDir}/lib"
}

在你需要把它列入你的Gradle项目文件:

After that you need to include it in your project gradle file:

dependencies {
    compile name: 'forms_rt', version: '13.1.1'
}

在,它应该是有可能建立它无论在IntelliJ IDEA的和摇篮

After that it should be possible to build it both in IntelliJ IDEA and Gradle.

这篇关于IntelliJ IDEA的13 UI设计师和自动摇篮建设的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆