Git Product home page Git Product logo

commerce-gradle-plugins's Introduction

Unic commerce-gradle-plugins: Code Quality

CI

Goal

This plugin supplies tasks and extensions to help with analyzing the code quality of a SAP Commerce project.

Since such projects cannot rely on the common sonarqube and jacoco plugins for technical reasons, a plugin like this one is required to do the SCA.

History

Originally Unic had their own toolchain to build, test, analyze, deploy and configure applications in their own and their customer's hosting environment. As SAP presented the Commerce Cloud v2 environment the toolchain became less relevant and the deploy & configure components have been deprecated. With the introduction of the commerce-gradle-plugin, which seems to share some ideas with the Unic toolchain, the build and test components were deprecated, too.

So far the codequality component has survived.

Prerequsites

An already configured and ready-to-test SAP Commerce instance is required to actually execute the included tasks.

Usage

Add this to your build.gradle.ks to enable the plugin:

plugins {
    id("com.unic.commercegradleplugin.codequality") version("0.0.1")
}
apply<CodeQualityPlugin>()

Configuration

  • jacocoDependency - The GAV coordinates that should point to a jacoco agent jar.
    type: String
    default: org.jacoco:org.jacoco.agent:0.8.7:runtime

  • jacocoCliDependency - The GAV coordinates that should point to a jacoco cli jar.
    type: String
    default: org.jacoco:org.jacoco.cli:0.8.7:nodeps@jar

  • sonarrunnerDependency - The GAV coordinates that should point to a sonarrunner agent jar.
    type: String
    default: org.sonarsource.scanner.cli:sonar-scanner-cli:4.6.2.2472@jar

Tasks / Rules

jacoco<targettask> Rule

To generate coverage data you need to configure the tasks that need to be enhanced in order to enable on-the-fly instrumentation by the jacoco agent.

This tasks wraps any target task with supplemental tasks, which reconfigure a hybris installation to enable or disable jacoco on-the-fly instrumentation to generate .exec files before or after running the actual target task, respectively. The target task name is being used to generate a target file name for the jacoco execution data. The following pattern will be used: ${projectDir}/hybris/log/jacoco/jacoco-${classifier}.exec.

Example ./gradlew jacocoYUnittests jacocoYIntegrationtests

jacocoReport Task

In order for sonar to be able to pick up the reports, you will have to compile the jacoco execution data into an XML report. Call the jacocoReport target to do so before executing the sonar task, for example by defining a dependency.

sonar Task

This task executes the Sonar Runner to analyze your code and pushes a new report to Sonarqube.

Restrictions / Notes

Currently the jacoco related extensions are assuming that hybris is installed in ${projectDir}/hybris.

Development

Status: Draft

This plugin is meant to be used to supplement the (SAP commerce-gradle-plugin)[https://github.com/SAP/commerce-gradle-plugin/] plugin suite. Please make sure to stay compatible.

Prerequisites

  • Groovy SDK
  • Familiarity with Gradle
  • IDE (VS Code, IntelliJ)

Preparing the plugin(s)

  • Adjust some code
  • Check the version of the plugin in gradle.properties as this will be the version in your local maven repository.
  • Build the project and publish it into your local maven repository like so: ./gradlew publishToMavenLocal

Testing the plugin(s)

Once you've published the plugins into your local maven repository you need to tell the consuming project that you want to load the plugins from your local maven repository instead of nexus.

You can do so by adjusting the settings.gradle in the hybris-toolkit-build repository:

pluginManagement {
    repositories {
        mavenLocal()
        [...]
    }
}

rootProject.name = 'hybris-toolkit'

Make sure the mavenLocal() is the first line in the repositories section as otherwise you will run into very strange errors.

commerce-gradle-plugins's People

Contributors

lennartjuette avatar martinkriegler avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

maaaaartn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.