maven classpath container refresh job - eclipse

I get stuck with m2eclipse and maven. After adding some dependency (hibernate 3.4, but I guess that doesn't really matter) eclipse got stuck with a message like in the title. Removing the dependency from pom file didn't help either. Restarting eclipse, checking out this as a clean project from repo neither. Alwyas gets stuck on refreshing. :/
What can get (m2)eclipse stuck on refreshing the project? All ideas welcome.

Workspace resolution can really slow the dependency resolution down. Maven needs to partially calculate each project to determine the dependency hierarchy, the time taken to do this increases rapidly as the number of related projects increases. To limit this, close projects you're not working on or uncheck the option to resolve workspace projects (so Maven will resolve the dependencies from the local repository, this means you need to install the projects after each update though).
If that doesn't help, try one of these:
Are your Maven settings correct? It may be that the preferences are not pointing to your platform install so Maven is downloading the dependencies to your user home in the background - this can take ages. If so tweak those settings. Select Window->Preferences->Maven and check if it is using the embedded Maven or not.
If you are behind a proxy you will need to set the proxy settings in your preferences, though if the problem is intermittent it won't be that.
Sometimes the persisted container isn't updated, I've never been able to isolate exactly why. I've found that closing the project and reopening can prod the container back into life.

Related

Prevent the download of Gradle and Maven dependencies

Before asking my question I'd like to apologize if this is really a
simple question.
I'm trying to find out the way, where we can locate and reuse the dependencies of Gradle and Maven. I want to find the possibilities of reusing them within multiple projects at the same time, opened in STS, Eclipse or Intellij.
Instead of download them every time when we create a new project. It will save me the data, time and disk space.
Maven dependencies are not downloaded again every time you create a new project.
They are downloaded to the local repository of your computer once and then they are read from there. So as long as you open a new project on the same account, Maven does not redownload dependencies.
The exception are SNAPSHOT dependencies, for which Maven periodically looks for new updates in the remote repositories.
Gradle, like Maven, has an Offline Mode, which means you're telling it to always try to re-use cached dependencies instead of resolving them from network.
Each of the dependency manager has a command line option for this, but in IntelliJ IDEA you can enable/disable it simply by toggling an icon-button in the Gradle toolbar.
And the same for Maven.

What is netbeans doing now?

This is getting tedious. I created a test project, simple java hello, to test a problem I have in another project. Having created the project, I could run it and build it to a jar.
Then I added some ivy stuff and tried a build which did not work. The ivy stuff consisted of ivy.xml ivysettings.xml and 2 tasks added to the otherwise default netbeans build.xml.
So then I removed the ivy files and the ivy sections from build.xml. I then did a diff on that and the previous unedited build.xml file and they are identical.
So now why after a clean build do I get this error?
/home/tester/WORKSPACE/NetBeans/Foo/nbproject/build-impl.xml:63: Source resource does not exist: /home/tester/WORKSPACE/NetBeans/Foo/lib/nblibraries.properties
Correct that file does not exist and it does not exist in any other project I have access to whether they use ivy or not.
I have reset everything I did yet Netbeans cannot continue. I have tried to work out how the hell nb actually builds a project but got lost. Just don't know what to say.
I guess nb and myself differ on what clean actually means and also on whether a task should be able to produce exact same results everytime given the same input, something that nb does not seem to be able to do. That or it cannot recover from the real world or their documentation just hides the useful information like how to reset a project.
I'm assuming there is some nb state that needs to be cleaned up manually but have no idea where to start. Any ideas please?
#Tim Biegeleisen, your comment got me thinking.
I shut down/restarted netbeans then tried the build again and it worked. So it seems that ivy is still running inside netbeans and has some form of state for my project that it will not release. I'll have to dig around to see if there is a way to reset ivy state without restarting nb but this whole process is turning in to a very tedious onerous task. I seem to be spending more time on the dev tools than I am on solving my coding tasks.
So the solution/workaround to my problem seems to be to restart netbeans to clear ivy state.

Can anyone help me fix this m2e-jdt/jdt bug?

Introduction
I have spend a lot of time to fix this bug
In our application we have a lot of generated code by cxf and jaxb which produces tons of warnings. We use the maven-build-helper plugin to add this code to our projects automatically.
By adding this enhancement, eclipse JDT enabled the possibility to set the javac -nowarn flag for specific source folders. Unluckily, by updating the maven project the flag gets lost. There are a few threads on SO where users got bugged by bug.
What I have tried so far
So i came up with a clever solution, javac has a nowarn flag. I set it to my maven-compiler-plugin and specified the directory. My maven build was fine, but my eclipse build wasn't. My research told me, that eclipse jdt does only use the maven-compiler-plugin source and target version. So my next step was to try to configure the EclipseCompiler, but this is not possible, because there is no possibility to add custom compiler Arguments in eclipse JDT.
Next Step. Inside of the .classpath file, eclipse JDT adds an ignore_optional_problems attribute for each ignored path. By updating the maven project inside of eclipse, this entry gets lost. So i started to write a maven "ignore-source-folder" plugin which should add the missing attribute. To run the plugin each time eclipse starts a build, i also created a m2e connector to refresh the .classpath file and everything should be fine.
By testing my plugin with my connector i realized, it works, but only 70% of the repetitions.
What happened?
Every time eclipse m2e/Jdt starts a new build, all classpath entries will be removed and populated again. When my maven plugin gets triggered by eclipse, a race condition starts.
So I started to analyze the code of jdt and m2e jdt. The ignore_optional_problems flag gets only once set manually inside of the patch which was provided to JDT and isn't stored somewhere else. By triggering a new build via m2e-jdt this information gets lost.
How to fix this problem
To fix this problem, some element has to be added or extended in jdt which contains all ignored folders. If a new build gets triggered and the classpath file gets newly generated by m2e-jdt this element should be checked for ignored paths. ClasspathEntryDescriptor seems to be a good place for it.
My problem
I checked out jdt and m2e jdt, but i have tons of errors inside of my IDE and i have no idea how to start. And even if I fix the code, I have no idea how to build and test it. I think my effort will be to high and we talk about 20 or 30 simple lines of code.
I am afraid if I add my results to the filed bug at eclipse, no one will care about it.
So, is there any developer able and willing to help me for this tiny job?
You need to "fix" the M2E's JDT project configurator. Probably somewhere in the m2e-core project. So, your change should obtain some kind of configuration flag from the project pom and create corresponding classpath entries for JDT.

Google App Engine, Maven and Eclipse development setup

I'll try keep this short. I have Eclipse with an installed M2E (Maven to Eclipse) plugin. I have a GAE (Google App Engine) project I'm working on. Everything is working ok apart from one really annoying thing: I have to stop/start the devserver every time I make a change.
If you have any experience with this setup then you might be able to answer this simple question?
I start the development server with "mvn appegnine:devserver" on the command line. Now I would expect that if I made changes to a *.jsp for example that those changes would automatically be updated on the devserver. Is this what happens with you?
I have noticed that if I make changes to *.jsp files under my target folder then devserver will see those changes and updates as I would expect. I think my problem lies with Eclipse not copying changes to target folder, but not sure if is even suppose to?
Does anyone have any suggestions on how I should progress investigating this? I've ran out of ideas :-/
I thank you in advance for any comments you may have.
P.s I know I can run "mvn package" to update files, but this is slow and the devserver runs out of memory after a do it twice.
This can be little painful, depending on how you want to work and which version of eclipse you're using.
Install the m2e-wtp plugin if you haven't. It's the secret sauce that makes appengine projects work in eclipse. Note this isn't m2e - but another plugin.
Install the GPE - the google plugin for eclipse if you haven't
Make sure your project is being managed by m2e as a maven project.
Go into your project properties - enable it as an appengine project using the GPE (listed under 'Google'). Don't forget to tick HRD while you're here.
Go to your project build path (Properties -> Java Build Path).
Ensure on the source tab that your src/main/resources doesnt have an ** exclusion.
Ensure on the libraries tab your have the three libraries 'JDK', 'Google Appengine' and 'Maven Dependencies' and nothing else
Ensure on the order and export tab that the appengine dependencies are above the maven dependencies.
It sounds pretty ridiculous - i'm not really sure why its still so painful, but that is a good recipe for success. Once that's done, this should allow you to run in debug from eclipse itself, with hotloading of code, jsps, css, scripts etc. I've had this work in helios, indigo and juno.
You can read more about the m2e-wtp setup instructions here. They refer to GWT but it's the same for appengine (I'm not sure why the emphasis on using GWT on GAE) because its actually about the correct setup of GPE and Maven.
You will also find that you may need to repeat some parts of step 5 pretty frequently - if your app isn't loading properly take a quick look to ensure that your resources haven't been excluded. This happens when you update your project configuration using the m2e plugin.
The wtp-m2e plugin updates the target folder as resources modified - so this should also resolve your issues running from the command line, but i can't vouch for that - I prefer to run straight out of eclipse.
I have the same problem as you, however I resolved with other way. I use FileSync plugin (which can be found in the market place).
With this plugin you configure an input directory (webapp) and output directory (target).
Any change made to the webapp will be passed to the target.
I have helped too.
You can use rsync like this:
rsync -r --existing src/main/webapp/ target/ROOT
where "ROOT" is the project build finalName.
The below point worked for me.
Ensure on the order and export tab that the appengine dependencies are above the maven dependencies.

Java maven development slow

I am developing a war/java website that is built via maven.
Currently, I have to make changes... tell maven to build them... then deploy to Tomcat. This is around 40seconds. So every change I make, I have to wait >=40seconds to see the change.
This is becoming very frustrating, so I have tried to speed up the deployment. I deployed the site via maven with war:exploded. Now, I edit the files live in 'deployed' format. The problem being I will need to move these changes back to the source location for pushing into our source control.
So has anyone written a script to 'undeploy' changes on the server carefully pointing them back to where maven expects them to be, or found another way I can instantly see my changes in a web browser. Rebuilding from source everytime is not a fun solution.
Currently, I have to make changes... tell maven to build them... then deploy to Tomcat. This is around 40seconds. So every change I make, I have to wait >=40seconds to see the change.
This is just a wrong way to use Maven in my opinion.
Either use something light like jetty:run (and hook Eclipse remote debugger to enable hotswap), see Configuring Jetty, Maven, and Eclipse together with Hot Swap.
Or use Eclipse WTP and deploy your project on a Tomcat server inside Eclipse (your project can be recognized as a Dynamic Web project whether you're using m2eclipse or the Maven Eclipse plugin).
Have you tried JavaRebel?
http://www.zeroturnaround.com/jrebel/
Use hot-deployment.
Just configure tomcat-maven-plugin and try tomcat:redeploy.