Can you debug a maven goal with Intellij IDEA? I know that I can right-click and run Debug. However, the maven plugin does not appear in my External Libraries list, so I can not go into the code and set a breakpoint. Thus, Debug runs through the goals without stopping, like Run does.
I am using OS X 10.8 and IDEA 12.0.2.
EDIT: Goal
I've written custom specRunner for https://github.com/searls/jasmine-maven-plugin - However, $specs$ stays empty. So I try to see which files are actually loaded.
Figured it out:
from the command line, run maven goal with mvnDebug instead of mvn. E.g. mvnDebug clean
Open the source of the maven plugin you want to debug in intelliJ and set a breakPoint
In IDEA, add a Remote JVM Debug Configuration.
Under Settings, set Transport: Socket, Debugger Mode: Attach, Host: localhost, Port: 8000 (default port of mvnDebug).
Run the Configuration in Debug mode. It should connect to the waiting mvnDebug jvm.
Very easy. I am using Intellj Idea 15.0.4
Set the breakpoint in your maven plugin
In the tag "Maven Projects" go to the project witch is using your maven plugin.
In "Plugins" find your plugin and over the goal right click and Debug
Here is a screenshot:
Old question, but I was having the same need and it took me a while to get it to work. Hopefully can help someone.
For test debugging use:
mvn <goal> -Dmaven.surefire.debug
or
mvn <goal> -Dmaven.failsafe.debug
When execution stops and listens to socket at address 5005 (default) you run your configured remote debugger.
How to configure it:
Run -> Edit configurations -> Remote
Transport: socket
Debugger mode: Attach
Port: 5005 (default)
-> Save.
I think the easiest solution is to temporarily add the maven plugin as a dependency. Once this is done, IntelliJ will treat this just like any other dependency and you can set breakpoints the usual way.
The easiest way to debug maven goal ONLY within IntelliJ is to create a regular maven goal and in the runner tab pass those VM options:
-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
Where 8000 is a port number for remote debugging.
Then create new Remote configuration with port 8000. Run this configuration after running maven goal.
No need to setup up Java Remote Debugger or anything like that. It is literally just a right click -> debug on the Maven goal now, as explained in the official docs.
Either You can refer to above answer Or just add this plugin to pom.xml
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>
-Xdebug -
Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
</jvmArguments>
</configuration>
</plugin>
And run maven goal with mvn instead of mvnDebug. E.g. mvn spring-boot:run
In IDEA, add a Remote Configuration.
Under Settings, set Transport: Socket, Debugger Mode: Attach, Host: localhost, Port: 8000 (default port of mvnDebug).
Run as Debug in IDEA , whenever you want to debug the code.
Since you are working with Intellij, there is already a built-in debugger there and you do not need to necessarily use mvnDebug which is a command line tool. Check out this tutorial: How to Debug Maven Applications in Intellij IDEA.
The tutorial uses the Maven Exec Plugin and lets you debug the application without a need to use the command line or MvnDebug. Thought sharing it might be of value here.
#Peter Szanto 's answer work for me, but I don't like mess my source code.
And I can't make those MvnDebug way work.
So I try another way, add plugin source as IDEA module.
Here is the detail step:
Clone the plugin source as an independent project.
In your project, go to File -> New -> Module from Exist Sources and add the plugin project you clone in step 1.
Now you can open the plugin source code and set some break point.
Run your maven goal as debug mode, it should stop at the break point.
Related
I am trying to debug a sbt application in intellij, but somehow break points are not hit.
My steps:
On terminal, run:
sbt -jvm-debug 5005
Then create debug configuration:
Then hit debug button:
And finally run the app:
sbt:raptor> run
Application does run well, but none of the debug points are hit.
What am I missing here?
If it remains on the latest version of the IDE, please submit the issue in https://youtrack.jetbrains.com/issues/SCL .
I work on a Kotlin-based cloud microservice. From time to time I need to run it in the IntelliJ debugger, but we often accidentally break the "local debug flow". There is no pipeline that checks if the IntelliJ run-configuration and the somewhat complex set of cloud-simulating proxies and mock-servers are in sync with the code base.
I would like to write a script that helps me check if the local debug flow works. The script should do the following:
build the project
start up the "mock cloud"
start the service locally using an IntelliJ run-configuration
run a Postman-collection against the locally running service
I need help with step 3 (and possibly step 1): How can I start the IntelliJ run-configuration via command line? I am using IntelliJ IDEA 2021.2 and MacOS 12.3.1.
There is no built-in way to start a Run Configuration from the command line. Instead, you should execute java/kotlin binary with classpath etc.
For example, for "Application" configuration it is needed to run the command like that:
so currently at work I face the problem, that I cannot build projects, which use global dependencies. We use an auto-config proxy script, which I already set in the File->Settings->Appearance & Behaviour->System Settings->HTTP Proxy and tested with the Check Connection-function.
The check connection function is working for any arbitrary html and also for the needed gradle-file (jcenter.bintray.com/com/android/tools/build/gradle/2.0.0/gradle-2.1.0-javadoc.jar).
For solutions I already tried to:
set the Proxy Information into the gradle.properties
tried to set http and/or https proxy settings
* systemProp.http(s).proxyHost=linktoproxyconfig.org
* systemProp.http(s).proxyPort=xxxx
* systemProp.http(s).proxyUser=xxxx
* systemProp.http(s).proxyPassword=xxxx
changing the repository direction (jcenter() vs. jcenter{url http://jcenter.bintray.com}
I am aware of the fact, that one can work offline, downloading the gradle locally. But to prevent the additional maintenance of gradle versions on different machines I would like to restrain from the work offline option.
Edit: Maybe I should also add the error message:
Gradle sync failed: Connection timed out: connect. If you are behind an HTTP proxy, please configure the proxy settings either in IDE or Gradle.
I would be most grateful if someone has an idea about a solution.
IntelliJ IDEA 2017.3 does not seem to respect the proxy options for downloading Gradle. So add the proxy options to both gradle.properties and gradle-wrapper.properties, and then run ./gradlew in a terminal. This will download Gradle. After that, IntelliJ will work.
It also happend to me and the problem was that Gradle installation was wrong. I added a GRADLE_HOME environment variable and appended %GRADLE_HOME%/bin to PATH. I restarted the IDE and it worked! :)
Source: https://docs.gradle.org/current/userguide/installation.html#sec:installation_environment_variables
Another possible caveat:
Check if your environment variables for GRADLE_USER_HOME is set. Gradle will look for the gradle.properties in this directory.
I am facing the same problem because I using the proxy in Windows 10. Going to set the auto dectect the proxy fixed the connection timeout problem:
version IntelliJ IDEA 2022.1.2 (Community Edition).
I'm trying to run Wildfly 8.0 from Intellij IDEA. When starting WildFly through commmand-line I can use the -c standalone-full.xml parameter to use the standalone-full.xml configuration file. How can I specify this when running WildFly from Intellij IDEA?
In my opinion switch -c standalone-full.xml is not a VM Option so I will post a little bit different solution:
In the Run/Debug configuration for your server in the tab Startup/Connection you have the ability to set Startup script: On the end of line there is checkbox Use default. Please unselect it and paste on the end of the input -c standalone-full.xml
Adding -Djboss.server.default.config=standalone-full.xml to VM_OPTIONS is the equivalent of running standalone -c standalone-full.xml from a shell
As said by Mike Holdsworth -Djboss.server.default.config=standalone-full.xml works perfectly.
But there is another advantage over the -c standalone-full.xml method.
When you rename your standalone.xml file to create custom configuration files for multiple environments. Like env1.xml, env2.xml, etc.
If you use -c env1.xml, Intellij will give you the following message:
Error: HTTP management port configuration not found.
So you have to put a basic standalone.xml who will be overriden at the startup by the one you give with the -c option.
The -Djboss.server.default.config=env1.xml will prevent it.
Look out for different startup scripts for "Run" and "Debug" in Intellij IDEA. If you don't uncheck "Use default" in both of them then you can end up with two different profiles on "Run" and "Debug". It is easy to forget and annoying to figure it out.
If you want to run it by default w/o passing any command line parameters than go
to standalone.(bat|sh)
Append to the SERVER_OPTS variable: --server-config=standalone-full.xml
At least now you'll run it in full mode from any place (ide, service, command line)
I'm on a cross-platform team and we share our run configs. Modifying the startup script could cause problems (other teammate's paths and startup scripts are different), so my solution was:
Made a backup of standalone.xml
Renamed standalone-full.xml to standalone.xml
This doesn't answer the OP's question directly, but may be helpful for folks.
In the Run/Debug configuration for your server you have the ability to set VM options. You can put your switch in there. You may have problems however with jboss identifying the correct path for the file, so you may have to play with that a little bit before it works for you.
Run -> Edit configurations -> Click '+' in the top left corner -> JBoss Server -> Local
There you can configure your JBoss instance and set VM options and so on.
I have a SBT project
in this project i have a sub play project and other projects
example from my build file :
lazy val subProj1 = Project(id = "sub-proj-1", base = file("sub1"))
.settings(...)...
lazy val subProjPlay = play.Project("play-proj", 1.0 , path = file("web"))
need to debug the play server from IntelliJ IDEA.
To run the project I use sbt run on the command line.
How can I debug the project in IDEA?
I found this to be the easiest solution : (using IntelliJ IDEA )
in IntelliJ :
Go to "edit run configurations"
Create a new remote configuration (port 9999, all other details leave with default values)
Go back to IntelliJ and run the new debug configuration (don't forget to put a break point)
From command line run :
sbt -jvm-debug 9999 run
The easiest solution.
Edit Configurations... -> add SBT Task (not Remote task).
Specify SBT Task: ~run.
Run created SBT Task using - Debug button
Provided you've Play distribution installed locally, use play debug run on the command line and connect to localhost on the port 9999 in IDEA.
From Debugging section in Using the Play console in the official Play 2.2.x documentation:
You can ask Play to start a JPDA debug port when starting the console.
You can then connect using Java debugger. Use the play debug command
to do that
If however you don't have it (and for a reason don't want to install it), add Remote Run configuration in IDEA that will give you a hint for the command line arguments you should be using when launching SBT, e.g.
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
When you launch SBT that may or may not be as simple as launching SBT jar, just use the above to configure JVM to run in debug mode.
IntelliJ IDEA 2016.1.1 && Play Framework 2.5.3
For me, no matter how I set(create new Run/Debug Configuration for Play 2 App or SBT Task, specify the debug port, execute in Run or Debug mode) in the IntelliJ IDEA 2016.1.1 Enterprise Edtion, the IDEA can not open the debug port(default 9999), so the debug is impossible.
After disable the sbt-fork-run-plugin(comment it in /project/paly-fork-run.sbt), it works!!!
I am newer to Play framework,and have found many bugs...Compare to RoR, it's so hard to learn, to run, to use, to debug...
Below is my steps:
disable the sbt-fork-run-plugin(comment it in /project/paly-fork-run.sbt)
execute activator -jvm-debug 9999 "run 11111" (I use port 9999 to debug, port 11111 to run my Play project)
In IDEA, add an new Run/Debug configuration, Choose, set debug port to 9999
debug the new created configutation