viernes, 15 de junio de 2012

Maven offline

Right so this one time at band camp.... (really don't get it??? American Pie 1 OMG!!!)

Ok moving on, I have this maven project which has like ALL THE DEPENDENCIES IN THE WORLD.

And every time I build it it start downloading all of them. Problem is 99.9999999% of the time they don't change.

How to avoid that overhead?
mvn -o
The -o modifier tells maven not to go look for the dependencies and to use the ones it already has.

Now we're on the subject I found this cool page that list all the modifiers. Nothing you could't do with a  mvn --help, never the less I need to keep posting you know.

So here it is the list of modifiers:


usage: mvn [options] [<goal(s)>] [<phase(s)>]

Options:
 -q,--quiet                        Quiet output - only show errors
 -C,--strict-checksums             Fail the build if checksums don't match
 -c,--lax-checksums                Warn if checksums don't match
 -P,--activate-profiles            Comma-delimited list of profiles to
                                   activate
 -amd,--also-make-dependents       If project list is specified, also
                                   build projects that depend on projects on the list
 -ff,--fail-fast                   Stop at first failure in reactorized
                                   builds
 -rf,--resume-from                 Resume reactor from specified project
 -fae,--fail-at-end                Only fail the build afterwards; allow
                                   all non-impacted builds to continue
 -B,--batch-mode                   Run in non-interactive (batch) mode
 -am,--also-make                   If project list is specified, also
                                   build projects required by the list
 -fn,--fail-never                  NEVER fail the build, regardless of
                                   project result
 -emp,--encrypt-master-password    Encrypt master security password
 -ep,--encrypt-password            Encrypt server password
 -up,--update-plugins              Synonym for cpu
 -N,--non-recursive                Do not recurse into sub-projects
 -npr,--no-plugin-registry         Don't use ~/.m2/plugin-registry.xml for
                                   plugin versions
 -gs,--global-settings             Alternate path for the global settings
                                   file
 -U,--update-snapshots             Forces a check for updated releases and
                                   snapshots on remote repositories
 -cpu,--check-plugin-updates       Force upToDate check for any relevant
                                   registered plugins
 -npu,--no-plugin-updates          Suppress upToDate check for any
                                   relevant registered plugins
 -V,--show-version                 Display version information WITHOUT
                                   stopping build
 -D,--define                       Define a system property
 -X,--debug                        Produce execution debug output
 -e,--errors                       Produce execution error messages
 -f,--file                         Force the use of an alternate POM file.
 -h,--help                         Display help information
 -o,--offline                      Work offline
 -pl,--projects                    Build specified reactor projects
                                   instead of all projects
 -r,--reactor                      Dynamically build reactor from
                                   subdirectories
 -s,--settings                     Alternate path for the user settings
                                   file
 -v,--version                      Display version information

jueves, 14 de junio de 2012

HTTP POST request with telnet

So I keep writing here all this things I'm force to do in order to tests things.

So this time I was require to reproduce an error in an environment other than local, and the only way was to send a HTTP request over telnet client.

Long story short this is the form of the request you should type after you are connected to the server:



POST /some-path-to-a-server-resource HTTP/1.1Cache-Control: no-cacheConnection: trueContent-Type: application/atom+xml;type=entryKeep-Alive: trueTransfer-Encoding: chunked
5;ext-name=ext-val012340
Now, the parts in red are the important ones.
Please note that this particular request is using HTTP 1.1. The HTTP 1.1 specification defines two ways to post information. The first one is the same as in HTTP 1.0 which require a content length parameter in the header.
The other one is Transfer Encoding chunked this tells the server that the content is going to be sent in waves of information.
Bear in mind this last thing otherwise the web server may answer your request with an error code other that the old and nice 200.

Not much this but, toke me a good half hour to find how to do it.
Enjoy it.

GIT stash

So have your tried GIT, it's superb!!!!!
Though some people have encounter feelings about it like this friend of mind that says "it's something they invented to make all the rest fell stupid".

Any way, one nice thing about GIT it's is stash command.
In short let's say you are working on one branch and you have to do a quick fix on your master branch, BUT you're not yet ready to commit your changes.

Stash to the rescue......
This functionality allows you to put your changes aside, WITHOUT loosing them and without needing to commit them.

How it works:

This will stash your changes
git stash save

This will list your stash changes

git stash list

This will recover your stash changes

git stash apply your_stash_name 

This will from your stash changes

git stash drom your_stash_name

where your_stash_name is listed when you run the stash list.

I understand that the concept is somehow weird but I can tell you it works just fine.
As usual I wasn't born with this knowledge so this is the brilliant page that I used when I run into this.

Hope you guys find it usefull.

miércoles, 6 de junio de 2012

How to define system variable in Mac OS

Another tricky business....
We all know how to define a system variable in Mac OS we just do:

set MY_VAR=varcontent
Now the down side of this is that when you close the console ( or the tab console), or just switch tabs the variable doesn't exists any more right????


Well you are free to google the explanation for that ( is not to hard to see though).
Any way here is how you should do it if you want the variable to survive you console:

+ Go you your home path
+ With you favorite text editor change (or create) the file ".profiles"
+ In there add you variable

And presto!!!!!
From now on the variable/s listed there will be available in each console you open (only for your user of course).

Skiping Test with Maven

This is another oldy but goldy that we always forget how to do and end up googling after the tenth run of our project:
how to stop Maven from runnig test each freaking time????


And here is the answer, just add the following parameter to your mvn command:

-DskipTests
And, as always be happy.

VM Arguments in MULE ESB

Right this is one of those things that many consider tricky, and why not I mean is not like they have a whole page about this.

Any way if you work with Mule ESB one of the thing you may find your self trying to do is to run it from the command line. No eclipse plugin no Studio no nothing.

How do you pass VM arguments to the app running inside you Mule instance?
Well look no more for here is the answer:

mule -M-Dyour.envvar=envvar_value

As you can see it's the same as running any Java app from the command line BUT the folks at Mule change it a little bit adding the "-M".

And that's it.

Jetty Remote Debug

So did you ever had to do that???? This is, you need to run you app in Jetty and debug the freaking code. Well this small snippet of code take it from this other great blog should do the trick.
export MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"
As you can see you just set an env property and you are good to go. Just run
mave jetty:run
And be happy. Bear in mind that, with this particular setup, your jetty will receive connections in port 4000. Feel free to change it at your convenience.