Open default browser as as build goal - maven

Is it possible to set an execution goal for maven so that the default browser is opened in a given url?

In my experience, Maven doesn't have the notion of a default system browser, nor does Java. There's some information here if you're looking to do this on Windows:
http://groups.google.com/group/comp.lang.java.programmer/msg/bd52c25dad8c1589
That solution also says that this is a platform specific detail.
My advice would be to write your own Maven plugin (surprisingly easy to do) and just set an execution for it under the part of the lifecycle you desire. If you could give me more details of the context under which you want to open a URL, I could help you with that. In my experience, any execution you define for Maven for a phase will happen after that phase. So, setting something for the deploy phase will cause your plugin to run immediately after the artifact is uploaded.
As far as actually opening the browser is concerned, I would recommend using Selenium 2 to accomplish that:
http://code.google.com/p/selenium/wiki/GettingStarted
The nice thing about Selenium 2/WebDriver (they're in the same API) is that it takes care of the logistics of finding default installations of things like Firefox and Chrome, and knows how to interact with that browser and open a URL. You could opt for a platform inspecific default (Firefox would be a good candidate), and if you have an exception opening it, launch Internet Explorer instead (there's no longer current Safari support in Selenium 2 however).
Combining those two things, Selenium 2 inside of a Maven plugin, should accomplish your goal quite well :)

Related

SpringBoot Devtools without IDE

I was wondering whether is possible to use the devtools within spring-boot and Maven only, without any IDE.
My question is about quick changes tests, using sublime text or notepad++ and console mvn spring-boot:run.
As I know, It could be done using mvn compile in another console. But, I was thinking something simpler such as ng serve does in Angular.
I found two plugins for sublime and one for notepad++ which execute console command (in your case mvn compile) on save event.
SublimeCommandOnSave - this plugin is directly dedicated to run command on save event.
sublime-hooks - this one has a lot of more option than previous, you can fire diffrent actions (i.e console command, http request) on diffrent events.
In notepad++ case please refer this question.

GWT Super Development Mode issue while loading the application

I have installed the GWT SDK version as 2.8.1. I am able to run the application in GWT with Jersy. But, when I try to run the application in GWT Development mode(Super), URL is generating like http://127.0.0.1:9876. When I place this URL in browser not loading the expected UI page. I am getting the page like,
When I click on Dev Mode On button, I am getting this page.
Even I clicked on module name (gwtsample), then I am getting the page like below,
I have even added the GWT extension in browser level and tried the same. But, still no luck.
Instead of trying with the eclipse downloaded GWT SDK, I have externally downloaded the same version of GWT SDK and applied in the Project Properties > GWT > General Settings. Still, facing the same issue only.
I have observed one more thing is, in project facets GWT version is showing like 1.0 where originally I am using 2.8.1 version of SDK. My project is configured with Maven.
I have even gone through multiple questions and solutions which are mentioned in stackoverflow as well as other websites, still, no solution found.
Links which I referred was,
GWT Super Dev Mode
Debugging in GWT Super Dev Mode?
GWT Super Dev mode and in production
some other as well...
You have to compile your GWT application and host in a webserver.
Then navigate to this webserver with your browser. And finally press the DevModeOn bookmarklet to switch to superdevmode.
Drag the bookmarklets (Dev mode on/off) to your bookmarks bar
Compile your gwtsample project into a war
Deploy the war into a webserver like tomcat or jetty
Take your browser (Chrome highly recommended for GWT debugging) and navigate to your installation : for example http://localhost:8080/gwtsample
Now you are just seeing your compiled version in the browser
Next hit the "Dev mode on" bookmarklet.
You will see a message in the browser that compilation is taking place
Now you are in SuperDevMode
Change something in your code
Hit F5 in the browser. Now a recompile will happen and you will see your changes
You can always hit "Dev mode off" to switch off superdevmode. Now you will just see your original compiled application.
Extra : if you are using Eclipse I highly recommend using the branflake plugin : https://github.com/gwt-plugins/gwt-eclipse-plugin
He has some great videos of how to use it : https://www.youtube.com/watch?v=DU7ZQVLR5Zo&list=PLBbgqtDgdc_TqzA-qXrjgTFMC_6DKAQyT
This way you don't even need to compile and host in some webserver as you can run with an embedded Jetty webserver.
You need a HTTP server to serve your HTML host page and webapp (Tomcat, Jetty, Wildfly, Apache+PHP, Rails, choose whatever you need).
Then, launch GWT's CodeServer with -launcherDir pointing to where your webapp lives. It will create a *.nocache.js specific for SuperDevMode, possibly overwriting your production one.
Now, load your webapp as usual from the web server, the specific *.nocache.js will compile your sources on the fly.
If you can live with a simple servlet container, then DevMode (instead of CodeServer) will do all the above setup automatically: use -war instead of -launcherDir.
You shouldn't need to open the CodeServer URL (on port 9876 by default) or use the bookmarklets with any recent GWT version, starting with 2.7.

How to publish a Maven project

I am developing a Java framework/API to solve a problem at a client. The code/idea is my property (not the client's). I think it might be useful for others, so I would like to publish it as a open source project.
By publishing I mean bringing it out in the open - making it available as a Maven project.
I can think of conforming to Maven structure, proper documentation/example usage available on a web site, and unit tests, maybe some code coverage threshold.
But does it have to be run by some committee? Do I have to present it to somebody? What steps do I need to take to eventually have it available as a Maven dependency?
There's no committee or approval process that I know of. All you have to do is put your code into a public Github repo. This is how open source software works.
Per Kapep's excellent suggestion below, you have to choose a license as well. Apache, Creative Commons, Gnu, MIT - these are a few of your choices. Know what they mean before you decide.
Your problem begins on that day - you'll have to make others aware of it and see if it's adopted by others. If it's good, you'll have the nice problems of dealing with a user base and having others change your code. If not, it'll languish in the repo.

Unpacking firefox via maven for Selenium

Problem How can I ensure correct browser versions at test execution time for selenium to run against?
Given that selenium requires specific browser version and I don't want to manage installing and updating versions on win (lin would be easier via puppet) I need a way to deploy the right browser version during my build.
Is this what other folks are doing?
bundle firefox, chrome browser versions as archive files
deploy these to my maven repository (nexus)
at build time use dependency plugin unpack goal to extract browser archive to target//
at test execution time, feed in location to browser executable and use that with selenium driver
Or is there a plugin that already handles this for me and am I re-inventing the wheel.
Thanks for the help.
Peter
This ceased to be an issue as my team decided to use chrome not firefox. So, here's the whole process for handling chrome driver and unpacking chrome. you can easily adjust it for firefox.
https://stackoverflow.com/a/38984738/9950

Is it possible to use Chutzpah with Jenkins?

I'm no experience with Jenkins, I'm currently researching different options for PHP & JS automated unit testing with Jenkins.
I've come across Chutzpah (which uses PhantomJS's headless WebKit browser) but:
Is it possible to use Chutzpah with Jenkins?
There's very little documentation on Chutzpah. Although it does state on the Chutzpah homepage that it can be integrated into the TeamCity continuous integration server.
What's the minimum requirements for something to be compatible with Jenkins?
It is possible to use Chutzpah with Jenkins and with the 2.1 release of Chutzpah it is easier. Chutzpah's command line client can now take /junit argument that lets you specify a file name to output a junit-xml compatible file to. You can use Jenkins to pick this file up and report the test results.
I am not the downvoter, but I agree it is difficult to give a good answer to this question.
I believe the minimum requirement for something to be compatible with Jenkins is: It can be executed from a shell or cmd script. (If it's not, you need to find or write a plugin.)
Additionally, the thing should exit with code 0 for success and anything else for failure. (If it doesn't, you need to find or write a plugin.)
If you are interested in having Jenkins publish test results, the results must be in xml files using junit compatible notation. (If they are not, you need find or write a plugin.)
Additional requirements might be imposed by the tool you want to execute: It might need to draw windows or access the mouse or other parts of a graphical UI desktop/session. If that's the case, you need to run Jenkins in a context/session where it has access to those. (Windows, Mac and Linux all restrict background daemon/service access to the GUI desktop.)
Also, if your tool needs to access resources which are accessible by only certain user, you need to run Jenkins as that user.
This is a very open-ended question. Please try it out and come back with more concrete questions.

Resources