14

I'm trying to use Java 1.8 with lambda expressions with Idea UI Designer, I have in maven:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>ideauidesigner-maven-plugin</artifactId>
    <executions>
        <execution>
            <goals>
                <goal>javac2</goal>
            </goals>
        </execution>
    </executions>

    <configuration>
        <fork>true</fork>
        <debug>true</debug>
        <failOnError>true</failOnError>
    </configuration>
</plugin>

and dependency

<dependency>
    <groupId>com.intellij</groupId>
    <artifactId>forms_rt</artifactId>
    <version>7.0.3</version>
</dependency>

When I try to use lambdas it returns compile error:

Failed to execute goal org.codehaus.mojo:ideauidesigner-maven-plugin:1.0-beta-1:javac2 (default) on project stockbox-chart: Execution default of goal org.codehaus.mojo:ideauidesigner-maven-plugin:1.0-beta-1:javac2 failed: 52264 -> [Help 1]

Do you have any ideas how to use lambdas with Idea UI Designer?

BullyWiiPlaza
  • 17,329
  • 10
  • 113
  • 185
Michał Jurczuk
  • 3,728
  • 4
  • 32
  • 56
  • Did you find a solution for this? – André Feb 01 '16 at 13:19
  • No, If I would have source code I could just update dependencies, maybe you could try to send question to JetBrains? – Michał Jurczuk Feb 01 '16 at 14:09
  • I just found that the problem is JetBrains does not actually have an official maven plugin for the UI designer. The ideauidesigner-maven-plugin is written by somebody else. Would be nice if JetBrains had an offical plugin, but I guess there's not enough demand for it. – André Feb 01 '16 at 14:21
  • So maybe we should try to send message to person who wrote this plugin, do you have contact to that person? – Michał Jurczuk Feb 01 '16 at 14:26
  • He actually previously worked where I work now. I don't know him, but I guess I can contact him and ask. I figured I'll also try and submit a request to JetBrains for an offical plugin as well. – André Feb 01 '16 at 14:30
  • Great, I hope you will fix this very soon, it would be great to be able to use Java 8 everywhere. It's probably about updating dependencies. Let us know if you will know something more, or we can help you anyhow – Michał Jurczuk Feb 01 '16 at 15:26
  • Did you find any solution for this bug? – Michał Jurczuk Apr 04 '16 at 06:50
  • No sorry, ended up not using the UI designer at all. – André Apr 05 '16 at 10:25
  • 1
    You should check [this](https://stackoverflow.com/a/45125398/3764804) answer since it works fine for me. – BullyWiiPlaza Oct 26 '17 at 19:19

4 Answers4

10

One workaround, until such time as someone is able to fix the plugin, is to configure your IntelliJ settings to generate the GUI as source rather than as binaries, then manually re-generate the GUI sources prior to running Maven any time you make a change in GUI designer:

  1. Go to File > Settings and change the selection for Editor > GUI Designer > Generate GUI into: to Java source code.
  2. Whenever you make a GUI change, build the project from IntelliJ to (re-)generate the GUI Java source code (Build >> Build Project).
  3. Optionally, check the generated source into whatever source-control mechanism you're using; this step saves anyone else building your project via Maven from having to do the manual build from IntelliJ later (i.e. so they can build solely via Maven).
  4. If you're using an IntelliJ layout manager (like GridLayoutManager), add com.intellij:forms_rt:7.0.3 as a compile dependency in your pom.xml, if it isn't already there.
  5. Run Maven as usual to build your project.
sumitsu
  • 1,481
  • 1
  • 16
  • 33
0

The problem with the GUI designer is that it does not have a maven straightforward plugin that you can use, because Intellij uses ant to post-manipulate the target .class files. You could use the maven ant plugin:

         <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <dependencies>
                <dependency>
                    <groupId>com.sun</groupId>
                    <artifactId>tools</artifactId>
                    <version>1.7.0</version>
                    <scope>system</scope>
                    <systemPath>${java.home}/../lib/tools.jar</systemPath>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <configuration>
                        <tasks>
                            <path id="j2cp">
                                <fileset dir="${project.basedir}/antlibs" includes="*.jar"/>
                            </path>
                            <path id="j2sp">
                                <pathelement location="${project.basedir}/src/main/java"/>
                            </path>

                            <taskdef name="javac2" classpathref="j2cp" classname="com.intellij.ant.Javac2"/>
                            <javac2 destdir="${project.basedir}/target/classes"> 
                                <src refid="j2sp"/>
                            </javac2>
                        </tasks>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

But you need the javac2 jars to be put in /antlibs, in my project I use these:

  • asm-5.0.3.jar
  • asm-all-7.0.1.jar
  • javac2.jar
  • jdom.jar

You can find these libraries inside your ${Intellij.home}/libs

If you use specific IDE layouts, maybe you will need other specific jars regarding them, the ant plugin will be specific if you missed out something

Luiz Damy
  • 216
  • 2
  • 9
0

The plugin org.codehaus.mojo:ideauidesigner-maven-plugin:1.0-beta-1 has 2 dependencies on the code provided by Jetbrains via com.intellij:javac2:7.0.3 and com.intellij:forms_rt:7.0.3 (both last updated in 2008). These have not been directly updated since, but have modern equivalents hosted by Jetbrains in their own repositories.

All there is to be done is to overwrite the plugin dependencies:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>ideauidesigner-maven-plugin</artifactId>
    <version>1.0-beta-1</version>
    <dependencies>
        <dependency>
            <groupId>com.jetbrains.intellij.java</groupId>
            <artifactId>java-compiler-ant-tasks</artifactId>
            <version>212.5284.40</version>
        </dependency>
        <dependency>
            <groupId>com.jetbrains.intellij.java</groupId>
            <artifactId>java-gui-forms-rt</artifactId>
            <version>212.5284.40</version>
        </dependency>
    </dependencies>
</plugin>

And include Jetbrains plugin repositories

<pluginRepositories>
    <pluginRepository>
        <id>intellij-repository</id>
        <url>https://www.jetbrains.com/intellij-repository/releases</url>
    </pluginRepository>
    <pluginRepository>
        <id>intellij-third-party</id>
        <url>https://cache-redirector.jetbrains.com/intellij-dependencies</url>
    </pluginRepository>
</pluginRepositories>
JockX
  • 1,928
  • 1
  • 16
  • 30
0

As JockX answer sais updating ideauidesigner-maven-plugin dependency can solve the issue.

<properties>
 <maven.compiler.source>11</maven.compiler.source>
 <maven.compiler.target>11</maven.compiler.target>
 <intellij.version>232.8660.211</intellij.version>
 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding
</properties>

<pluginRepositories>
 <pluginRepository>
  <id>intellij-repository</id>
  <url>https://www.jetbrains.com/intellij-repository/releases</url>
 </pluginRepository>
 <pluginRepository>
   <id>intellij-third-party</id>
   <url>https://cache-redirector.jetbrains.com/intellij-dependencies</url>
 </pluginRepository>
</pluginRepositories>

<plugin>
 <groupId>org.codehaus.mojo</groupId>
 <artifactId>ideauidesigner-maven-plugin</artifactId>
 <version>1.0-beta-1</version>
 <dependencies>
  <dependency>
   <groupId>com.jetbrains.intellij.java</groupId>
   <artifactId>java-compiler-ant-tasks</artifactId>
   <version>${intellij.version}</version>
  </dependency>
  <dependency>
   <groupId>com.jetbrains.intellij.java</groupId>
   <artifactId>java-gui-forms-rt</artifactId>
   <version>${intellij.version}</version>
  </dependency>
  <!-- https://mvnrepository.com/artifact/org.apache.maven/maven-core -->
  <dependency>
   <groupId>org.apache.maven</groupId>
   <artifactId>maven-core</artifactId>
   <version>3.9.4</version>
  </dependency>
  <!-- https://mvnrepository.com/artifact/org.apache.maven/maven-plugin-api -->
  <dependency>
   <groupId>org.apache.maven</groupId>
   <artifactId>maven-plugin-api</artifactId>
   <version>3.9.4</version>
  </dependency>
 </dependencies>
 <executions>
  <execution>
   <goals>
    <goal>javac2</goal>
   </goals>
  </execution>
 </executions>
 <configuration>
  <fork>true</fork>
  <debug>true</debug>
  <failOnError>true</failOnError>
 </configuration>
</plugin>