Skip to content

Commit

Permalink
feat: new build script and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Oct 5, 2024
1 parent 019469d commit bcd0177
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 60 deletions.
2 changes: 0 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# violations-command-line changelog

Changelog of violations-command-line.

## 3.0.3 (2024-09-08)

Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ This is a command line tool that will find report files from static code analysi
- Can used like `docker run --mount src="$(pwd)",target=/home/violations-command-line,type=bind tomasbjerre/violations-command-line:a.b.c -v "FINDBUGS" src/test/resources/findbugs/ ".*main\.xml$" "Spotbugs"`.
- Or open a shell to have a look `docker run --rm -it --entrypoint sh tomasbjerre/violations-command-line:a.b.c`

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

Run it with:

```bash
Expand Down
57 changes: 11 additions & 46 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,51 +1,16 @@
apply plugin: 'java-library'

buildscript {
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
classpath 'se.bjurr.gradle:gradle-scripts:2.+'
}
plugins {
id "se.bjurr.gradle.conventional-release" version "0.+"
id "se.bjurr.gradle.java-convention" version "0.+"
id "se.bjurr.gradle.update-versions" version "0.+"
}
project.ext.buildConfig = [
repoType: "COMMAND",
publishing: [
relocate: [
"org:org",
"com:com"
]
],
violations: [
updateReadme: true
],
manifest: [
mainClass: 'se.bjurr.violations.main.Main'
],
sourceCompatibility: 11,
targetCompatibility: 11
]
apply from: project.buildscript.classLoader.getResource('main.gradle').toURI()

shadowJar {
exclude 'META-INF/versions/21/**'
}

dependencies {
api('se.bjurr.violations:violations-git-lib:2.2.0') {
/**
* Jackson contains class files with more recent java-version in ./META-INF/versions/19
* This causes problems for Shadow when creating fat jar.
*
* java.lang.IllegalArgumentException: Unsupported class file major version 61
* at shadow.org.objectweb.asm.ClassReader.<init>(ClassReader.java:184)
*/
exclude group: "com.fasterxml.jackson.core", module: "jackson-core"
exclude group: "com.fasterxml.jackson.core", module: "jackson-databind"
exclude group: "com.fasterxml.jackson.datatype", module: "jackson-datatype-jsr310"
}
implementation 'com.fasterxml.jackson.core:jackson-core:2.14.+'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.+'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.+'
api 'info.picocli:picocli:4.7.5'
api 'org.slf4j:slf4j-simple:2.0.6'
testImplementation 'junit:junit:4.13.2'
api 'se.bjurr.violations:violations-git-lib:2.3.2'
api 'info.picocli:picocli:4.7.6'
api 'org.slf4j:slf4j-simple:2.0.16'
testImplementation 'junit:junit:4.13.2'
}
11 changes: 9 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#Sun Sep 08 08:15:35 CEST 2024
#
#Sat Oct 05 21:30:02 CEST 2024
description="CLI find report files from static code analysis, present and optionally fail."
version=3.0.3
group=se.bjurr.violations
mainClass=se.bjurr.violations.main.Main
maxViolations=6
relocate=org\:org,com\:com
repoType=COMMAND
sourceCompatibility=11
targetCompatibility=11
version=3.1.0
7 changes: 7 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pluginManagement {
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
}
}
2 changes: 1 addition & 1 deletion src/main/java/se/bjurr/violations/main/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static void main(final String[] args) throws Exception {
Arrays.asList(Parser.values()).stream()
.map((it) -> it.name())
.collect(Collectors.joining(", "));
System.out.println("Available parsers are:\n" + parsers + "\n");
System.out.println("Available parsers are:\n" + parsers + "\n"); // NOPMD
}
System.exit(commandLine.execute(args));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public int handleExecutionException(
final Exception ex, final CommandLine commandLine, final ParseResult parseResult)
throws Exception {
if (ex instanceof TooManyViolationsException) {
System.err.println(ex.getMessage());
System.err.println(ex.getMessage()); // NOPMD
} else {
ex.printStackTrace(System.err);
}
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/se/bjurr/violations/main/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,28 +258,28 @@ public void run() {
}
this.violationsConfig.setShowDebugInfo(this.wasGiven(this.showDebugInfo));
if (this.violationsConfig.isShowDebugInfo()) {
System.out.println("Parsed parameters:\n" + this.toString());
System.out.println("Parsed parameters:\n" + this.toString()); // NOPMD
}
}

if (this.wasGiven(this.showJsonConfig)) {
final Gson gson = new GsonBuilder().setPrettyPrinting().create();
final String jsonString = gson.toJson(this.violationsConfig);
System.out.println(jsonString);
System.out.println(jsonString); // NOPMD
return;
}
this.violationsConfig.setViolationsLogger(
new ViolationsLogger() {
@Override
public void log(final Level level, final String string) {
System.out.println(level + " " + string);
System.out.println(level + " " + string); // NOPMD
}

@Override
public void log(final Level level, final String string, final Throwable t) {
final StringWriter sw = new StringWriter();
t.printStackTrace(new PrintWriter(sw));
System.out.println(level + " " + string + "\n" + sw.toString());
System.out.println(level + " " + string + "\n" + sw.toString()); // NOPMD
}
});
if (!this.violationsConfig.isShowDebugInfo()) {
Expand Down Expand Up @@ -359,15 +359,15 @@ private void checkGlobalViolations(final Set<Violation> violations) throws Scrip
.getReport(this.violationsConfig.getDetailLevel());

if (tooManyViolations) {
System.err.println("\nViolations in repo\n\n" + report);
System.err.println("\nViolations in repo\n\n" + report); // NOPMD
throw new TooManyViolationsException(
"Too many violations found, max is "
+ this.violationsConfig.getMaxViolations()
+ " but found "
+ violations.size());
} else {
if (this.violationsConfig.isPrintViolations()) {
System.out.println("\nViolations in repo\n\n" + report);
System.out.println("\nViolations in repo\n\n" + report); // NOPMD
}
}
}
Expand All @@ -390,15 +390,15 @@ private void checkDiffViolations(final Set<Violation> violations) throws ScriptE
.getReport(this.violationsConfig.getDiffDetailLevel());

if (tooManyViolations) {
System.err.println("\nViolations in repo\n\n" + report);
System.err.println("\nViolations in repo\n\n" + report); // NOPMD
throw new ScriptException(
"Too many violations found in diff, max is "
+ this.violationsConfig.getMaxViolations()
+ " but found "
+ violations.size());
} else {
if (this.violationsConfig.isDiffPrintViolations()) {
System.out.println("\nViolations in diff\n\n" + report);
System.out.println("\nViolations in diff\n\n" + report); // NOPMD
}
}
}
Expand Down

0 comments on commit bcd0177

Please sign in to comment.