Over the past few days I have been trying to create/run a project in Eclipse using the gwt-maven-plugin and keep running into roadblocks (see some of my previous questions). I like to use Maven to do my builds, but I'm at the point where I'm thinking of going the Ant build route because of the complications of using Maven.
Does anyone out there have it configured/working well? Is it just me or is this harder than it should be?
After much frustration trying to get things to play nicely together, this is the setup I have that "works" for me. "Works" meaning that I can create, run and debug a GWT project with tweaks, but it isn't the most elegant solution.
Create Project
Much of the steps are the same as Pascal's answer in this post: Maven GWT 2.0 and Eclipse. I'll list mine out to be clear.
In Eclipse (Helios) with m2eclipse and GWT Eclipse plugins installed:
Create a new Maven project using the gwt-maven-plugin archetype
Modify the pom.xml:
set <gwt.version property> to 2.0.4
(needs to be same as GWT Eclipse
Plugin version)
set <maven.compiler.source> and
<maven.compiler.target> properties to
1.6
remove <goal>generateAsync</goal>
from gwt-maven-plugin <plugin> config
add maven-war-plugin to pom.xml
maven-war-plugin example:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<warSourceDirectory>war</warSourceDirectory>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
Update project Properties:
Google -> Web Toolkit, check the "Use Google Web Toolkit" box, and ensure "Use default SDK (GWT-2.0.4) is selected.
Run Maven "gwt:eclipse" goal on project (sets up environment and launch config)
Copy *.launch file to workspace.metadata.plugins\org.eclipse.debug.core.launches
Restart Eclipse
Compile/Run Project
I created a Run Configuration that does mvn clean compile gwt:run. The gwt:run is necessary to copy the resources and lib jars into the war directory. However, it does not copy the web.xml from src/main/webapp/WEB-INF into war/WEB-INF/. So, I have to manually copy that file.
If I want to run my application, the above step is sufficient. However, if I want to debug the application, I launch it by choosing the Google "Web Application" configuration from Debug Configurations that was created when the .launch file was copied previously. This configuration allows for debugging (breakpoints etc.) without any other config or need for remote debugging.
It is harder then it should be, however it is possible. All hints posted here can do the trick. However you can still have classloading issues. I decided to switch to GWT 2.1 and use new abilities of JettyLauncher. You can create own jetty launcher like this:
public class MyJettyLauncher extends com.google.gwt.dev.shell.jetty.JettyLauncher {
#Override
protected WebAppContext createWebAppContext(TreeLogger logger, File appRootDir) {
return new WebAppContext(appRootDir.getAbsolutePath(), "/");
}
}
And then add -server MyJettyLauncher option to your gwt launcher configuration. With such configuration all the libraries are managed by m2eclipse (you can even remove GWT SDK from classpath) and there is no need to copy anything to WEB-INF/lib (you can remove gwt-servlet.jar which could be already there).
Ready launcher is here in tadedon library:
http://code.google.com/p/tadedon/source/browse/tadedon-gwt-dev/src/main/java/com/xemantic/tadedon/gwt/dev/JettyLauncher.java
Yes, in 2016 it does, quite nicely indeed. :)
I launch Tomcat from within Eclipse, I launch GWT codeserver (SuperDev mode) from Eclipse, I launch Chrome from Eclipse.
You will find quite recent and very valuable set-up tutorials on Brandon Donnelson's YouTube channel: https://www.youtube.com/user/branflake2267/videos
What is essential for me is Eclipse debugger for GWT SuperDevMode: https://sdbg.github.io/
I prefer to have my project "mavenized", and there is lot of Maven archetypes also provided by Brandon: https://github.com/branflake2267/Archetypes/tree/master/archetypes
The official starting point (not just) for downloading the GPE plugin (not to confuse with above mentioned debugger plugin) is on GwtProject.com: http://www.gwtproject.org/download.html
For me personally GPE itself has become rather optional "convenience" component. (Yes, refactoring and auto-completion are nice to have, but that's all it is needed for. :)
It is not a one-click solution, and I prefer it like that, as those tend to be black-boxes prone to breaking.
And BTW make sure to take a look at GWT Material: http://gwtmaterialdesign.github.io/gwt-material-demo/
(Currently playing with 2.8-beta1.)
For Eclipse I use: m2eclipse plugin (1.0). It works well with one or two minor things. Also download the m2eclipse-extras plugin to add SVN functionality AND Maven (or CVS if you prefer).
When you download then your project it reads the pom.xml and [re]creates the Eclipse configuration files like the mvn eclipse:eclipse command.
For GWT... I've used it too. It's a pretty twiked configuration but it works. I use GWT 2.0.3, the maven-gwt-plugin uses the dependencies to work (no ref to GWT SDK) and it can debug from Eclipse which is simply great.
You have to compile to a war directory (not the target/classes standard). But the details are in my work, so let me see it tomorrow and complete this answer :) Don't give up. It's a great thing to have GWT+Eclipse+Maven.
Edit: part of my configuration
<build>...
<outputDirectory>war/WEB-INF/classes</outputDirectory>
...
</build>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.2</version>
<configuration>
<gwtVersion>${gwt.version}</gwtVersion> <!-- para forzar que use el de maven y no el SDK instalado -->
<disableCastChecking>true</disableCastChecking>
<disableClassMetadata>true</disableClassMetadata>
<runTarget>/subscriber/listSubscribers.htm</runTarget>
<webappDirectory>${basedir}/war</webappDirectory>
<soyc>true</soyc>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- dont know/remember if the jetty inside the gwt uses this... but it doesnt hurt-->
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.14</version>
<configuration>
<webAppConfig>
<contextPath>/magazine</contextPath>
<baseResource implementation="org.mortbay.resource.ResourceCollection">
<resourcesAsCSV>
${basedir}/src/main/webapp,
${basedir}/war
</resourcesAsCSV>
</baseResource>
</webAppConfig>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>8888</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
<scanIntervalSeconds>3</scanIntervalSeconds>
<scanTargets>
<scanTarget>${basedir}/war</scanTarget>
</scanTargets>
</configuration>
</plugin>
AND
For debugging I create two tasks:
1) maven build inside eclipse that runs two goals: war:exploded gwt:debug
The first one copies all the resources into war directory for gwt debug to use them.
Next the gwt is ready.
Maybe you need to execute gwt:compile for the first time
2) a Java Remote Application debug configuration, with your project selected.
You run this configuration when the gwt:debug is "listening at port 8000"
AND: this is in a parent pom.xml (sorry I'll edit this post later :)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1-alpha-2</version>
<configuration>
<warSourceDirectory>${basedir}/src/main/webapp</warSourceDirectory>
<webappDirectory>${basedir}/war</webappDirectory>
<warName>${artifactId}</warName>
</configuration>
</plugin>
helios wrote good explanation. But it's not actual at the moment. So I advice you to try my modern example of EAR application running on GlassFish and with full debug support.
Related
I am using the latest version of STS which at the moment is 4.11. I'm building a new project and trying to get AspectJ CTW working with Spring Boot. I have some unit tests to check the aspects with #Async method calls. The funny thing is that the unit tests pass with a maven clean install, but not when building through STS.
I believe the reason is the AJDT plugin or AJDT configurator plugins are not working because I see this error:
Plugin execution not covered by lifecycle configuration:
dev.aspectj:aspectj-maven-plugin:1.13.M3:compile
(execution: default, phase: compile)
I am using the latest aspectj maven plugin with these settings.
<plugin>
<groupId>dev.aspectj</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.13.M3</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<complianceLevel>${maven.compiler.target}</complianceLevel>
<encoding>${project.build.sourceEncoding}</encoding>
<XnoInline>true</XnoInline>
<aspectLibraries>
<aspectLibrary>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
And I tried to install these two software installations:
http://download.eclipse.org/tools/ajdt/410/dev/update
http://dist.springsource.org/release/AJDT/configurator/
Getting this set up always seems to be a pain. Has anyone managed to do it with Java 11?
AspectJ Development Tools (AJDT)
I do not use STS, but mostly IntelliJ IDEA and if Eclipse, then plain Eclipse for Java developers. A while ago, I prepared a new AJDT version for Eclipse 2021-03, which still seems to be working in 2021-06, while developing AspectJ 1.9.7.
Try downloading the latest snapshot from aspectj.dev:
https://aspectj.dev/maven/org/eclipse/ajdt/org.eclipse.ajdt.releng/2.2.4-SNAPSHOT/
At the time of writing this, the latest snapshot is:
https://aspectj.dev/maven/org/eclipse/ajdt/org.eclipse.ajdt.releng/2.2.4-SNAPSHOT/org.eclipse.ajdt.releng-2.2.4-20210509.044425-2.zip
Sorry that I cannot provide you with a regular Eclipse update site, but while contributing to AspectJ, I have no access to the Eclipse infrastructure. The lead developer is busy, so my own web server is the easiest way to provide you with AJDT. The ZIP archive is about 15 MB in size. You can import it into Eclipse as a virtual update site as described here (scroll to "Install AJDT (AspectJ Development tools) for Eclipse IDE").
AspectJ Maven Plugin by aspectj.dev
Some small news: Yesterday I released version 1.13 of AspectJ Maven. It has a few more improvements compared to 1.13.M3, most notably 1.13
depends on AspectJ 1.9.8.M1 by default (you can also use 1.9.7, of course, but 1.9.8.M1 supports the --release N compiler switch),
recognises language level 17 as a valid parameter for source, target, compliance level and release parameters, i.e. it can be used with latest AspectJ 1.9.8 snapshots in order to experimentally compile Java 17-EA,
has precedence rules for compiler level settings, i.e. if compliance level is set, you do not need source and target (they are the same) and if you set source and target, you do not need to specify compliance level anymore. That before you had to set all three, was always a bug IMO. Besides, if you set the release for cross-compilation, all of source, target and compliance level are ignored.
More information can be found on the plugin's GitHub site.
Update: I found an m2e connector for AJDT which is maintained by Miika Vesti for his private use. At first it was not working for the dev.aspectj groupID, because he had forgotten to push an update to the Eclipse update site, but I got in touch with him and now it works. Please see the project's read-me for more information. You can use the existing update site for Eclipse 2020-12 in order to install a connector which also works on Eclipse 2021-06.
The connector needs some more work in order to import all AspectJ Maven settings correctly, e.g. it does not work in some of my projects where I deactivated Maven Compiler Plugin, because it currently relies on it being active and things like source/target compiler levels being configured there. Only then it will also correctly import source and target directories as well as dependencies - most prominently the Aspectj runtime library - correctly and result in a usable Eclipse project. I am trying to work with Miika in order to make the connector more self-sufficient in the future.
I have a multi-module maven project. I'm using intellij-idea as my IDE.
I have Maven configured with the clover plugin to automatically instrument on build.
How can I get IntelliJ to recognize those changes and refresh its coverage data.(NOTE: having to click the "Refresh Coverage" toolbar button is fine.)
I've tried configuring maven-clover2-plugin like so:
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-clover2-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<baseDir>${project.basedir}</baseDir>
<cloverMergeDatabase>
${project.basedir}.clover\cloverMerge.db
</cloverMergeDatabase>
</configuration>
<executions>
<execution>
<id>main</id>
<phase>package</phase>
<goals>
<goal>instrument</goal>
<goal>aggregate</goal>
<goal>check</goal>
</goals>
</execution>
<execution>
<id>site</id>
<phase>pre-site</phase>
<goals>
<goal>instrument</goal>
<goal>aggregate</goal>
<goal>check</goal>
</goals>
</execution>
<execution>
<id>clean</id>
<phase>clean</phase>
<goals><goal>clean</goal></goals>
</execution>
</executions>
</plugin>
I then configured my project settings to use:
.clover\cloverMerge.db and checked the relative to project directory. checkbox.
But that didn't work.
NOTE:
At the bottom of Configuring Instrumentation it says
Do not set these locations explicitly if you have a multi-module project.
So I also tried leaving the location as the default for both Maven and IDEA and that didn't work either.
Also in the Clover for IDEA installation GUIDE - Known Issues
If you are using the Maven build tool, you should avoid using the same > IntelliJ output directory as Maven does. As Maven uses the target/classes and target/test-classes directories,
avoid specifying these ones. The clover.db location for IntelliJ should also be distinct from that used by Maven.
WHY should they be distinct is there some file corruption issue? If they're kept distinct then HOW can I get awesome coverage highlighting/etc, without having to repeat builds in a completely separate process?
Well I finally figured out an answer. I'm leaving this here for posterity.
The solution is complicated and somewhat of a Hack but it WORKS.
Update the parent projects pom.xml file
cloverDB: <cloverDatabase>${project.basedir}.clover\clover.db</cloverDatabase>
Merge CloverDB:
<cloverMergeDatabase>
${project.basedir}.clover\cloverMerge.db
</cloverMergeDatabase>
Create your Unit Tests to Run in IntelliJ IDEA
setup a Before launch - Run Maven Goal
clean clover2:setup prepare-package -DSkipTests
Create a Maven Run Configuration
Make the Unit-Tests a Before launch condition
In the command line have Maven run clover2:aggregrate
Update Intellij Project Settings for clover to point to the merge file
Make sure the Relative to project directory. checkbox is checked.
InitString to User specified with the value the same as your pom file.
in my case: .clover\cloverMergeDB
Once the command is run, just click the Referesh Coverage icon to see and work with the coverage data in idea.
If the tests fail you will also have the nice IntelliJ Test runner Tab to figure out why.
At the bottom of Configuring Instrumentation it says
Do not set these locations explicitly if you have a multi-module project.
Documentation actually says: Do not set these locations explicitly (using absolute path) if you have a multi-module project. The reason is simple - if you use an absolute path, then you will not have a separate clover.db for every module, but only a single clover.db file.
"If you are using the Maven build tool, you should avoid using the same IntelliJ output directory as Maven does. As Maven uses the target/classes and target/test-classes directories, avoid specifying these ones" [...] WHY should they be distinct is there some file corruption issue?
The problem is as follows: IntelliJ IDEA uses it's own engine to compile sources. It means that it does not have to call the original project's build system (a Maven, for instance) to compile sources.
It means that:
- if you have a Maven-based project and it has the Clover-for-Maven plugin installed and
- at the same time you have the Clover-for-IDEA installed in the IntelliJ IDE
- and these two Clover integrations use the same output folders for classes and databases
... then these two Clover integrations may start overwriting their files.
In most cases this is not a desired behaviour because any source code modification / project rebuild action etc in IDEA will trigger source recompilation; which can delete results obtained previously by Clover-for-Maven.
I am using maven for my webapplication to build, start and handle the libraries. So I run tomcat7:run to develop my application... But if I change the code the tomcat will not automatic reload the code changes, so I need to restart. Before maven I use the "Sysdeo Eclipse Tomcat Launcher plugin" to run and create my project. This plugin allows to the see code changes instant and I know that the PLAY! Framework do the same. So it is possible to configure maven to reload my code changes on running? I will improve my work progress...
It is possible to automatically reload code changes by making sure the Tomcat context is reloadable.
The tomcat7:run goal allows you to enable context reloading with the contextReloadable parameter which must be configured in the configuration section of the plugin:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<contextReloadable>true</contextReloadable>
</configuration>
</plugin>
I have a couple of questions.
I'm trying to learn how to make web apps with Java (I'm coming from C#). The project which I'm going to work on is using Spring MVC.
Now all the tutorials of Spring MVC / Java want me to use Maven. I'm also using Eclipse.
My problem is that every time I try to run a project downloaded from some tutorial like these:
http://tech-read.com/2011/10/31/spring-3-mvc-annotations/
http://www.mkyong.com/spring3/spring-3-mvc-hello-world-example/
I can't run the project. it tells me that the project has no main and then tries to find a class, nothing very clear...
I've also watched youtube videos about it, and some guy was using Jetty to launch the website. (video link : http://www.youtube.com/watch?v=uv9tXFrTLtI)
So my question is:
If I have Eclipse, Oracle JDK 1.7, Spring Tool Suite 3, Maven + m2e - Maven Integration for Eclipse, Spring IDE blah blah plugin, should I be able to run a website from a simple Hello World project? If so, Is there something specific I have to tell Maven / Eclipse to launch my things?
You need to run it in a server context.
To do this you need to install a java web server, like svz said. Tomcat is the one I use.
Spring Source Toolkit (STS) comes with this set up out of the box.
Spring is confusing enough to learn, I would suggest using this IDE until you get the hang of it, then you can experiment with better (different?) web servers.
Try right clicking on your project and running it on a server.
It should be set up to do it for you out of the box.
You can also install it as a plugin to eclipse, or install tomcat manually and drop your war files into the app directory.
You could use jetty. Add the jetty plugin in your pom like this :
<build>
<finalName>spring-mvc-webapp</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.0.1</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
</configuration>
</plugin>
</plugins>
</build>
Execute mvn jetty:run
Connect to URL : http://localhost:8080/spring-mvc-webapp/
I apologize if this question has been answered elsewhere, but I couldn't seem to find an the exact response that I've been looking for. So I'm in the middle of altering a web application that once relied heavily on the jQuery UI to use Vaadin, instead. To make it easy for me to understand, I created a new Maven project and altered the pom.xml to include the following plugins:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
<version>2.3.2</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<server>local_tomcat</server>
<path>/illuminate</path>
<url>http://127.0.0.1:8080/manager/text</url>
</configuration>
<version>1.1</version>
</plugin>
Now, I can manage to build and deploy my very simple application to Tomcat just fine, but when I attempt to go to it, I get the following error:
In order to get a better understanding of how to set up this kind of project, I checked out a recent applicaiton that uses Vaadin with Maven from our repository called "Tag." Looking at the error, it looks as though it's trying to find a JavaScript file nocache.js in a directory that starts off accurate (Illuminate is my current application), but then branches off into this other project that has no link to my current one. I'm not sure if the browser has something to do with this or not, but I learned that it might have something to do with the widgets of my project having not been compiled yet. I've noticed that there are some other plugins that will do this, but these two are the only ones that this other project, Tag, makes use of, so I figured mine should work just fine. I have also been trying to follow the step-by-step process to make a simple "Hello World" like program from the Vaadin Tutorial. So... Anyone know what I am missing? If it's the compilation of the widgets (I only wish to use the defaults, I suppose), do I NEED those other plugins?
Thats problem of tomcat not deploying VAADIN dir content.
see below blog
http://fmucar.wordpress.com/2011/04/20/vaadin-maven2-eclipse/