In my current Hybris project one of coding standard is to publish SonarQube report before every push to master. This rule is nice, but not always everyone fallows it.

This is why I’ve wanted to introduce plugin that can automatically generates SonarQube analysis results in BitBucket (Stash) pull-request. And I’ve found it: SonarQube Stash (BitBucket) plugin.

The workflow looks as fallow:

user creates pull-request 
-> hook executes Jenkins job 
-> sonar-scanner executes analysis in preview mode 
-> Executing post-job org.sonar.plugins.stash.StashIssueReportingPostJob
-> SonarQube analysis overview has been reported to Stash.

It’s almost perfect, but instead of comments in lines with violations I get a lot of messages like this:

Comment "squid:S1134" cannot be pushed to Stash like it does not belong to diff view - nc3cockpit/src/com/nespresso/nc3/cockpit/components/header/ (line: 14)

How to fix “Comment cannot be pushed to Stash like it does not belong to diff view”

In my case the problem was with project configuration. Analysed code was in different location then GIT root directory:


Similar structure can be checked here:

Note that I’m referring to old version of this repo where this problem exists. In the newest revision whole project is configured in a way that problem “Comment cannot be pushed” is not occurring.

I’m executing sonar-scanner from Jenkins, so the working directory is ./ instead of ./src/. This is why my command was like this:

sonar-scanner sonar.projectBaseDir=./src/

and main



Full path to file:




Should be:


The Fix

Move your main file from ./src/ to ./, change into:


execute command:

sonar-scanner sonar.projectBaseDir=./



During development of my fix PR#56 (which is not need eventually), I created GIT repo to test the solution. If you fallow those two links you can find some more interesting things how it’s working.

And it’s all started from Issue: Comment “xxx” cannot be pushed to Stash like it does not belong to diff view.


How to add Groovy and Spock to your Hybris extension.

My goal is to develop new features for our eCommerce solution with TDD methodology. To achieve that I want to use fancy technologies: Groovy and Spock.

Hybris uses ant, and don’t have direct support for Spock, but has for Groovy. To introduce this framework to your Hybris 5.4, please fallow those steps:

General advice, read my comments in code listing.


Make sure, you configure groovy extensions in your hybris instance. To check this, please go to hybris\config\localextensions.xml and look for two entries:

<hybrisconfig (...)>
		<extension dir="${HYBRIS_BIN_DIR}/ext-platform-optional/ygroovy" />
		<extension dir="${HYBRIS_BIN_DIR}/ext-platform-optional/groovynature" />

Step 1

Configure your extension to use maven and add groovy (EXTENSION_PATH/extensioninfo.xml):

    <extension (...) usemaven="true">
        <requires-extension name="groovynature"/>

Step 2

This step is needed if you didn’t create extension with groovy nature.

Add missing ant macrodef, for your extension (EXTENSION_PATH/buildcallbacks.xml):

<project name="EXTENSION_NAME_buildcallbacks">    
	<macrodef name="EXTENSION_NAME_before_build">
            <!-- defines native file extension used by the nature of the extension -->
            <property name="ext.EXTENSION_NAME.native.file.extension" value="groovy"/>
            <!-- defines source folder for groovy files -->
            <property name="ext.EXTENSION_NAME.additional.src.dir" value="groovysrc"/>
            <!-- defines test source folder for groovy tests -->
            <property name="ext.EXTENSION_NAME.additional.testsrc.dir" value="groovytestsrc"/>
                    <fileset dir="${ext.EXTENSION_NAME.path}">
                        <include name="${ext.EXTENSION_NAME.additional.src.dir}/**"/>
                <targetfiles path="${HYBRIS_TEMP_DIR}/touch/EXTENSION_NAME_srctouch"/>
                    <touch mkdirs="true">
                    <fileset dir="${ext.EXTENSION_NAME.path}">
                        <include name="${ext.EXTENSION_NAME.additional.testsrc.dir}/**"/>
                <targetfiles path="${HYBRIS_TEMP_DIR}/touch/EXTENSION_NAME_testsrctouch"/>
                    <touch mkdirs="true">

    <macrodef name="EXTENSION_NAME_after_compile_core">
            <groovynature_compile_core extname="EXTENSION_NAME"/>

Step 3

Add required dependencies to your extension (EXTENSION_PATH/external-dependencies.xml):

<project xmlns="" xmlns:xsi=""
		<!-- TESTING -->
			<version>1.0-groovy-2.3</version><!-- Hybris 5.4 depends on Groovy 2.3, so we are obligated to use this version -->
		<!-- Optional dependencies for using Spock -->
		<!-- use a specific Groovy version rather than the one specified by spock-core -->
		<!-- already in hybris
		<dependency> <!-- enables mocking of classes (in addition to interfaces) -->
		<dependency> <!-- enables mocking of classes without default constructor (together with CGLIB) -->
		<dependency> <!-- only required if Hamcrest matchers are used -->
			<version>5.0.3</version><!-- watch out for this one! -->

Run maven to update your new dependencies:

hybris\bin\platform> ant updateMavenDependencies

Maven should download all your new dependencies into EXTENSION_PATH/lib folder.

Step 4

Replace old ASM library with newer. Spock requires this change.

Replace: hybris/bin/platform/ext/core/lib/asm-3.3.1.jar with asm-5.0.3.jar.

You can find this JAR in your EXTENSION_PATH/lib folder.

Step 5

Create your firs Spock Specification in folder EXTENSION_PATH/groovytestsrc.


import de.hybris.bootstrap.annotations.UnitTest
import org.junit.Test
import spock.lang.Specification

 * @UnitTest is really important for Hybris to know when this test should be executed.
 * Without any of de.hybris.bootstrap.annotations.* annotation, test mechanism will not pick up this specification.
 * Created by kirkor on 7/25/2016.
class SimpleStringComparatorSpec extends Specification {

     * If a test class don't have at least one test annotation,
     * TestClassesUtil will ommit this test and it will not be executed.
    def "should concatenate two strings into one"() {
            String test = "I have a dog"
            test += " and two cats."
            test == "I have a dog and two cats."


hybris\bin\platform> setantenv.bat
hybris\bin\platform> cd ..\custom\EXTENSION
hybris\bin\custom\EXTENSION> ant build
 [echo] preparing...
 [echo] building extension 'EXTENSION'...
  [groovyc] Compiling 1 source files to hybris\bin\custom\EXTENSION\classes
[testClassesScanner] Found 1 EXTENSION testclasses in 14.25 ms
Total time: 10 seconds
hybris\bin\custom\EXTENSION> ant unittests*
 [echo] preparing...
 [echo] Annotations : unittests
 [echo] Extensions  : EXTENSION
 [echo] Packages(+) :*
 [echo] Packages(-) :
 [echo] JUnit Split :
 [echo] Web         : false
|-- Adding Filter for package*
|-- Adding Filter for UnitTests
|-- Adding Filter for extension EXTENSION
 [yunitint] Using TestClassesUtil...
 [yunitint] Found 1 filtered classes...
 [yunitint] Scanning finished in : 337ms, found 1 testclasse(s)!
 [yunitint] --> found 1 testclasses!
 [yunitint] Running
 [yunitint] INFO  [main] (junit) [SimpleLog4jPerformanceMeasurement] Test method concatenate two strings into one succeeded. Time taken: 181.5 ms
 [yunitint] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.636 sec
     [echo] Report generated to src/hybris/log/junit/index.html

What we just achieve is the possibility of running together, the old JUnit tests and Spock Specification. This is because Spock is build on top of JUnit, as a Runner.

This is extremely useful if we already have some test in JUnit, but we want to add new with Spock, and run them from command line on Jenkins or Bamboo – to have one big report about our tests.

Yesterday I faced one problem, how to insert new row to SQLite database with newline char.

First I’ve try to use CHAR(13) function (witch is ASCI newline char), but the Android version of SQLite does not have char function (Exception).

Finally I found the way how to do it:

insert into TABLE ('column') values ('First line, ' || x'0A' || 'Second line.');

Special characters || are responsible for concatenation, tells that his is a HEX value, and 0A is hex representation of Line Feed.


Few weeks ago I watch one video on YouTube by Tomasz Dziurko: Jinkubator #28 – 1011 błędów w rekrutacji, które pokazują jaki będzie twój kod. It’s in polish, but some of you may enjoy. I really fall in love with this sentence: I write and read faily well ;-)

I write about this because yesterday I faced one English grammar problem. During implementation of one feature I’ve add an method to our interface:


It’s about returning list of codes for different categories. One of my code reviewer told me that this against English grammar – I couldn’t believe ;-)

First because other similar methods looks the same eg:


Second it was against my logic, but after all it occurs that my logic throws there RuntimeException ;-)

I even ask question about it on StackOverflow and the conclusion was:

As both a native English speaker and a Java programmer: getCategoryCodes() is preferable. getCategoriesCodes() implies to me that I am getting multiple codes for each category, or that the codes relate to the collection of categories, rather than a code for each category.

As an example from “real” English: a car has one driver; you would refer to the drivers of many cars as “car drivers”, not “cars drivers”.

If you are interested in more detailed discussion please read my post: Java naming conventions versus English language correctness

Today I faced small confusion how to configure my Eclipse to use JRebel with Grails 3 framework. This is step by step configuration.

  1. Get ready with your eclipse on fedora 22 and gnome shell (I’m using sts-3.7.0.RELEASE);
  2. Install Gradle IDE Plugin;
    Screenshot from 2015-09-30 10-25-49
  3. Install JRebel – it’s just a tool to autoreloading classes and spring beans ;-);
    Screenshot from 2015-10-02 10-49-40
  4. Install Groovy 2.4 support from GitHub, (eclipse 4.5 Mars);
    Screenshot from 2015-10-02 10-43-57
  5. Create your Grails 3 application
    grails create-app hello-world --profile=web
    cd hello-world
    grails> create-controller homePage
  6. Import project into eclipse;
  7. Edit file (to add JRebel compatibility), documentation at GitHub:
    buildscript {
      repositories {
      dependencies {
         classpath group: 'org.zeroturnaround', name: 'gradle-jrebel-plugin', version: '1.1.2'
    apply plugin: 'rebel'
  8. Run “gradle generateRebel” -> generate rebel.xml file
    1. In eclipse, Window -> Show view -> Other -> Select Gradle -> Gradle Tasks
      Screenshot from 2015-10-02 15-06-47
    2. The file is generated under this location: build/classes/main/rebel.xml

During the next few days I will publish how to run Grails 3 with JRebel:

  1. From command line without JRebel
  2. From command line with JRebel
  3. From eclipse as a Spring Boot Application without JRebel
  4. From eclipse as a Spring Boot Application with JRebel

When I run the default eclipse STS-3.7.0 on the linux fedora 22 the look and feel is not what I’m expecting. Especially margin of tabs, button, text is too big. I’m loosing a lot of screen space because of this “nice GTK3 look”. The problem is with current GTK3 theme that is used by fedora on Gnome Shell 3.16.2. I’ve tried many different approaches to change this (editing css styles for eclipse, editing current GTK3 theme), but the simplest and the best is just to use GTK2 to run eclipse.

To achieve this, create simple bash script (like in  your eclipse directory:

export SWT_GTK3=0

Remember to make this file “runnable”:

chmod +x

This is how the eclipse looks before:

Screenshot from 2015-10-02 09-31-39


Screenshot from 2015-10-02 09-43-05