Skip to content

Commit

Permalink
feat: set checkstyle max warnings 0 by default
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt committed Feb 22, 2024
1 parent bf47adc commit 57906b3
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 13 deletions.
19 changes: 18 additions & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import java.nio.file.Files
import java.time.LocalDateTime

plugins {
`java-gradle-plugin`
Expand Down Expand Up @@ -71,7 +72,23 @@ val createVersions = tasks.register("createVersions") {
doLast {
versionCatalogs.find("libs")
.ifPresent { catalog ->
val head = "package org.eclipse.edc.plugins.edcbuild;\npublic interface Versions {\n"
val copyright = """
/*
* Copyright (c) ${LocalDateTime.now().year} Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Contributors to the Eclipse Foundation - initial API and implementation
*
*/
""".trimIndent()

val head = "$copyright\n\npackage org.eclipse.edc.plugins.edcbuild;\npublic interface Versions {\n"
val tail = "\n}";

val constants = listOf("assertj", "checkstyle", "jupiter", "mockito")
Expand Down
3 changes: 1 addition & 2 deletions config/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
<module name="RegexpHeader">
<property name="severity" value="warning"/>
<property name="fileExtensions" value="java"/>
<property name="header"
value="^/\*$\n^ \* Copyright \(c\) 20\d\d((,| -) 20\d{2})? [A-Za-z].+\S$\n^ \*$\n^ \* This program and the accompanying materials are made available under the$\n^ \* terms of the Apache License, Version 2\.0 which is available at$\n^ \* https://www\.apache\.org/licenses/LICENSE-2\.0$\n^ \*$\n^ \* SPDX-License-Identifier: Apache-2\.0$\n^ \*$\n^ \* Contributors:$\n^ \* \S.*\S$\n^ \*$\n^ \*/$\n^$\n^package"/>
<property name="headerFile" value="${config_loc}/java.header"/>
<property name="multiLines" value="11"/>
</module>

Expand Down
15 changes: 15 additions & 0 deletions config/checkstyle/java.header
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
^/\*$
^ \* Copyright \(c\) 20\d\d((,| -) 20\d{2})? [A-Za-z].+\S$
^ \*$
^ \* This program and the accompanying materials are made available under the$
^ \* terms of the Apache License, Version 2\.0 which is available at$
^ \* https://www\.apache\.org/licenses/LICENSE-2\.0$
^ \*$
^ \* SPDX-License-Identifier: Apache-2\.0$
^ \*$
^ \* Contributors:$
^ \* \S.*\S$
^ \*$
^ \*/$
^$
^package
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/*
* Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
* Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Contributors:
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ class CheckstyleConvention implements EdcConvention {

@Override
public void apply(Project target) {
var cse = requireExtension(target, CheckstyleExtension.class);
var extension = requireExtension(target, CheckstyleExtension.class);

cse.setToolVersion(Versions.CHECKSTYLE);
cse.setMaxErrors(0);
target.getTasks().withType(Checkstyle.class, cs -> cs.reports(r -> {
extension.setToolVersion(Versions.CHECKSTYLE);
extension.setMaxErrors(0);
extension.setMaxWarnings(0);

target.getTasks().withType(Checkstyle.class, checkstyle -> checkstyle.reports(r -> {
r.getHtml().getRequired().set(false);
r.getXml().getRequired().set(true);
}));
Expand Down

0 comments on commit 57906b3

Please sign in to comment.