JPragma Blog

Pragmatic Developers, Elegant Software

Archive for the ‘Uncategorized’ Category

Project release and version management using gradle and git

leave a comment »

Two very useful Gradle plugins:

1. axion-release-plugin
https://github.com/allegro/axion-release-plugin

This plugin derives project version from tags in git repository. I use following rules in my projects:

  • Start with default version 0.1.0-SNAPSHOT
  • Every release of master branch increments second digit
  • Production emergency fixes are done on a branch, which is created from the version tag. Such branch name must start with “hotfix-” prefix. Releasing this branch will increment 3rd digit.
  • Feature branches must have “topic-” prefix. They are never released, however their version includes feature name.

To check current project version run “gradle currentVersion”
To release the project run “gradle release”

2. gradle-nexus-plugin
https://github.com/bmuschko/gradle-nexus-plugin

This plugin adds ability to upload project artifacts to nexus repository. Simply run “gradle upload”.

Example gradle.build

buildscript {
    repositories {
        maven {url = 'http://repo1.maven.org/maven2'}
    }
}

plugins {
    id 'java'
    id 'pl.allegro.tech.build.axion-release' version '1.3.4'
    id 'com.bmuschko.nexus' version '2.3.1'
}

scmVersion {
    versionIncrementer 'incrementMinor'
    branchVersionIncrementer = [
            'hotfix-.*' : { c -> c.currentVersion.incrementPatchVersion() }
    ]
    branchVersionCreator = [
            'topic-.*' : 'versionWithBranch'
    ]
}

group 'com.jpragma.myproject'
version = scmVersion.version

repositories {
    jcenter {url = 'http://jcenter.bintray.com/'}
}

dependencies {
    compile 'org.slf4j:slf4j-api:1.7.21'
    testCompile 'junit:junit:4.12'
}

nexus {
    sign = false
    repositoryUrl = 'http://localhost:8081/nexus/content/repositories/internal/'
    snapshotRepositoryUrl = 'http://localhost:8081/nexus/content/repositories/internal-snapshots/'
}
Advertisements

Written by isaaclevin

July 12, 2016 at 2:03 pm

Posted in Uncategorized

Useful aliases and ENVs in cygwin .profile

leave a comment »

alias cp=’cp -i’
alias mv=’mv -i’
alias df=’df -h’
alias du=’du -h’
alias grep=’grep –color’
alias itest=’mvn clean test verify -U’
alias ls=’ls -h –color’
alias mci=’mvn clean install -U’
alias mi=’mvn install’
alias mjr=’mvn jetty:run -o’
alias mjrwithprofile=’mvn clean jetty:run -DAPP_ENV=dev -Dspring.profiles.active=dev’
alias ps=’ps -W -a -f ux’
alias rm=’rm -i’

function xtitle {
echo -ne “\033]0;$1\007″
}

export MAVEN_OPTS_BASE=”-server -Xms128m -Xmx2048m -XX:MaxPermSize=256m”
export MAVEN_OPTS_DEBUG=”$MAVEN_OPTS_BASE -Xdebug=true -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=5555,server=y,suspend=n -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.port=7777″
alias mvnAllOff=’export MAVEN_OPTS=$MAVEN_OPTS_BASE’
alias mvnDebugOn=’export MAVEN_OPTS=$MAVEN_OPTS_DEBUG’

mvnDebugOn

Written by isaaclevin

May 11, 2016 at 8:45 am

Posted in Uncategorized

Insert semicolons and braces in correct position

leave a comment »

One thing that always disturbed me when editing Java source files is that you need to move your hands out of keyboard’s home row, press <End> and then type semicolon or open brace. Not anymore! I recently discovered pretty cool feature in Eclipse that automatically inserts semicolons and braces in correct positions.

Enable this option via Preferences -> Java -> Editor -> Typing dialog.

Written by isaaclevin

February 14, 2010 at 7:23 pm

Posted in Uncategorized