Debugging my Maven2 plugin in Eclipse - java

I've written a plugin for Maven2 in Eclipse.
How can I run the plugin in debug mode in Eclipse?
If possible, I'd like to avoid remote debugging an external process and I'd also like to avoid installing plugins into Eclipse.

Make sure that "workspace resolution" is enabled for the project you're running the plugin from, then right click on this project and select Debug As > Maven build...

It is possible to debug integration/functional tests. See the following resources:
http://maven.apache.org/plugin-developers/plugin-testing.html
http://docs.codehaus.org/display/MAVENUSER/Review+of+Plugin+Testing+Strategies
http://docs.codehaus.org/display/MAVEN/Maven+Plugin+Harness
Just in case (and for other readers), the wiki page Dealing with Eclipse-based IDE explains how to remote debug an external Maven process (not sure why you want to avoid this).

Related

How I can debug the installed eclipse plugin

I have installed some JAVA plugin to the Eclipse. This plugin does not provides the source files (as this plugin contains only a set of JAR files). So, right now I want to "reverse engineering", to debug this plugin (to understand how it does work).
I know that I can run the Eclipse (which includes this plugin) in a "server" mode and then it will wait the remote 'GDB' connection.
Also, I have heard that I can use the Intellij IDEA as an IDE to remote debugging, to debug that Eclipse (with its plugin). But a main issue is that I have not a sources of that Eclipse plugin and I can't open it in Intellij IDEA.
So, my question is: is it possible to debug the eclipse JAVA plugin which has not a sources? And, if yes, then, how I can do it?
BR,
Denis
Using Intellij IDEA for this is nonsense--this is little different from debugging a plug-in when you do have the sources available, and plug-in developers have to do that all the time.
1) Install the Plug-in Development Environment. It's found in the Eclipse Project update site you should already have built-in.
2) Import the plug-in into a project in your workspace. Be sure to look for
3) Launch an Eclipse Application using a different workspace from the Debug menu.
This essentially takes what's in the Target Platform preference page, adds the plug-in from your workspace, and runs a copy of Eclipse with all of that mixed together. It's a different JVM process and should have its own workspace directory.

Is there a way to automatically compile using maven after code changes when using IntelliJ?

When using intelliJ, is there a way to automatically run maven compile after code changes? running mvn compile is too tedious each time.
Access Settings (Preferences on macOS). Select Build, Execution, Deployment > Compiler.
Enable Build project automatically. Press OK.
Press Ctrl+Shift+A (Cmd+Shift+A on macOS) and search for Registry. Open it to find and enable compiler.automake.allow.when.app.running (IntelliJ IDEA 15 and newer).
Source:
https://zeroturnaround.com/software/jrebel/quickstart/intellij/enable-automatic-compilation-in-intellij-idea/
Have a look at JRebel Plugin. If you are working with web apps its great.

Steps to Debug Dependancy In Webapp Eclipse/Tomcat

I have the Maven Web App, where I have to many dependencies. I am trying to create the Remote Debug configuration in eclipse to debug jars when my home page open. As I am aware to to the debugging on java code, how can i do the same with maven dependencies.
Thanks,
You can debug libraries from maven the same way you debug your code. Nothing special need to be configured in debugger.
You just need to make sure for the libraries you're going to debug, sources are available in eclipse.
You can either download and specify them manually, or let maven download sources automatically for you.

Managing Maven project in Eclipse with git repository

we recently migrated to Maven Build manager & git hub repository for our Java web-app. Also i switched to eclipse as eclipse has good set of plugins.
As a new bie, i am simply running mvn clean package from terminal at the code root directory. And then moving the compiled code i.e., /target/SNAPSHOT/* to tomcat/webapps/ROOT location.
And then starting Tomcat7 server. The process is time taking especially when i do code changes in Java & configuration .xml files.
I want to do it completely in IDE environment as i did earlier in Netbeans, update code -> build and run in debug mode, -> do code changes and then commit.
Heard of egit & m2e in eclipse for maven & github integration, but not sure how to use it.
Please walk me through the steps required in doing so. I am completely new to eclipse.
--
Thanks
You might want to consider using maven-jetty-plugin http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin for running the webapp. You will not need to copy over stuff to tomcat. After configuring this plugin, you can simply run your application by doing mvn jetty:run
I generally do not like running webapps inside Eclipse. It's a personal prefrence, but it is always nice to have an IDE neutral way of building and running your applications. If you have m2e things should work simply fine. I have seen maven-jetty-plugin having hot pluggability where if you changed your web.xml, jetty would reload your application.
We use Git for version control and Maven for dependency management and build automation. Once your project has successfully imported into Eclipse and recognized as a valid java web project, you don't need either Git or Maven in order to build/run it inside IDE. Just creat a server using you existing tomcat installation, add the project to server, then select Run as > Run on Server.
The Complete Guide:
Creating a server
Adding projects to a server
Starting a server
For more details, check out Testing and publishing on your server.

Debugging Maven Web Application on already installed Glassfish using eclipse

My problem is with respect to debugging web application on an already installed glassfish using eclipse.
If I create a web project using eclipse then eclipse will let be deploy and debug application on an already installed glassfish application server. However, if I have created a web project using maven archetype, eclipse does not let me debug the application.
I can use maven's jetty or tomcat plugin and debug the application but I need to debug application on an already installed glassfish. Basically I have followings
1) Web application created using maven archetype
2) Eclipse IDE
3) Glassfish which is already installed outside of Eclipse IDE
I came across maven's glassfish plugin but as far as I understood it is not for debugging the application.
Please let me know your suggestions.
Thanks
If I create a web project using eclipse then eclipse will let be deploy and debug application on an already installed glassfish application server. However, if I have created a web project using maven archetype, eclipse does not let me debug the application.
This is not true. Whether you use the Maven Eclipse Plugin (which provides WTP support) or m2eclipse (with the optional Maven Integration for WTP installed from the m2eclipse Extras), you can deploy a project created outside Eclipse to an existing "Server" (that you can start in Debug mode), as long as you imported it appropriately (Import... > Existing Project into Workspace if you use the former, Import... > Maven Projects if you use the later).
Basically I have followings 1) Web application created using maven archetype 2) Eclipse IDE 3) Glassfish which is already installed outside of Eclipse IDE
I use the same setup with several projects with no problem (and can debug them on my locally installed GlassFish server).
I came across maven's glassfish plugin but as far as I understood it is not for debugging the application.
There is no need for extra Maven plugins, you can just rely on your IDE if you follow the right steps.
I don't know about eclipse, but IntelliJ IDEA has a remote debug feature. You start your server with something like
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5055
and then the IDE will connect to that port and you'll have a regular debug.
I'm sure eclipse has this feature.
EDIT: This article shows how to use this feature with eclipse.
I´m going to write it most for me in order to keep trace of my solution:
If you are using the maven.failsafe plugin just force the execution of glassfish internally the current JVM started by maven avoiding the fork with the parameter
-DforkCount=0
in such way you are able to debug both test and server from the usual way, ie. running a debug task from eclipse and setting break points both in test and in server side.
Extra parameter information could be found here, including setting different debug port:
http://maven.apache.org/surefire/maven-failsafe-plugin/examples/debugging.html

Categories

Resources