How make Intellij do before launch actions when redeploy external artifact? - maven

I build an artifact (ear) with maven and deploy it to a local WebSphere Application Server 8 with Intellij IDEA 15, so I configured "before launch" action "mvn clean package".
Intellij starts WAS and deplopyment goes well, but when I try to do a redeploy, maven begins to build the artifact but installation it to WAS goes in a parallel and fails, so when maven finishes there is no proper insalled applicaion and I have to run "deploy" in Intellij manually by clicking a green arrow using a mouse to get it run.
How can I tell Intellij wait for "before launch" tasks to be finished before it will do the redeploy?

Have you tried the MultiRun plugin?
It completely solved my problem with launching/running multiple sub-tasks in sequence (or not in sequence if you choose) before the primary task is launched.

Finally I wrote a wsadmin script to redeploy the app and assigned the intellij idea shortcut to run it.

Related

How to integrate maven framework with Jenkins

In order to integrate and run the Selenium Maven project on Jenkins 2.73.3, I set the option(s) as the following images:
Notice Goals and options with clean install; nothing else selected/checked, but Enable triggering of downstream projects.
Notice Install automatically is unchecked.
Jenkins project built successfully without opening any browser that shows any activity.
Please, let me know if there is/are any project setting(s) to solve this issue; i.e.: can we see the Web application run on browser as it does when it's run by the Maven project.
You are using Jenkins from services means you are using installable Jenkins version which not allow opening of any UI invocation.
You need to use jenkins.war
You can download war from below URL:
https://updates.jenkins-ci.org/download/war/
Use below command to start Jenkins server
java -jar jenkins.war --httpPort=9090

What does maven clean install -U do?

I have eclipse ide with m2e plugin, maven and weblogc app server running from my local box.
I have imported someone else's multiple maven projects from bitbucket to my box. I was told that one of them is main and rest are dependencies in which I never seen anything like that before. I have always dealt with single maven project. Anyhow from the instruction, it says I have to run maven command such as "clean install -U".
In the IDE so I touched run configuration for each mvn project by setting goal as "clean install -U". By reading maven guide, I kind understand what each term means but when you combine together with a passing parameter, what does it do actually? I didn't expect a jar (web app) to be deployed to an application server but it did also.
-U forces maven to check any external dependencies (third party dependencies) that might need to be updated based on your POM files.
clean install are both basic maven lifecycle phases (https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html).
install normally would simply take the artifact that is built and put it in the local repository, i.e. a directory on the box you are building on (.m2 directory most of the time). It would not do a deployment to a server - typically the deploy phase would be used to do that.
However, developers can override and add to what maven does in the various phases, so just like in the days of ant things can easily devolve into chaos no one can understand on complex projects ;-).
sometimes in the integration-test phase, developers will tell maven to start up a container temporarily to run the web app on, so that tests can be run against it, and then that container is shut down when the integration-test phase completes.

How to have Buildship recognize existing projects in Eclipse Mars

I just converted my Maven project to a gradle project. It was a multi project structure:
master-project
pom.xml
---->project1
-------->pom.xml
---->project2
-------->pom.xml
---->project3
-------->pom.xml
I ran a gradle init on it and have this structure now:
master-project
build.gradle
---->project1
-------->build.gradle
---->project2
-------->build.gradle
---->project3
-------->build.gradle
Everything builds fine, and I have been able to get some things done with that I couldn't figure out how to do with Maven, so that's great. Next step was to integrate that into the IDE since the Maven Dependencies are gone since I have removed the pom.xml files.
However the project isn't recognized as a gradle project - and I am not sure how to change that?
In Eclipse Mars it's still recognized as a Maven build, not gradle....
Thanks in advance.
EDIT: I reimported the projects which enabled the plugin for Eclipse. Now I am having weird behavior.
The build works from the command line, however when attempting the same execution from within Eclipse, it fails trying to copy the file dependencies.
For example:
Couldn't copy dependency jakarta-regexp-1.4.jar
java.nio.file.NoSuchFileException: C:\Users\user.m2\repository\jakarta-regexp\jakarta-regexp\1.4\jakarta-regexp-1.4.jar -> build\jfx\app\lib\jakarta-regexp-1.4.jar
I haven't changed the repo from maven yet - just changed the build scripts. This is running from the master project. So I am confused as to why the script would work from the commandline but not from within eclipse.
EDIT 2: Turns out this behavior is also present when running from the command line when the --daemon flag is set. Is there anyway to run the tasks without the daemon in Buildship? Or perhaps a way to fix this issue when the --daemon flag is enabled?
Thanks.
The issue with the build was that there is a leak in the JDK when bundling the JRE with the native app. This only happens when running with the --daemon flag (which all IDEs user). Therefore until this is fixed you will need to run gradle --stop and then run the clean.
The plug in I am using is no longer running the native task when running with --daemon.

Running Maven and then Copying files from IntelliJ

I have intelliJ and I run my mvn lifecycle commands from within the IDE. I would like it so that once a compile has completed I can then copy ceratain artifacts to certain locations on my PC. Can I configure IntelliJ to run commands after it has completed a build? I cannot see anything in the UI that allows me to do this but Im wondering if there is an easter egg somewhere that lets me do this.
Thanks

How to stop tomcat 7 with maven in eclipse

When I run my maven web project in eclipse. I go to pom.xml, right click on the file and
1. Maven Clean
2. Build Resources
3. Maven Build ..
Then I type tomcat7:run (for tomcat 7) for tomcat 6 , tomcat:run in the tomcat goals field in eclipse . It just starts. But I want to know how
1. To stop it
2. Rebuild the source and redeploy
in elipse or any other quick easy step. Isn't there any way to do all stuff to start the tomcat instead of repeating fore said steps(maven clean.. building resource.. again type tomcat7:run ... ) in eclipse.
Can you try right click on pom.xml > Run As > Maven Build...
Define here in the Goals section all your commands, something like: clean install tomcat7:run
My recommendation is to check skip tests for faster start up time, you can add extra paramenters like -Denvironment=qa if needed or VM arguments (from the JRE tab) like -Xmx2048m -Xms256m
Also, put a name to the configuration since you will be able to Run it again with a simple click or you could copy the .launch file eclipse generates into your application and commit it.
To stop the server just click the red square from the console view.
Hope it helps.
Following worked for me:
mvn tomcat7:shutdown
http://tomcat.apache.org/maven-plugin-2.2/tomcat7-maven-plugin/shutdown-mojo.html
You can use JRebel to hot-deploy your changes, no need to stop/start the app.
In IntelliJ use Ctrl+Shift+F9 to recompile and hot-deploty current changes.
Installing JRebel takes 5 minutes, and running app under JRebel is relally easy:
mvn <your usual parameteres here> -Djrebel.
If you search around, you can get JRebel for free.
Also, nothing stops you from running your maven application in a command line. Then stopping your app is as easy as hitting Ctrl+C.
You can also try maven tomcat shutdown plugin: http://tomcat.apache.org/maven-plugin-2.0/tomcat7-maven-plugin/shutdown-mojo.html.
I use JBoss Tools for managing Containers from Eclipse.
Just close the window for eclipse if the red square from the console view is not available.

Resources