Upon following setup instructions for Vue GWT, IntelliJ IDEA doesn't process e.g. #Component annotations - gwt

(NOTE: this question is self-answered Q&A-style, however please feel free to add and expand on my answer.)
I started experimenting with Vue GWT and followed the general setup instructions as well as the ones specific to IntelliJ IDEA. IDEA, however, refused to process my #Component annotation (e.g. to generate the factory class for my component).

My answer applies if you use Maven and have used IDEA's Maven project import when opening your project.
I found that I had to add the following to the project's pom.xml, an idea adapted from MapStruct setup:
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<!-- For IntelliJ IDEA to process Vue GWT annotations. -->
<annotationProcessors>
<annotationProcessor>com.axellience.vuegwt.processors.VueGwtProcessor</annotationProcessor>
</annotationProcessors>
...
</configuration>
...
</plugin>
<plugins>

Related

Mapstruct only works via maven package..is maven compiler plugin really necessary?

I'm trying setting up mapstruct with my project, I'm used to lombok that does it via a simple jvm agent so I really can't understand how to make mapstruct work.
Here's my pom:
<properties>
<m2e.apt.activation>jdt_apt</m2e.apt.activation>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<annotationProcessorPaths>
<path>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>${springboot.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${springboot.version}</version>
</plugin>
</plugins>
</build>
Please mind that, before mapstruct entered the game, I didn't need this whole maven compile plugin block: everything was working fine. I could build my springboot fat jar with no problems at all, no need to explicitely specify spring and lombok annotation processing...they were very good times.
Now I'm not even sure that I didn't introduce some regressions with the above code but, anyhow, I noticed that mapstruct classes are only generated when I do "mvn package".
I would have expected, like for lombok, for them to be generated automatically each time I saved an object but this does not happen.
Do you have any idea? And can you assure me that that specific build block does not change anything in my spring boot project?
For the code generation to work automatically make sure that you have the m2e-apt plugin installed.
As for having or not having the maven-compiler-plugin block. It is a flavour that the MapStruct teams like to recommend.
MapStruct is an annotation processor, which means that you don't need it during runtime. Therefore, you need 2 dependencies mapstruct where the annotations are located and the mapstruct-processor where the processor is located. The processor has some extra dependencies and contains shaded Freemarker for the code generation.
The use of annotationProcessorPaths allows you to have annotation processor paths and not have conflicts on your classpath, i.e. not accidentally using some internal MapStruct classes in your production code. On top of that, you don't need Spring Boot to package the mapstruct-processor provided dependency for your runtime application.
From the maven-compiler documentation the annotationProcessorPaths means the following:
Classpath elements to supply as annotation processor path. If specified, the compiler will detect annotation processors only in those classpath elements. If omitted, the default classpath is used to detect annotation processors. The detection itself depends on the configuration of annotationProcessors.
So if you really want you can add the mapstruct-processor to your normal dependencies.

gwt with maven and bootstrap eclipse starter project

I struggle for a few days now with integrating maven and gwt in eclipse. I was searching web for some ready to import project, but unfortunatelly everything crashed so long.
I am new to gwt. I would like learn it. Earlier I was using maven, spring and playframework with sbt.
I haven't use ant like build tool. But I like it integration between gwt and eclipe (I can click run in super dev mode).
One think is that I do not like in ant, I have to manually download jar and put it in classpath. I think it is unnecessary if maven can do it for me.
I would like also to use this library: gwtbootstrap3
I can't handle this on my own.
Can someone of You prepare for me that eclipse project, that I could just import.
Here is my newest pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>pl.korbeldaniel.btsp</groupId>
<artifactId>btsp</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>btsp</name>
<properties>
<gwt.version>2.7.0</gwt.version>
<gwtBootstrap3.version>0.9.1-SNAPSHOT</gwtBootstrap3.version>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.version}</version>
</dependency>
</dependencies>
<build>
<finalName>btsp</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
But I cant run in like native gwt project.
Yes, it's a definitely possible. You just have to sift through a ton of documentation to figure it out.
You'll need Google Plugin for eclipse and the m2e (Maven Integration for Eclipse) plugin
After you have those, right click on a GWT project-> configure -> convert to Maven Project.
Now, to use GwtBootstrap3, all you need to do is add GWT and gwtBootstrap3 as dependencies in your pom. (Details here).
If you need any ready to import maven projects, you can clone GwtBootstrap3-demo project from github and run that as a web application. As for learning GWT, tutorials are your best option (Pay close attention to UiBinder for GwtBootstrap3).
click here, here and here for details about setting everything up.

Maven with TestNG and Selenium, TestNG file being ignored

Story: So I am running a WebDriver2 test suite with TestNG and all that's bundled up in a Maven architecture. I built everything in Eclipse project first, then converted this over to a Maven project. I am not a programmer but I can hack my way through Java, I am new to Maven but pretty good with TestNG and Selenium and from everything I have researched I am approaching this correctly, I have to be missing something stupid.
Problem: I am running this all in Eclipse with Maven plugin, when I run POM as TEST I get an error:
org.testng.TestNGException: Parameter 'dataMode' is required by #Configuration of method prepareDriver but has not been marked #Optional or defined
So POM setup thusly for SureFire to grab my file, testNG dependency also set and appears to work since my error is coming from TestNG itself:
<plugins>
[...]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src\test\resources\testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
[...]
</plugins>
I have also passed in the parameters to this plugin as well:
<systemPropertyVariables>
<dataMode>Custom</dataMode>
</systemPropertyVariables>
<systemPropertyVariables>
<log_level>DEBUG</log_level>
</systemPropertyVariables>
Everything in my TestNG file is correct, if I run as a TestNG test just from the testng.xml everything runs like it is supposed to, if you want that code I will update but that part works, parameters are in there correctly.
Also, when I execute the POM as TEST I get a report that 2 out of 11 tests failed... I don't have 11 tests, if you go by my testNG.xml I have only 2 #Test's that it would find, I think it's counting every TestNG annotation in this portion of my test-suite...
My theory is that it's trying to run without the TestNG file and just running every TestNG annotation in any file it finds but I don't have it setup to do that, or do I?
Try something like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
<systemProperties>
<property>
</property>
</systemProperties>
</configuration>
</plugin>

Datanucleus Maven Plugin

How to fix this issue with Eclipse maven project:
Plugin execution not covered by lifecycle configuration:
org.datanucleus:maven-datanucleus-plugin:3.1.0-m3:enhance (execution:
default, phase: compile) pom.xml /DatanucleusJPA line 218 Maven
Project Build Lifecycle Mapping Problem
Is this fixable with the Eclipse M2 Eclipse plugin?
Preface:
I suppose this is nothing Datanucleus specific at all, but a feature of Eclipse Maven plugin instead. All that you have tried, apparently works if running on command line (Linux) or Cygwin[1] (Windows). The issue here is that Eclipse m2 plugin needs some more info for working properly and make its tricks and that is where the question lies and that's why you asked.
Possible solutions:
Like pointed already in comments, every detail can be found from the given link to [2] M2E site, and the essentials appear in one answer to one question [3] about the same issue. I take this snippet from one of it's answers:
<action>
<execute />
</action>
These lines should be fine, added inside the last element inside your <plugin-executions> element on your project pom.xml. I am not magician, I can only use Google, so without code / pom content given in question I suggest you have followed Datanucleus own instructions [4] and had there something like:
<plugins>
<plugin>
<groupId>org.datanucleus</groupId>
<artifactId>maven-datanucleus-plugin</artifactId>
<version>3.1.0-m3</version>
<configuration>
<log4jConfiguration>${basedir}/log4j.properties</log4jConfiguration>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>enhance</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
..and well, there it is only <executions>, but place it there.
Sidenote:
Funny though, while using Google for searching what would be the issue, that question was already voted up by me and there my answer of choice was different, looking like this:
<build>
<pluginManagement>
<plugins>
<plugin> ... </plugin>
<plugin> ... </plugin>
....
</plugins>
</pluginManagement>
</build>
..the trick being to add that <pluginmanagement> part to the xml. I just remember to have taken a fresh copy of my projects from SVN and after that I did not use that trick anymore. Maybe that problem is old or someone in my company committed that trick. Anyways, worth of testing, too.
Answer to the question:
Not, not directly with plugin, but tweak the pom.xml file.
My sources:
[1] http://cygwin.com - running Linux commands at Windows.
[2] http://wiki.eclipse.org/M2E_plugin_execution_not_covered - suggested in comments
[3] How to solve "Plugin execution not covered by lifecycle configuration" for Spring Data Maven Builds - includes lines of quotation

GWT/Eclipse/Jetty issue: Jasper can't resolve tag libraries

I'm trying to get GWT Hosted mode working in Eclipse, à la this HOWTO. Servlets work fine, as does my GWT code, but all my JSPs fail because with errors such as the following:
[WARN] /view/lniExecutiveSummary.htm
org.apache.jasper.JasperException: /WEB-INF/jsp/lni/lniExecutiveSummary.jsp(1,1) The absolute uri: http://java.sun.com/jsp/jstl/fmt cannot be resolved in either web.xml or the jar files deployed with this application
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
[ trimmed ]
This webapp works fine when deployed under Tomcat 5x; I just can't seem to get it to resolve the taglibs when running in Eclipse.
I'm new to Eclipse, and getting it working with all the moving parts required for GWT+Maven has me pulling my hair out.
Update: I'm no longer using Eclipse; I've switched (back!) to Intellij IDEA. So I can't honestly evaluate the answers you kind folks have posted. Once some voting action happens, or someone else reports success with one of these methods, I'll accept the appropriate answer. Thanks.
I feel your pain. I've gone thru the same pain trying to get gwt, maven, and eclipse to work together.
I've been able to get it working with maven using the following pom.xml. This way you can use mvn gwt:run to run in hosted mode, but unfortunately, I could never get the mvn goal mvn gwt:eclipse for generating an eclipse launch run time config to work.
Here's the relevant snippets from my pom.xml. Note that I've found it easier to install gwt in separate location and point maven to use that instead of having mvn download gwt from repo. The "system" level scope in the mvn dependencies are what make this happen.
<properties>
<!-- convenience to define GWT version in one place -->
<gwt.version>1.7.1</gwt.version>
<google.webtoolkit.home>${env.GWT_HOME}</google.webtoolkit.home>
<!-- tell the compiler we can use 1.5 -->
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<dependencies>
<!-- GWT dependencies (from central repo) -->
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwt.version}</version>
<scope>system</scope>
<systemPath>${env.GWT_HOME}/gwt-servlet.jar</systemPath>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<scope>system</scope>
<systemPath>${env.GWT_HOME}/gwt-user.jar</systemPath>
</dependency>
... other dependencies...
</dependencies>
<build>
<outputDirectory>war/WEB-INF/classes</outputDirectory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>generateAsync</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<runTarget>com.gwt.example/Application.html</runTarget>
<extraJvmArgs>-Xmx512m</extraJvmArgs>
</configuration>
</plugin>
<!--
If you want to use the target/web.xml file mergewebxml produces,
tell the war plugin to use it.
Also, exclude what you want from the final artifact here.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>target/web.xml</webXml>
<warSourceExcludes>.gwt-tmp/**</warSourceExcludes>
</configuration>
</plugin>
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<module>com.gwt.example</module>
</configuration>
</plugin>
</plugins>
...rest of pom.xml...
Another technique I've had success with is to use the eclipse google gwt plugin. Just use the wizard to create a new gwt project, make sure that you can run it from eclipse, then modify with your own code.
This webapp works fine when deployed under Tomcat 5x; I just can't seem to get it to resolve the taglibs when running in Eclipse. I'm new to Eclipse, and getting it working with all the moving parts required for GWT+Maven has me pulling my hair out.
You apparently have the JSTL JAR file(s) in Tomcat/lib instead of WEB-INF/lib. You can fix this in at least three ways:
Move/copy the JSTL JAR file(s) into WEB-INF/lib.
Move/copy the JSTL JAR file(s) into Tomcat/lib of your development machine.
Associate the right Tomcat server containing the JSTL JAR file(s) with web project in Eclipse. If not done yet, add the Tomcat server in Servers view. Then in project properties go to Java Build Path > Libraries > Add Library > Server Runtime > select the server in question.
Add the Jar files in eclipse project classpath. if you already had this file tomcat lib. This option will works for you. Second option is add jar in Web-Inf lib folder if you have eclipse web project.
Did you try to mark the "jsf-api.jar" as "exported" in your Java project ?
(as mentioned in this thread)
1.) Go into the java-project properties and mark the "jsf-api.jar" as exported.
(project>properties>java build path>order and exports)
2.) Go into the advanced global tomcat preferences and add your project to
the tomcat classpath (windows>preferences>tomcat>advanced>add projects to
tomcat classpath)
Then, try again to run your webapp under eclipse.
Here is an article describing the same procedure/setup, not for JSF but Hudson (same problem though)
You can clearly see the two steps I mentioned above:
(source: hudson-ci.org)
(source: hudson-ci.org)