GWT - Refreshing changes with 'Development Mode' with Maven - eclipse

If I use GWT's Development Mode with Eclipse, changes that I make in the IDE are immediately reflected in my browser upon refresh. However, I can't seem to get the same result when using the maven plugin to build. Is this possible?
Here's what I've tried:
Running gwt:run, making a change and saving it in Eclipse, refreshing the browser.
Same as above but clicked the 'restart server' button on the GWT Development Mode console.
Telling Eclipse that my project is a GWT project and configuring a Web Application, but it fails to list any Entry Point Modules for me to choose from.
'webAppCreator -templates maven com.xx.WebApp' - creates just a pom, no project (?).
The only option seems to be: stop the console, gwt:compile, gwt:run. This cycle takes minutes each time..
Any ideas on how to achieve this, or if it's even possible? Not being able to do this is really a show stopper for us adopting GWT, since we can't scrap maven.
TIA, Roy

The real answer to this question came from Thomas Broyer's comment, but I wanted to spell out all of the steps that I took for future reference:
With Maven:
Create the project using the gwt maven plugin archetype.
Move the xxx.gwt.xml file from the 'resources' tree to the 'java' tree, as recommended by Thomas.
Run 'mvn clean install' to ensure that all's well, and to generate the async classes.
To get around this issue, add this to your pom. When you change your maven dependencies you'll need to run a maven compile to get them to take in Eclipse.
With Eclipse:
Import the project into Eclipse using 'Import Existing Maven Project'
Right-click on target -> generated-sources -> gwt, and select Build Path -> Add to Build Path.
In project properties -> Google -> Web Toolkit, 'Use Google Web Toolkit' is checked.
On the same page, add your entry point modules.
In project properties -> Google -> Web Application, ensure that 'This project has a WAR directory' is checked, and the dir points to 'src/main/webapp'
Right-click on the project, select Run As -> Web Application
Ready to go!

Related

Rename JEE project

I'm working on a JavaEE project, I already have the skeleton of an old project. All i have done is rename the project, packages and change the name in the project file (.project). But now when i'm trying to run, it returns error in the browser "The requested resource is not available". I've checked the web.xml and added a new jsp in vain it doesn't work. In the browser's address, it gives me the old name of the project(http://localhost:8061/smsgate/). I've tried a lot to fix the problem. what can i do? Is there any other file that i have to update and write in the new name? Please give me your ideas (knowing that i have to use that old project)
Do Project -> Clean in your workspace by selecting your current project. Also if using maven then right click your project and do maven -> clean.
Manually go to your target directory of your ear module and shift-delete everything inside your target and then rebuild your project to form new ear.
if you have configured the web.xml properly then strike your app url. Also ctrl+shift+delete your browser history and then check.
Why not create a new project using a maven archetype, just type in the console:
mvn archetype:generate
It will show you a list of available archetypes from the web, just choose one of them, for JEE6/JEE7 you could choose among:
1019: remote -> org.codehaus.mojo.archetypes:webapp-javaee6 (Archetype for a web application using Java EE 6.)
1020: remote -> org.codehaus.mojo.archetypes:webapp-javaee7 (Archetype for a web application using Java EE 7.)
If you agree with me, just type:
1019 or 1020 according to your needs and answer the questions like:
projectId:your-project-name
groupdId:com.yourdomain.reverse
version:1.0

Eclipse Gradle dependencies are not updated in Web App Libraries

I have a Gradle project (imported and generated using Eclipse's Gradle plugin) in Spring Tool Suite edition of Eclipse (3.2.0). It works most of the time, but sometimes, dependencies are getting out-of-sync between "Gradle Dependencies" and "Web App Libraries" in the project. Here is what I mean:
I define a compile dependency as following:
compile(group: 'com.mygroup', name: 'myClient', version: '0.2.1')
Then, after I do "Gradle -> Refresh All" I see that the dependency lib "myClient-0.2.1.jar" is in the list of the "Gradle Dependencies", and in the list under the "web App Libraries".
Now, after some time, I decide to use a newer version of this lib:
compile(group: 'com.mygroup', name: 'myClient', version: '0.2.2')
I again do "Gradle -> Refresh All", I also tried to refresh the project, re-build it, open/close the project and Eclipse, but what I see is:
The dependency under the "Gradle Dependencies" is indeed updated and is listed as "myClient-0.2.2.jar". But, the dependency under the "Web App Libraries" refuses to be updated and stays as "myClient-0.2.1.jar". this, obviously, wracks havoc to my app as now my code is not referencing correct newer classes and shows up all red in Eclipse.
One workaround that works sometimes is to nuke the whole project, and re-build it from scratch, but this is rather more radical than what I'd like to do :) And it does not work sometimes. It looks like I cannot explicitly control what goes into the "Web App Libraries" - so even though I see that a wrong lib is listed in the Project -> Properties -> Java Build Path -> Libraries -> Web App Libraries - I cannot change it there.
Any insight into this would be much appreciated,
Thanks!
Marina
I had the same problem.
Try a gradle cleanEclipseWtp eclipseWtp, this worked for me.
The WebApp libs will be up to date.
Best regards
Max
1)delete it without deleting contents on disk
2)Import ... Existing projects into workspace and import the gradle-example project back
3)the Gradle Dependencies container is named nicely
4)restart Eclipse
5)the Gradle Dependencies container of the gradle-example project has the weird name I'm reporting

Grails Project - Common Java Project Dependency in Eclipse

All,
We have standard java projects that contain our common data model, common util classes, etc...
What I can’t seem to figure out is how, to make my Grails project (in Eclipse) have a dependency on the other standard (non Grails) java project in the workspace. When I add the project in the “Java Build Path” the project doesn’t show any compiler errors, but it when I run “Grails Tools -> Refresh Dependencies” or attempt to run the project (run-app) it fails.
This seems like it would be a pretty common thing, but I have searched all over the web and have been unable to find a solution. We are not using maven in our environment. Since we build Eclipse RCP applications on the client side, we use OSGI manifests to manage our project / bundle dependencies.
You can use linked source directories to include the Java or Groovy dependencies in the grails project and you need to set the output directory to Project/target/classes (these configurations go into the grails project preferences in Java Build Path options -> Source Tab).
The change in the output directory allows Eclipse to detect changes in the dependencies and auto load it when running the app using grails run-app.
You can use autocomplete and debug the sources of the dependencies with this configuration.
I prepared a step and step process that includes screenshots for Java and Groovy here
The documentation includes information on customizing the build.
You can add this to your BuildConfig.groovy:
grails.compiler.dependencies = {
fileset (dir:"/path/to/jars")
}
That should get you started.
If the dependencies are not stored in an Ivy/Maven repository then AFAIK your only option is to copy the dependencies to the lib directory of the Grails project.

How to get peer project source in eclipse and maven

creating a parent project with only a pom.xml, and lots of sub projects such as:
my-web
my-core
my-backoffice
etc. is easy, and the sonotype eclipse plugin does most of the work.
However, getting one project to know about the source in the other project seems to be hard. E.g. when you are debugging the my-web project, and step into my-core, eclipse doesnt know where to get the source.
Looking in the Java Build Path in eclipse, the maven plugin has added my-core as a folder under "Web App Libraries". I.e. its not using the my-core-0.0.1.SNAPSHOT.jar or similar, its using the raw java files. Great!
But how to tell maven to tell eclipse to look for the source in the same place?
Im not really sure where to start. Im guessing its possible to get maven to put the source in a special jar using the maven-soure-plugin, but this will usually be out of sync with the actual java files which the web project seems to be using directly.
A quick and dirty solution is to manually Edit the Java Build Path for each project, and add my-core and other dependant projects in the "Projects" tab. Is this best practice? Any other suggestions?
A quick and dirty solution is to
manually Edit the Java Build Path for
each project, and add my-core and
other dependant projects in the
"Projects" tab.
If this doesn't happen automatically you have a configuration problem.
My Guess would be that you have a version mismatch between the pom dependencies and the actual project versions. Or your projects have an unusual name template (m2eclipse resolves projects by their artifactId AFAIK)
Either way, what always helps is in your Debug configuration (Run > Debug Configurations ...) select the Source tab and just Add... the selected projects.

How do I disable maven build when using Maven 2.0 integration for eclipse?

How do I stop the "Maven 2.0 integration" plugin from running maven build, while keeping "build automatically" checked?
I'm pretty sure it used to be some check box to disable maven build before, but after upgrading Ubuntu; eclipse seems to have been updated in the process, and now I cannot find any way to turn off the maven build. The maven build takes literally minutes (about 5 minutes or so), while just running java build used to finish in seconds.
Is it no longer possible to disable it or have they just hidden it well?
If it's not possible, will eclipse be able to compile my maven project without the plugin?
(Trying to google for a solution the closes I got to an answer was several archives of this old post where the answer essentially were "You should be able to disable Maven builder in project preferences..." which doesn't really help because I cannot find any on/off settings there)
To disable the Maven Project Builder, right-click on your project then Preferences > Builders and uncheck the Maven Project Builder (you cannot modify the default maven builder).
alt text http://www.imagebanana.com/img/fikqaidv/screenshot_010.png
If this removes "too much" things, you can maybe create your own custom Maven builder. Click New, select Maven Build and configure it as you want.
alt text http://www.imagebanana.com/img/rwkmm7jb/screenshot_010.png
Disabling it seems to stop eclipse from knowing about the related projects causing the java build to fail. Is there a some sort of dummy, no-operation goal I can use for auto build goals?
I guess you would have to add the related projects in the Project References (or to uncheck Resolve dependencies from Workspace projects).
Is there a way to disable it for all 6 related projects in the workspace simultaneously?
I don't think so.
At the end, all this tweaks looks like ugly hacks. If you're not satisfied by the m2eclipse plugin, maybe you should use the maven-eclipse-plugin instead (i.e. run mvn eclipse:eclipse) instead to generate the .project and .classpath files and import your projects as Existing Project into Eclipse.