Problem
When building projects with GUI Designer forms using an external build system (Maven/Gradle), the forms are not compiled and the code doesn't work, failing with NullPointerException when trying to access some component.
Reason
When using the IntelliJ IDEA build system, the forms are compiled automatically and instrumented into the class bytecode during the build process. Gradle and Maven are not aware of the .form files and don't perform any bytecode instrumentation.
Solutions
-
Use custom build scripts that call
javac2forms compiler via Ant: Gradle / Maven. -
Enable Settings | Editor | GUI Designer | Generate GUI into: Java Source code and build the project in IntelliJ IDEA to update the generated code every time you make a change to the
.formfile. You will also needjava-gui-forms-rtdependency added inpom.xml/build.gradle. -
Disable build delegation to Gradle: Settings | Build, Execution, Deployment | Build Tools | Gradle | Build and run using: IntelliJ IDEA.
-
Disable build delegation to Maven: Settings | Build, Execution, Deployment | Build Tools | Maven | Runner | Delegate IDE build/run actions to Maven (uncheck).
Related issues and resources
- https://stackoverflow.com/questions/32747917/intellij-gui-designer-maven-executable-jar-export
- https://stackoverflow.com/questions/19049253/intellij-idea-gui-designer-maven
- https://youtrack.jetbrains.com/issue/IDEA-151118/Offical-maven-plugin-for-IntelliJ-GUI-Designer
- https://youtrack.jetbrains.com/issue/IDEA-207997/GUI-setupUI-is-not-generated-if-build-and-run-using-gradle-is-selected
Comments
0 comments
Please sign in to leave a comment.