Skip to content

Commit

Permalink
feat: new build script and stepping dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Oct 5, 2024
1 parent f744fa6 commit bdc7e4c
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 104 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/gradle-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: Call Gradle CI

on: [workflow_dispatch, push, pull_request]

jobs:
call-workflow:
uses: tomasbjerre/.github/.github/workflows/gradle-ci.yml@master
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# violations-gradle-plugin changelog

Changelog of violations-gradle-plugin.

## 2.1.2 (2024-09-29)

Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This is a Gradle plugin for [Violations Lib](https://github.com/tomasbjerre/violations-lib). There is also a [Maven plugin](https://github.com/tomasbjerre/violations-maven-plugin) for this.

| Version | Java Version |
| ------------------| ------------ |
| version < 2.0.0 | 8 |
| 2.0.0 <= version | 11 |

Published to [plugins.gradle.org](https://plugins.gradle.org/plugin/se.bjurr.violations.violations-gradle-plugin).

It can parse results from static code analysis and:
Expand Down Expand Up @@ -150,7 +155,7 @@ A number of **parsers** have been implemented. Some **parsers** can parse output

Missing a format? Open an issue [here](https://github.com/tomasbjerre/violations-lib/issues)!

## Usage ##
## Usage
There is a running example [here](https://github.com/tomasbjerre/violations-gradle-plugin/tree/master/violations-gradle-plugin-example).

Having the following in the build script will make the plugin run with `./gradlew build`.
Expand Down
27 changes: 5 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
apply plugin: 'java-library'

buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'se.bjurr.gradle:gradle-scripts:2.+'
}
plugins {
id "se.bjurr.gradle.conventional-release"
id "se.bjurr.gradle.java-convention"
id "se.bjurr.gradle.update-versions"
}
project.ext.buildConfig = [
repoType: "GRADLE",
gradlePlugin: [
tags: ['violation', 'static code analysis', 'Checkstyle', 'CPPLint', 'CPPCheck', 'CSSLint', 'Findbugs', 'Flake8', 'PyLint', 'Pep8', 'Mccabe', 'PyFlakes', 'JSHint', 'Lint', 'PerlCritic', 'PMD', 'ReSharper', 'XMLLint'],
implementationClass: 'se.bjurr.violations.gradle.plugin.ViolationsGradlePlugin'
],
violations: [
updateReadme: true
]
]
apply from: project.buildscript.classLoader.getResource('main.gradle').toURI()

dependencies {
implementation 'se.bjurr.violations:violations-git-lib:2.2.1'
implementation 'se.bjurr.violations:violations-git-lib:2.3.2'
}
11 changes: 8 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#Sun Sep 29 09:27:54 CEST 2024
description=Gradle that will find report files from static code analysis, present and optionally fail the build.
version=2.1.2
description=Find report files from static code analysis, present and optionally fail the build.
group=se.bjurr.violations
implementationClass=se.bjurr.violations.gradle.plugin.ViolationsGradlePlugin
repoType=GRADLE
sourceCompatibility=11
tags=violation,static code analysis,Checkstyle,CPPLint,CPPCheck,CSSLint,Findbugs,Flake8,PyLint,Pep8,Mccabe,PyFlakes,JSHint,Lint,PerlCritic,PMD,ReSharper,XMLLint
targetCompatibility=11
version=2.1.3
maxViolations=6
5 changes: 0 additions & 5 deletions release.sh

This file was deleted.

13 changes: 13 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
pluginManagement {
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
}
}

plugins {
id "se.bjurr.gradle.conventional-release" version "0.+" apply false
id "se.bjurr.gradle.java-convention" version "0.+" apply false
id "se.bjurr.gradle.update-versions" version "0.+" apply false
}
26 changes: 13 additions & 13 deletions src/main/java/se/bjurr/violations/gradle/plugin/ViolationsTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import static java.nio.file.StandardOpenOption.CREATE;
import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
import static java.nio.file.StandardOpenOption.WRITE;
import static se.bjurr.violations.violationsgitlib.se.bjurr.violations.git.ViolationsReporterApi.violationsReporterApi;
import static se.bjurr.violations.violationsgitlib.se.bjurr.violations.git.ViolationsReporterDetailLevel.VERBOSE;
import static se.bjurr.violations.violationsgitlib.se.bjurr.violations.lib.ViolationsApi.violationsApi;
import static se.bjurr.violations.violationsgitlib.se.bjurr.violations.lib.model.SEVERITY.INFO;
import static se.bjurr.violations.violationsgitlib.se.bjurr.violations.lib.model.codeclimate.CodeClimateTransformer.fromViolations;
import static se.bjurr.violations.git.ViolationsReporterApi.violationsReporterApi;
import static se.bjurr.violations.git.ViolationsReporterDetailLevel.VERBOSE;
import static se.bjurr.violations.lib.ViolationsApi.violationsApi;
import static se.bjurr.violations.lib.model.SEVERITY.INFO;
import static se.bjurr.violations.lib.model.codeclimate.CodeClimateTransformer.fromViolations;

import java.io.File;
import java.io.IOException;
Expand All @@ -23,14 +23,14 @@
import org.gradle.api.DefaultTask;
import org.gradle.api.logging.LogLevel;
import org.gradle.api.tasks.TaskAction;
import se.bjurr.violations.violationsgitlib.se.bjurr.violations.git.ViolationsGit;
import se.bjurr.violations.violationsgitlib.se.bjurr.violations.git.ViolationsReporterDetailLevel;
import se.bjurr.violations.violationsgitlib.se.bjurr.violations.lib.ViolationsLogger;
import se.bjurr.violations.violationsgitlib.se.bjurr.violations.lib.model.SEVERITY;
import se.bjurr.violations.violationsgitlib.se.bjurr.violations.lib.model.Violation;
import se.bjurr.violations.violationsgitlib.se.bjurr.violations.lib.reports.Parser;
import se.bjurr.violations.violationsgitlib.se.bjurr.violations.lib.util.Filtering;
import se.bjurr.violations.violationsgitlib.se.bjurr.violations.violationslib.com.google.gson.GsonBuilder;
import se.bjurr.violations.git.ViolationsGit;
import se.bjurr.violations.git.ViolationsReporterDetailLevel;
import se.bjurr.violations.lib.ViolationsLogger;
import se.bjurr.violations.lib.model.SEVERITY;
import se.bjurr.violations.lib.model.Violation;
import se.bjurr.violations.lib.reports.Parser;
import se.bjurr.violations.lib.util.Filtering;
import se.bjurr.violations.violationslib.com.google.gson.GsonBuilder;

public class ViolationsTask extends DefaultTask {

Expand Down
139 changes: 82 additions & 57 deletions violations-gradle-plugin-example/build.gradle
Original file line number Diff line number Diff line change
@@ -1,71 +1,96 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
repositories {
mavenLocal()
mavenCentral()
}

dependencies {
classpath "se.bjurr.violations:violations-gradle-plugin:+"
}
dependencies {
classpath "se.bjurr.violations:violations-gradle-plugin:+"
}
}

apply plugin: "java"
apply plugin: "se.bjurr.violations.violations-gradle-plugin"

task violations(type: se.bjurr.violations.gradle.plugin.ViolationsTask) {
//
// Optional config
//
maxReporterColumnWidth = 0 // 0 is disabled
maxRuleColumnWidth = 10
maxSeverityColumnWidth = 0
maxLineColumnWidth = 0
maxMessageColumnWidth = 50
codeClimateFile = file('code-climate-file.json') // Will create a CodeClimate JSON report.
violationsFile = file('violations-file.json') // Will create a normalized JSON report.
//
// Optional config
//
maxReporterColumnWidth = 0 // 0 is disabled
maxRuleColumnWidth = 10
maxSeverityColumnWidth = 0
maxLineColumnWidth = 0
maxMessageColumnWidth = 50
codeClimateFile = file('code-climate-file.json') // Will create a CodeClimate JSON report.
violationsFile = file('violations-file.json') // Will create a normalized JSON report.

//
// Global configuration, remove if you dont want to report violations for
// the entire repo.
//
minSeverity = 'INFO' // INFO, WARN or ERROR
detailLevel = 'VERBOSE' // PER_FILE_COMPACT, COMPACT or VERBOSE
maxViolations = 99999999 // Will fail the build if total number of found violations is higher
printViolations = true // Will print violations found in diff
//
// Global configuration, remove if you dont want to report violations for
// the entire repo.
//
minSeverity = 'INFO' // INFO, WARN or ERROR
detailLevel = 'VERBOSE' // PER_FILE_COMPACT, COMPACT or VERBOSE
maxViolations = 99999999 // Will fail the build if total number of found violations is higher
printViolations = true // Will print violations found in diff


//
// Diff configuration, remove if you dont want to report violations for
// files changed between specific revisions.
//
// diff-properties can be supplied with something like:
//
// ./gradlew violations -i -PdiffFrom=e4de20e -PdiffTo=HEAD
//
// And in Travis, you could add:
//
// script:
// - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bash ./gradlew check -PdiffFrom=$TRAVIS_PULL_REQUEST_BRANCH -PdiffTo=$TRAVIS_BRANCH ; fi'
//
diffFrom = project.properties.diffFrom // Can be empty (ignored), Git-commit or any Git-reference
diffTo = project.properties.diffTo // Same as above
diffMinSeverity = 'INFO' // INFO, WARN or ERROR
diffDetailLevel = 'VERBOSE' // PER_FILE_COMPACT, COMPACT or VERBOSE
diffMaxViolations = 99 // Will fail the build if number of violations, in the diff within from/to, is higher
diffPrintViolations = true // Will print violations found in diff
gitRepo = file('.') // Where to look for Git
//
// Diff configuration, remove if you dont want to report violations for
// files changed between specific revisions.
//
// diff-properties can be supplied with something like:
//
// ./gradlew violations -i -PdiffFrom=e4de20e -PdiffTo=HEAD
//
// And in Travis, you could add:
//
// script:
// - 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bash ./gradlew check -PdiffFrom=$TRAVIS_PULL_REQUEST_BRANCH -PdiffTo=$TRAVIS_BRANCH ; fi'
//
diffFrom = project.properties.diffFrom // Can be empty (ignored), Git-commit or any Git-reference
diffTo = project.properties.diffTo // Same as above
diffMinSeverity = 'INFO' // INFO, WARN or ERROR
diffDetailLevel = 'VERBOSE' // PER_FILE_COMPACT, COMPACT or VERBOSE
diffMaxViolations = 99 // Will fail the build if number of violations, in the diff within from/to, is higher
diffPrintViolations = true // Will print violations found in diff
gitRepo = file('.') // Where to look for Git


//
// This is mandatory regardless of if you want to report violations between
// revisions or the entire repo.
//
// Many more formats available, see: https://github.com/tomasbjerre/violations-lib
violations = [
["FINDBUGS", projectDir.path, ".*/findbugs/.*\\.xml\$", "Findbugs"],
["PMD", projectDir.path, ".*/pmd/.*\\.xml\$", "PMD"],
["CHECKSTYLE", projectDir.path, ".*/checkstyle/.*\\.xml\$", "Checkstyle"],
["JSLINT", projectDir.path, ".*/jshint/.*\\.xml\$", "JSHint"],
["CSSLINT", projectDir.path, ".*/csslint/.*\\.xml\$", "CssLint"]
]
//
// This is mandatory regardless of if you want to report violations between
// revisions or the entire repo.
//
// Many more formats available, see: https://github.com/tomasbjerre/violations-lib
violations = [
[
"FINDBUGS",
projectDir.path,
".*/findbugs/.*\\.xml\$",
"Findbugs"
],
[
"PMD",
projectDir.path,
".*/pmd/.*\\.xml\$",
"PMD"
],
[
"CHECKSTYLE",
projectDir.path,
".*/checkstyle/.*\\.xml\$",
"Checkstyle"
],
[
"JSLINT",
projectDir.path,
".*/jshint/.*\\.xml\$",
"JSHint"
],
[
"CSSLINT",
projectDir.path,
".*/csslint/.*\\.xml\$",
"CssLint"
]
]
}

0 comments on commit bdc7e4c

Please sign in to comment.