Maven build runs when I run a Unit test in eclipse - eclipse

I have a maven project. I am trying to run a single test in maven command line and that works fine. I am trying to debug that test in eclipse and using -Dmaven.surefire.debug option and starting a debug on port 5005 as "Remote Application" in maven - ref http://maven.apache.org/surefire/maven-surefire-plugin/examples/debugging.html
Now when I do so - as part of my maven command in command line all classes/test-classes, spring config get compiled and put in right places. However when I am Run Debug from eclipse when the test pauses to listen on port 5005 - I see eclipse is running a maven build all over again and all classes are recompiled. And while doing this it is not picking up all the profiles required for the test as not all profiles are active by default. I could fix that by Project->Properties->Maven and set the active Maven profiles there.
What I am looking for if why is eclipse trying to do a maven build when I am trying to run my test for which a compiled class is already present? Is that a default behaviour of eclipse maven plugin m2e? And can this be turned off - so that it only executes the class instead of trying a maven build?

Related

Setup mvn clean package -P profile_name in eclipse in eclipse run configuration

Consider a project which till now used to be built using:
mvn clean package -P pname
in terminal and deployed manually to tomcat's webapps folder.
How to setup the run configuration and deployment for this in eclipse?
Here's what I've tried in Eclipse Oxygen:
Created a new Maven Build Run Configuration like this - set the Base directory of the project, set the Goals to clean package and Profiles to local.
Once run, I tried deploying the project to the tomcat set up in eclipse.
The issue is that there is difference between the runs when I am building and deploying manually and when I am using the eclipse configuration that I have made. The pname part is not being picked properly.

How to Debug spring-boot maven project in eclipse?

I have spring-boot mvc project - maven.
Specifically I want to debug #Controller class.
I converted it to eclipse project with
mvn eclipse:eclipse -Dwtpversion=2.0
Then in eclipse, I tried to Debug it on Server (Tomcat 7), but got an error
The server does not support version 3.1 of the J2EE Web module
specification.
In Facets configurations, it doesn't allow me to choose any other version of 'Dynamic Web Module' from 3.1.
I also tried to debug like that: from project root I ran:
mvndebug spring-boot::run
And then connected debug-remote, but when I opened the page in browser, break point of the controller didn't trigger.
You should not use eclipse:eclipse cause it's deprecated very long time...If you like to debug the Spring Boot application you can do this via:
mvn spring-boot:run -Drun.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"
You need to start Eclipse via Debug configuration.
The execution mvnDebug... will debug Maven itself which is not what you want to do.

Run arquillian test with eclipse

I make my first steps with arquillian. I just setup a java-ee project (using wildfly ear archetype).
The pom delivers 2 profiles: "wildfly-arquillian-container-managed" (only runs if JBOSS_HOME is properly set) and "wildfly-arquillian-container-remote"
Both are running fine. But how to run them in Eclipse? I read here "and select Run As > JUnit Test " but this yields
DeployableContainer must be specified
But i also found "Arquillian Eclips". It should provide "add Arquillian support and "run as Arquillian JUnit test". I installed JBoss Tools in my Juno but can't find any "arquillian".
So how to run Arquillian test from within Eclipse?
The maven profiles activate a container adapter. When you run them the container adapter can start wildfly.
When you run your test in Eclipse you have to add this container adapter to your class path. When you then choose Run As > JUnit Test it will take this container adapter into account and run wildfly.
I found jboss-Tool's arquillian-eclipse:
Via help->install new software
Choose "http://download.jboss.org/jbosstools/updates/stable/luna/" as update site. You'll found arquillian support in "JBoos Web and Java EE Development".
This will bring among other things "run as arquillian test". It will configure maven (pom) and will setup test run targets.
The option which works in every IDE I know is to select the default Maven profile to run.
With Eclipse it's available from Project | Maven |
Select Maven Profiles. Choose the Arquillian Managed profile as an example.
Then, in arquillian.xml file configure the location where JBoss/WildFly is installed.
Source: Running Arquillian from Eclipse

How to force eclipse to republish project when changing source in another module

I have multi module maven project.
One of the modules is actual web application, the JBoss is the server.
Other subprojects are dependencies for the web project.
I am running it in JBoss embedded in eclipse. Pretty straightforward configuration.
When executed from within eclipse, if I do mvn clean, mvn package - then clean + publish to JBoss, everything works wonderfully.
If I change source code for the web project, eclipse detects the need to republish automatically and does job well.
However if I change source in the non-web subproject, eclipse does not detect change and I have to mvn clean, mvn package, then publish to JBoss manually for it to pick the code change.
This is annoying since packaging job takes about a minute, then publishing job takes another 30 seconds. I have to clean since simply packaging without clean does not pick the change either.
Is there a way to configure things in the eclipse so that any source change in any subproject/module is automatically recognized by eclipse and it would republish to JBoss upon selecting "run"?
There is another bad side effect - debugging of the source that is not web project is impossible - eclipse's debugger does not see that source. It sees only source of the web module.
Thanks,
Nikolay
Make sure that your web project has dependencies on the other modules(projects) defined in the pom and in the eclipse project. you can check that in the build settings. If they are not there then it probably means that the project file was not generated from your maven .pom file. You can generate that by running
mvn eclipse:eclipse

Run configurations in maven

I want to use maven to run my application in test mode. I have a multi module project which uses gwt. To debug my app I want to do the following:
Run jetty in exploded directory
Run gwt in a hosted mode with -noserver option
Now I have to do this manually in the IDE. Is there any way to do this automatically from maven?
Using Maven, you can use the jetty-maven-plugin to run Jetty in your server module (use the start or run goal), and the gwt-maven-plugin to launch GWT's DevMode (use the run or debug goal).
To my knowledge, you cannot however do that with a single Maven command.
Have a look at https://github.com/tbroyer/gwt-maven-archetypes for sample configurations of such multi-module GWT projects.