Showing posts with label Tools. Show all posts
Showing posts with label Tools. Show all posts

Tuesday, 28 July 2015

Version Numbering - Redux

The issue

I have been looking at version numbering for a project where the developers had stuck at 0.0.1-SNAPSHOT for 12 months and were starting to encounter issues with getting the correct JARS for their projects from their binary repository.

The solution was to use the features that are present in Maven and Jenkins to assist them in their processes.

I covered the basics of version numbering in an other post (May 2012), but that just gives the version strategy for Apache projects. Since then I have come across Semantic Versioning which is a great a almost definitive source on how you should work with versions.
However this does not cater for the way Maven actually treats version numbers, it is just compatible with it..

A good version number has a number of properties:
  • Natural order: it should be possible to determine at a glance between two versions which one is newer
  • Maven support: Maven should be able to deal with the format of the version number to enforce the natural order
  • Machine incrementable: so you don't have to specify it explicitly every time

What does Maven do?

For reference, Maven version numbers are comprised as follows: <MajorVersion>.<MinorVersion>.<IncrementalVersion>-<BuildNumber | Qualifier>. Where MajorVersion, MinorVersion, IncrementalVersion and BuildNumber are all numeric and Qualifier is a string. If your version number does not match this format, then the entire version number is treated as being the Qualifier. [See]
If all the version numbers are equal, the qualifier is compared alphabetically. "RC1" and "SNAPSHOT" and sorted no differently to "a" and "b". As a result, "SNAPSHOT" is considered newer because it is greater alphabetically. See this page as a reference.
The issue on may projects is how to manage the versions and how to do so with out breaking the Maven format which will cause Maven to treat your versions as just the Qualifier which is a string (not good). Note that a.b.c-RC1-SNAPSHOT would be considered older than a.b.c-RC1, because of text comparisons.

What to use as an Incremental version number?

I think it is reasonably straight forwards for a project to determine the major and minor version as they often come directly from the business drivers for the project.
The Incremental version can give some issues as the business may not be interested and it is the developers that need it for tracking purposes.
Therefore the incremental number has be be meaningful to them.
So usefull numbers could be the database schema version, the sprint number the feature set that is being implemented (although this can be hard if you have several teals working in parallel).

The simplest way is to start at 1 and for the team leads to determine when to increase the number.

Whether to use as a Qualifier or a BuildNumber?

There appear to be several schools of thought on this and Maven simply fits with them all.
The Apache method is to not have either and using the SNAPSHOT qualifier allows you to follow this pattern.
However, SNAPSHOT does not allow your developers to know what to use the version for.
JBoss has qualifiers (alpha[n], beta[n], release candidate 'CR[n]' and Final) with optional numbers. [See].
The OSGI specification adds a further complication as does the eclipse numbering which are
MajorVersion, MinorVersion, IncrementalVersion.TIMESTAMP[-Mn]
MajorVersion, MinorVersion, IncrementalVersion.CR[n]
MajorVersion, MinorVersion, IncrementalVersion.Final
There are only two qualifiers.  The first one is for the milestone releases, and the qualifier starts with a numeric timestamp.  The project can use a timestamp as shown below as it will sort according to the compareTo method of the String class just like any other qualifier. ie YYYYMMDD
Optionally, if for some reason there is a need to make two releases in the same day, you can add a sequence number to the end of the timestamp. The next part of the qualifier is the milestone number, where M stands for milestone, and n is the milestone number.
After all the milestone releases that have added the various functional pieces are complete, and the project and any sub-projects that are integrated are at least at a candidate release stage, then a CR release will follow.  Just like in the traditional model, there may be multiple CR releases depending on the feedback from the community.

It is the above approach minus the milestone number I would advise (assuming the 'IncrementalVersion' is controlled by the development team.

Setting up Maven

Making sure your version numbers are incremented can be a pain in the arse but there is  a plugin for Maven that helps you mange this.

The Maven 'Release' Plugin

The Release plugin [See] is helpful but not essential. It is used to help a developer release a project with Maven, saving a lot of repetitive, manual work. Its best usage is to allow the developer to update their version number with out effort and correctly.

It is added to the maven project as follows:

 <project>  
     ...  
     <build>  
         <plugins>  
             ...  
             <plugin>  
                 <groupId>org.apache.maven.plugins</groupId>  
                 <artifactId>maven-release-plugin</artifactId>  
                 <version>2.5.2</version>  
             </plugin>  
             ...  
         </plugins>  
         ...  
     </build>  
     ...  
 </project>  

easy!

This allows the developer to issue a command as follows:
 mvn -B release:update-versions  
... and the version will be updated to the next increment. They then only need to commit it as part of their code.
It is always the last part of the version number that is incremented and it even works if you have a text qualifier such as CRn (see above).

Maven Versions Plugin

This plugin is much more useful when it comes to controlling your release via your CI server. [See]
(In these examples I'm going to quote Jenkins but this process should work for others.)
(I am also not sure if Maven 3.1+ doesn't include this plugin.)

Unlike the previous plugin that increments the version, this will allow a specific version number to be set in the POM, like this:
 mvn versions:set -DnewVersion=0.1.1-RC1  

Where '0.1.1-RC1' is an example of a version number.

The process

Now to tie this together.
The process we want is:
  1. Jenkins checks out the latest revision from SCM (Subversion, Mercurial, Git, ...)
  2. Release Plugin transforms the POMs with the new version number
  3. Maven compiles the sources and runs the tests
  4. Release Plugin commits the new POMs into SCM
  5. Maven publishes the binaries into the Artifact Repository
Prerequisites: Jenkins with a JDK and Maven configured, and both the Git and the Workspace Cleanup, and Parameterized Trigger Plugin  plugins installed.
We're going to start by creating a new Maven job and making sure we have a fresh workspace for every build:


After assigning you SCM, the next step is to set the version upon checkout.
A good version number is both unique and chronological. We're going to use the Jenkins BUILD_NUMBER (the current build number, such as "153") as it fulfills both these criteria wonderfully.
We could use BUILD_ID which is such as "2005-08-22_23-59-59" (YYYY-MM-DD_hh-mm-ss).
or even the Git commit number using GIT_REVISION.
This is configured as follows:



and in the build step:

And that's it! Every time this job is run, a new release is produced, the artifacts will be deployed and the source code will be tagged. The version of the release will be the BUILD_NUMBER (or GIT_REVISION) of the Jenkins project. Nice and simple.

Tuesday, 9 June 2015

Cool Tool of the Day: OutlookGoogleSync

A nice little tool to get your work outlook appointments into your Google calendar.

http://outlookgooglesync.codeplex.com/

It only pushes data from Outlook to Google but for those like me who only want an update on my phone it is more than enough.
 
According to the project it is a...

A small tool to keep the Google calendar in sync with the Outlook calendar (one way: Outlook -> Google).
Doesn't need admin rights and works behind a proxy.
Works with Outlook 2003 and newer.

There is an alternate http://calendarsyncplus.codeplex.com/

Thursday, 21 May 2015

Cool tool of the day:

Why is my Eclipse so Slow?
Optimizer for Eclipse

As much as many devs will say that eclipse is the best IDE, it still sucks when it comes to starting up.
Luna is an improvement over some of the earlier versions but it can still leave you waiting for it to start.

This is a topic I have visited before (Setting up Eclipse check list (Part 1), Eclipse Configuration settings) but now comes "Optimizer for Eclipse". A plugin by  Zeroturnaround (the people who brought us JRebel) so it has an impressive pedigree.

The plugin works by tuning the startup settings for eclipse. Again this can be done by hunting these settings down but its nice to have them all in one place.
Once installed it prompts you to select a number of options, restarts eclipse and tells you if you saved any time. It then disappears to site under the Help menu.

On my first use of it I turned off class validation and found that Eclipse started 1 full minute faster.

So I'm pleased!

How to install

Either install using:
  • Marketplace
    Open Help → Eclipse Marketplace…
    Search for Optimizer for Eclipse.
    Press Install.
  • Update site
    Open Help → Install New Software…
    Add this repository.
    Complete the plugin installation.

Wednesday, 8 April 2015

Cool tool of the day: jsonschema2pojo

So we all love JSON?

AND I love Java but creating the Java classes to serve or parse your JSON is a pain.

Especially when the JSON alters!

So use jsonschema2pojo!

It comes with a handy code generator Maven plugin.

The steps are as follows:

  1. Create a Java project with a maven POM;
  2. Add the code generator as seen in the documentation;
  3. Capture your JSON;
  4. Create the JSON schema in the folder specified in your POM using jsonschema.net;
  5. run mvn generate-sources;
Done!

Friday, 7 March 2014

Code School

Ok I've tried to get to grips with GIT ... finally! and I have been shown a realy  nice learning resource.

Code School!


Please take a look as it is quite fascinating ... http://try.github.io

Cool tip of the day: Come the Dark side! ... Eclipse Theme colours

After some eye dazling hours working with the standard black on white editor in Eclipse and witnessing the relativly calm appearance of Visual Studios Dark theme I decided to see if I could do the same with eclipse.
I discovered that it is relativly straight forwards and lots of otherpeople think the same way. I have included links to the plugins you need and a list of the other blogs and posts that will be helpfull should you go over to the dark side!

  1. Download the ‘Dark Juno’ theme 
  2. https://github.com/rogerdudler/eclipse-ui-themes.
    This will change the color of all eclipse view and toolbars to a dark theme. However we still have to change the color theme of the editor.
  3. Get the Eclipse Color Themes plugin
    http://www.eclipsecolorthemes.org/
    Install a dark theme for the editor from there.
    I like the Retta theme but its your choice.
And that should be it!

The other references are:

Friday, 7 February 2014

I just thought this was fun:

Vampirestat.com

Vampirestat domain and site appraisal!

This site is a full featured Website Statistics and domain appraisal service. You can easily check out your own website value in seconds. Our software collects information about the domains from various sources and makes it available to the users. Try and look up your domain right now.
 

Monday, 27 January 2014

Cool tip of the day: gource

I have the funny feeling that this is one of those tools that could be really useful if you could think of a sensible way to use it.
It produces an interesting visualisation of the changes occurring in your source control system.

It works with SVN & GIT but I have only seen it work so far with GIT and that was with a team of 3.
With that set up we were able to visualise the scope of work performed over the two week sprint as part of our sprint-retrospective.

Gource is a software version control visualization tool.
See more of Gource in action on the Videos page.

Wednesday, 18 December 2013

Cool tip of the day: find that port on a windows PC

I get fed up of never being able to find the port of a particular process on a windows PC.
It is easy under Unix as you can use Grep.
So here is a reminder on how to do it for windows:

netstat -ano | findstr <Port>

Or for the process:

netstat -ano | findstr <PID>

Or for an established connection:

netstat -ano | findstr :80 | findstr ESTABLISHED

See the following other references:

Tuesday, 12 November 2013

Cool tool of the Day: Random.org


File this one under NICE!!!



The site random.org says about its self:

RANDOM.ORG offers true random numbers to anyone on the Internet. The randomness comes from atmospheric noise, which for many purposes is better than the pseudo-random number algorithms typically used in computer programs.
Random values from the environment ... excellent!
None of the pseudo-random values you get from normal random number generators.

Friday, 1 November 2013

Cool tool of the day: Sitemesh

Why Use SiteMesh?

SiteMesh is a lightweight and flexible Java web application framework that applies the Gang of Four decorator pattern to allow a clean separation of content from presentation.

I am posting it here as I have used this tool before and really like it but I just spent 10 minutes attempting to recall what it was called.

The jars for site mesh can be found on the Maven repository or but pasting this into your POM.xml:


<dependency>
    <groupId>opensymphony</groupId>
    <artifactId>sitemesh</artifactId>
    <version>2.4.2</version>
</dependency>
            

Setting up Eclipse (again)

I have documented the setting up of eclipse before but in the almost two years since that post I have learned a few new tricks. SO I'm documenting them here in case they are useful to someone else.

Java JDK

You will probably have Java installed, but it will only be the JRE, which will hot have all the environment variables established. The JDK can be found by searching on Google and it will probably be the top link.
I have this time around down loaded the version 7 JDK from here (http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html). (Don't forget to pick the right version and accept the licensing  terms).

On a windows PC the easiest location to install all of these files is under a single directory structure ... with NO spaces in the name.
I will use "c:\development" throughout this post (cos it's what I use).

So:
  1. Download the JDK installer;
  2. Place it in a new folder  "c:\development\java";
  3. Run the installer (as administrator);
  4. Wait for it to start & press the next buttons;
  5. At the Optional Features deselect the "Public JRE" as you already have one;
  6. Change the installed directory to  "c:\development\java\jdk1.7.0_45\" (where 1.7.0_45 is the JDK version);
  7. Now install by pressing next;
  8. Set an environment variable JAVA_HOME = C:\development\java\jdk1.7.0_45;
  9. Add to the PATH environment variable %JAVA_HOME%\bin;
  10. Open a command prompt and check that the maven command "java-version" runs and gives the correct version.

Maven

Since my last version of this install guide I have been working with Maven, which is a build tool. I had produced a nice set of ANT scripts to do what MAVEN does but I have decided that this is just too much like reinventing the wheel.

So:
  1. Download the zip;
  2. Place into a new folder "c:\development\maven";
  3. Extract the files to  "C:\development\maven\apache-maven-3.1.1";
  4. Create an environment variable M2 = C:\development\maven\apache-maven-3.1.1;
  5. Add to the PATH environment variable %M2%\bin;
  6. Open a command prompt and check that the maven command "mvn -version" runs and gives the correct version.

Eclipse 

With the JDK set up now install the version of Eclipse you prefer.
My current favorite is the Spring Tool Suite (STS) since it comes with may of the tools and plugins pre-installed.

So:
  1. Download the latest STS; from http://spring.io/tools/sts/all ensuring you get the right version for your OS
  2. Place it in a new folder called "c:\development\eclipse";
  3. Run the installer (as administrator);
  4. Accept the licensing agreement;
  5. Accept the default installation location which should be C:\development\eclipse\springsource;
  6. Install all the toys;
  7. Set up the JDK path to be C:\development\java\jdk1.7.0_45;
  8. It may complain that a 32-bit or 64-bit version is needed which means you made a mistake at step #1;
  9. When prompted for a short cut group call it "Java Development";
  10. Launch the tool set to ensure it works;
  11. When prompted for a workspace create one with out spaces ie. "C:\development\projects\default-eclipse";
  12. You may be prompted to install any updates if they exist;
  13. Create a "Hello World" project and check whether you have Java set up correctly;

Eclipse plugins (optional)

Having installed Eclipse it is now a mater of installing a set of plugins. These vary accourding to taste and your development purpose; mine is Java web development.
I've written about the set of plugins I use before (here, & here and here). 
I'm not going to detail which ones I'm just going to list those that I use and include a 'bookmark.xml' import to list them.
The Plugins I use are:
  1. Sysdeo JSP/Tomcat Manager -  This plugin allows you to start or stop the tomcat environment and perform remote debuging;
  2. Log4e - Log4E is an Eclipse Plugin which helps you to use your logger easily in Java Projects; 
  3. StartExplorer- This plug-in gives you a convenient way to examine a file or a folder outside the Eclipse workspace with your file manager or open a shell/cmd.exe  and do all this by adding a few entries to Eclipse's context menus.
  4. SubEclipse - Links to your subversion source control.
  5. Aptana Studio -  HTML, CSS etc editing
 
 Interesting ones:
  1. C# development

XAMPP

This has to be the sweetest install of the set. It is an entire Apache LAMP stack installer with Tomcat included.
The best version if you are installing to windows is the full instalation tool sooner than the zip version.

So:
  1. Download the latest XAMPP;
  2. Place it in a new folder called "c:\development\xampp";
  3. Run the installer (as administrator);
  4. Follow the next buttons and select all the toys;
  5. Select the installation to c:\development\xampp\1.8.3 (where 1.8.3) is the current version;
  6. Wait a long time for the installation top complete;
  7. Start the control panel and start up HTTPD;
  8. Open a browser and check http://localhost, if you don't get a page titled XXXX then you may have something else running on port 80.
    The usual culprits are IIS or Skype these systems need to be configured to use any thing other than 80,443, 8080, 8443 (which are all ports used by Httpd & Tomcat);
    Shut those services down or change their ports (see articles on IIS or Skype respectivly) and retry (PS. don't forget to force your browser to refresh the page or you could be thinking it is still there).
  9. Tomcat should have its admin user set up.
    You can check this by browsing to http://127.0.0.1:8080/manager/status.
    If it fails shut down tomcat & edit the web-users.xml file (in the above config this is C:\development\xampp\1.8.3\tomcat\conf\web-users.xml);
    Add a set of nodes as follows:
    <role rolename="manager-gui"/>
    <user username="tomcat" password="s3cret" roles="manager-gui"/>
    Then restart.
<< Previously in this series
 

Thursday, 5 September 2013

Cool tip of the day: Formatting source code for your blog

Oh finally!
I have pasted code into my blog & it has been a real pain to get it right.
While looking around I found a resource on blogspot http://formatmysourcecode.blogspot.co.uk/ which provides an online utility to format the script into html to include on your blog.
It has two outputs, one with inline CSS and the other with a set of styles used.
The "linked style sheet" option depends on a PRE.source-code style.

An example of this formatting is as follows:

/**
 * The HelloWorldApp class implements an application that
 * simply prints "Hello World!" to standard output.
 */
class HelloWorldApp {
    public static void main(String[] args) {
        System.out.println("Hello World!"); // Display the string.
    }
}

A second resource can be found at http://codeformatter.blogspot.co.uk/ which has similar options  but allows you to define whether you have line numbers on your code. When you don't use embedded styles it creates a style element which defines two classes pre.CICodeFormatter and code.CICodeFormatter.

An example of this output is as follow:

1:  /**  
2:   * The HelloWorldApp class implements an application that  
3:   * simply prints "Hello World!" to standard output.  
4:   */  
5:  class HelloWorldApp {  
6:    public static void main(String[] args) {  
7:      System.out.println("Hello World!"); // Display the string.  
8:    }  
9:  }  

A third which I have yet to check is "How to use PrettyPrint to format source code in Blogger" which is a utility on blogger.com which is where this site is.
But more on this an other day.

Friday, 5 July 2013

Cool tool of the day: vLetter

Vletter is a nice way to create handwritten text quickly.

As they say on their site:

We create your own handwriting fontto use on your computer. vLetter captures the natural variations in your handwriting to give your letters, cards and other correspondence a unique, personal touch. Your handwriting font also includes your signature, so you can sign documents and letters with ease. We've been creating personal handwriting fonts since 1988!
Any way its kinda fun ...

Cheers

Tuesday, 9 April 2013

Cool Tip of the day - An online barcode generator

A 2-d barcode for this site.
If you want one of those neat little 2-d barcodes for your web site or project, then pop over to http://www.barcode-generator.org/.

It includes many of the most popular formats for barcodes, including QR codes as seen on this page; 2-d data matrices and EAN which appears on most retail products.

Wednesday, 20 March 2013

Cool tool tip of the day: Rant and Rave

Gathering customer feed back can assist and drive sales.
According to Rapide Communications who produce the "RantandRave" product:

"The most important aspect of capturing feedback is timing. Response rates increase 10% to 12% and accuracy increases by 40% simply by requesting feedback straight after service delivery."


I interviewed with these guys and from the research I did their product sounds very useful.

http://rantandrave.com/feedback/capturing-customer-feedback/

Friday, 15 March 2013

Cool tip of the day - Bitnami Stacks

When you need a LAMP stack or a Tomcat Stack for development ... what do you do?

Yes you go trawling around the net looking for all the bits and how to glue them together.
Well don't just go to http://bitnami.org/stacks and download their all in one stack.

My favorite is the tomcat stack!

Cool tip of the day - Newrelic server and app monitoring

 This looks worth an invertigate if you have some servers to watch: https://newrelic.com/

They say on their web site that they do the following:
New Relic is the all-in-one web application performance tool that lets you see performance from the end user experience, through servers, and down to the line of application code.

They seem to have the free try before you buy option while their full price offering is $24 per month. This could be considered expensive for some uses especially as it seems to be offering much that Google analytics also offers.

But one to think about nether the less.

Friday, 8 March 2013

Virgin Media and Stackoverflow

I don't usually complain about my ISP Virgin media but recently I have found their tech support is shockingly bad.
While I will not dwell on one of their IT support guys doing a remote connection to my PC and resetting my network drivers ... blue screen of death!
It looks as if they would not know a network fault if it had a big sign hanging around its neck!
At this time it is impossible for me to access stackoverflow.com and as I am at home doing technical research this is a pain in the arse.
So after the support muppets have told me to restart my PC, change my network settings and reboot my modem ... even when I tell them the iPad can not connect they then tell me I need to contact stackoverflow directly and advise them that that they have blocked the IP range my requests are coming from. That is an interesting idea ... but I can't contact them because I can't get to their web site & emails are blocked!

But it isn't just me ... read on ...

One post suggested using a VPN, which I have now set up.
The free VPN I used was justfreevpn.com which did not at first work.
Why?
Because the Virgin Super hub blocks all PPTP traffic. (Go to your router-->Advanced Settings-->Security-->Firewall and select PPTP Pass through to be on.)





But now I have a VPN to enable when I need to access the blocked sites.

Struth!

Tuesday, 5 March 2013

Tool tip of the day - Netsparker!

Have you heard of a tool called Netsparker ?  It will scan your site for XSS exploits, useful for testing you haven't left something wide open !

What is Netsparker?

Netsparker is the only False-positive-free web application security scanner. Simply point it at your website and it will automatically discover the flaws that could leave you dangerously exposed.

http://www.mavitunasecurity.com/netsparker/

Thanks for the tip Neil.