This is an automated email from the ASF dual-hosted git repository.
claude pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/creadur-rat.git
The following commit(s) were added to refs/heads/master by this push:
new 0aa38ebf RAT-478: Raise language level to JDK17 (#599)
0aa38ebf is described below
commit 0aa38ebfdc8dec5417886cc0173ad8388d6dc33e
Author: P. Ottlinger <[email protected]>
AuthorDate: Fri Dec 26 13:27:58 2025 +0100
RAT-478: Raise language level to JDK17 (#599)
* RAT-478: Raise language level to JDK17, remove animal-sniffer, build with
18,21,25 on GHA
* RAT-478, RAT-479: Skip site and javadoc build step on GHA with JDK17
* RAT-478: Changelog - change to language level 17, build with JDK21
* RAT-478: Remove existing JDK8 dependabot exclusions
* RAT-498, RAT-478: Update to latest tika to avoid CVE-2025-66516.
* RAT-498: Update mockito to latest version
* RAT-478: Fix dependabot config error
* RAT-478: Try to exclude steps on GHA with JDK17
* RAT-498: Update junit to 5.14.1
* RAT-498: Update dependencies during ANT Unit test runs
* RAT-478: Apply language features up to JDK17
* RAT-478: Remove unused imports and harmonize file templates
* RAT-478: Try new format in GHA to avoid JDK17 javadoc/site builds
* RAT-478: Try to change if condition
* RAT-478: Move inside expression language
* RAT-478: Do not generate javadoc/site with Java17
* RAT-498, RAT-478, RAT-527: Update dependencies und plugins
* RAT-478: Migrate to jUnit 6.1.0-M1
* RAT-478: Fix minor warnings
* RAT-478: Fix FS-VA_FORMAT_STRING_USES_NEWLINE
* RAT-478: Fix REC - REC_CATCH_EXCEPTION
Explicitly rethrow runtime exceptions instead of catching it
* RAT-478: Apply spotbugs-induced changes, improve javadoc
* RAT-478: Use UTF-8 as default encoding and fix spotbugs issues
* RAT-478: Add migration guide entries for 0.18
* RAT-478: Add changelog entry for UTF-8 fallback
* RAT-478: Fix glitches in release note template and link to migration guide
* RAT-528: Add hint to refactor annotation mechanism
* RAT-478: adapt docs concerncing Java17
* RAT-478: Rm comment as number of spotbugs warnings is stable as of >=JDK17
* RAT-478: Add documentation
---
.github/dependabot.yml | 13 +-
.github/workflows/maven.yml | 14 +-
README.md | 2 +-
ant-task-examples.xml | 2 +-
apache-rat-core/pom.xml | 1 +
apache-rat-core/spotbugs-ignore.xml | 22 +--
.../src/it/java/org/apache/rat/ReportTest.java | 2 +-
.../it/resources/ReportTest/RAT_81/verify.groovy | 2 +-
.../java/org/apache/rat/DeprecationReporter.java | 2 +-
.../main/java/org/apache/rat/OptionCollection.java | 3 +-
.../org/apache/rat/analysis/AnalyserFactory.java | 13 +-
.../rat/annotation/AbstractLicenseAppender.java | 34 ++--
.../rat/annotation/ApacheV2LicenseAppender.java | 33 ++--
.../src/main/java/org/apache/rat/api/EnvVar.java | 3 +
.../main/java/org/apache/rat/api/RatException.java | 28 ++-
.../rat/config/exclusion/ExclusionUtils.java | 10 +-
.../rat/config/exclusion/StandardCollection.java | 6 +-
.../apache/rat/config/parameters/Description.java | 17 +-
.../rat/config/parameters/DescriptionBuilder.java | 3 +-
.../rat/configuration/XMLConfigurationWriter.java | 13 +-
.../org/apache/rat/document/ArchiveEntryName.java | 10 +
.../apache/rat/document/DocumentNameMatcher.java | 2 +-
.../src/main/java/org/apache/rat/help/Help.java | 11 +-
.../main/java/org/apache/rat/license/ILicense.java | 3 +-
.../java/org/apache/rat/utils/CasedString.java | 4 +-
.../src/main/java/org/apache/rat/utils/Log.java | 2 +-
.../java/org/apache/rat/utils/ReportingSet.java | 17 +-
.../org/apache/rat/ReporterOptionsProvider.java | 62 +++---
.../src/test/java/org/apache/rat/ReporterTest.java | 25 +--
.../apache/rat/analysis/HeaderCheckWorkerTest.java | 4 +-
.../license/ApacheSoftwareLicenseTest.java | 46 +++--
.../rat/analysis/license/GPLLicenseTest.java | 30 +--
.../rat/analysis/license/W3CLicenseTest.java | 6 +-
.../rat/config/results/ClaimValidatorTest.java | 2 +-
.../configuration/XMLConfigurationReaderTest.java | 9 +-
.../org/apache/rat/testhelpers/TestingLog.java | 2 +-
.../org/apache/rat/walker/DirectoryWalkerTest.java | 2 +-
apache-rat-plugin/pom.xml | 2 +-
apache-rat-plugin/spotbugs-ignore.xml | 2 +-
.../main/java/org/apache/rat/mp/RatCheckMojo.java | 4 +-
.../src/main/java/org/apache/rat/mp/Regex.java | 8 +-
apache-rat-tasks/run-antunit.xml | 10 +-
apache-rat-tasks/spotbugs-ignore.xml | 2 +-
.../main/java/org/apache/rat/anttasks/Help.java | 1 -
.../main/java/org/apache/rat/anttasks/Report.java | 51 ++---
apache-rat-tasks/src/templates/apt/index.apt.vm.vm | 5 +-
.../apache/rat/anttasks/GeneratedReportTest.java | 218 +++++++++------------
.../org/apache/rat/anttasks/ReportOptionTest.java | 55 +++---
apache-rat-tools/spotbugs-ignore.xml | 2 +-
.../org/apache/rat/documentation/Exporter.java | 55 +++---
.../rat/documentation/options/AntOption.java | 6 +-
.../apache/rat/documentation/velocity/Matcher.java | 3 +-
.../java/org/apache/rat/tools/AntGenerator.java | 40 ++--
.../java/org/apache/rat/tools/ArgumentTypes.java | 3 +-
.../java/org/apache/rat/tools/MavenGenerator.java | 9 +-
.../src/main/java/org/apache/rat/tools/Naming.java | 3 +-
.../org/apache/rat/tools/xsd/XsdGenerator.java | 2 +-
apache-rat-tools/src/main/resources/Ant.tpl | 1 -
apache-rat-tools/src/main/resources/Args.tpl | 4 +-
apache-rat-tools/src/main/resources/Maven.tpl | 3 +-
apache-rat/spotbugs-ignore.xml | 16 --
apache-rat/src/site/apt/known_issues.apt | 6 +-
apache-rat/src/site/markdown/migration_guide.md | 1 -
.../src/site/markdown/migrationguide/0.18.md | 6 +
pom.xml | 43 ++--
src/changes/changes.xml | 24 +++
src/changes/release-notes.vm | 4 +-
src/conf/checkstyle-suppressions.xml | 4 +-
src/conf/spotbugs-exclude.xml | 16 --
src/site/apt/index.apt.vm | 6 +-
70 files changed, 534 insertions(+), 541 deletions(-)
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 2d5e10fd..26635e55 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -19,18 +19,13 @@ updates:
directory: "/"
schedule:
interval: "daily"
- ignore:
# Remember that version range definitions depend on the build tool, thus for
Maven:
#
https://docs.github.com/en/code-security/dependabot/working-with-dependabot/dependabot-options-reference#versions-ignore
#
https://maven.apache.org/pom.html#Dependency_Version_Requirement_Specification
-# RAT-478: as of 0.17 we run on JDK8 we must not update tika-core that runs on
>= JDK11
- - dependency-name: "org.apache.tika:tika-core"
- versions: ["[3,)"]
-# as we run on JDK8 we must not update mockito as it dropped JDK8 beginning
from v4.x
- - dependency-name: "org.mockito:mockito-core"
- versions: ["[5,)"]
- - dependency-name: "com.github.spotbugs:spotbugs-maven-plugin"
- versions: ["[4.9,)"]
+# Example:
+# ignore:
+# - dependency-name: "org.apache.tika:tika-core"
+# versions: ["[3,)"]
- package-ecosystem: "github-actions"
directory: "/"
schedule:
diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index df8e19b9..8dd4f3f8 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -31,14 +31,10 @@ jobs:
strategy:
matrix:
-# RAT-468: macos-latest starts with JDK11 and has no JDK8 available
- os: [ubuntu-latest, windows-latest]
-# RAT-296: disable JDK10 due to
-# Caused by: sun.security.validator.ValidatorException: PKIX path building
failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to
find valid certification path to requested target
-#
-# RAT-497: JDK17-javadoc error fails the site build, albeit javadoc:javadoc
works fine, https://bugs.java.com/bugdatabase/view_bug?bug_id=JDK-8369613
-# Java 25 is not working until we drop JDK8!
- java: [8, 11, 21]
+ os: [macos-latest, ubuntu-latest, windows-latest]
+# RAT-497: JDK17/18/19-javadoc error fails the site build, albeit
javadoc:javadoc works fine,
https://bugs.java.com/bugdatabase/view_bug?bug_id=JDK-8369613
+# Due to RAT-497 we skip javadoc and site generation with JDK17!
+ java: [17, 20, 21, 25]
fail-fast: false
runs-on: ${{ matrix.os }}
@@ -85,7 +81,9 @@ jobs:
**/target/surefire-reports
- name: Generate javadoc
+ if: ${{ matrix.java != 17}}
run: ./mvnw -e -B -V -ntp javadoc:javadoc
- name: Build site
+ if: ${{ matrix.java != 17}}
run: ./mvnw -e -B -V -ntp site site:stage
diff --git a/README.md b/README.md
index 0763a577..90d86b9e 100644
--- a/README.md
+++ b/README.md
@@ -103,7 +103,7 @@ Requires: file `src/changes/release-notes.vm` to format the
changes.xml.
To import RAT into Eclipse,
1. Clone the repository.
2. Import the directory into Eclipse as an existing Maven project.
- 3. Right click the `creadur-rat` project and execute "Run As -> Maven install"
+ 3. Right-click the `creadur-rat` project and execute "Run As -> Maven install"
The above steps will generate the necessary source code as well as testing
resources.
diff --git a/ant-task-examples.xml b/ant-task-examples.xml
index c5ddbe74..dba37cb0 100644
--- a/ant-task-examples.xml
+++ b/ant-task-examples.xml
@@ -25,7 +25,7 @@
</description>
<property name="src-dir" location="apache-rat-core/src/main/java"/>
- <property name="version" value="1.0.0"/>
+ <property name="version" value="0.18"/>
<property name="src-jar"
location="apache-rat-core/target/apache-rat-core-${version}-sources.jar"/>
diff --git a/apache-rat-core/pom.xml b/apache-rat-core/pom.xml
index 8237d8eb..4819f23b 100644
--- a/apache-rat-core/pom.xml
+++ b/apache-rat-core/pom.xml
@@ -247,6 +247,7 @@
</dependency>
<dependency>
<!-- this dependency is actually used by integration testing code -->
+ <!-- TODO RAT-527: migrate to newer version under ASF umbrella: 5.x
including itests -->
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<scope>test</scope>
diff --git a/apache-rat-core/spotbugs-ignore.xml
b/apache-rat-core/spotbugs-ignore.xml
index fc94fe36..d23d45e1 100644
--- a/apache-rat-core/spotbugs-ignore.xml
+++ b/apache-rat-core/spotbugs-ignore.xml
@@ -16,22 +16,6 @@
limitations under the License.
-->
<FindBugsFilter>
- <Match>
- <!--
- Convenience constructors that allow setting a charset are not available in
Java8 for PrintStream.
- -->
- <Class name="org.apache.rat.Report"/>
- <Bug pattern="DM_DEFAULT_ENCODING"/>
- </Match>
-
- <Match>
- <!--
- Convenience constructors that allow setting a charset are not available in
Java8 for PrintStream.
- -->
- <Class name="org.apache.rat.annotation.AbstractLicenseAppender"/>
- <Bug pattern="DM_DEFAULT_ENCODING"/>
- </Match>
-
<Match>
<Bug pattern='PATH_TRAVERSAL_IN'/>
</Match>
@@ -59,4 +43,10 @@
<Class name="org.apache.rat.Reporter"/>
<Bug pattern='XXE_XSLT_TRANSFORM_FACTORY'/>
</Match>
+
+ <!-- As we want to log errors we intentionally print stacktraces -->
+ <Match>
+ <Class name="org.apache.rat.utils.Log"/>
+ <Bug pattern='INFORMATION_EXPOSURE_THROUGH_AN_ERROR_MESSAGE'/>
+ </Match>
</FindBugsFilter>
diff --git a/apache-rat-core/src/it/java/org/apache/rat/ReportTest.java
b/apache-rat-core/src/it/java/org/apache/rat/ReportTest.java
index d29f0781..b695134a 100644
--- a/apache-rat-core/src/it/java/org/apache/rat/ReportTest.java
+++ b/apache-rat-core/src/it/java/org/apache/rat/ReportTest.java
@@ -157,7 +157,7 @@ public class ReportTest {
String urlAsFile;
try {
urlAsFile = Paths.get(url.toURI()).toString();
- } catch (URISyntaxException e) {
+ } catch (NullPointerException | URISyntaxException e) {
throw new RatException("Unable to find root directory for " + url,
e);
}
diff --git a/apache-rat-core/src/it/resources/ReportTest/RAT_81/verify.groovy
b/apache-rat-core/src/it/resources/ReportTest/RAT_81/verify.groovy
index dde3e8b3..c1a5de0c 100644
--- a/apache-rat-core/src/it/resources/ReportTest/RAT_81/verify.groovy
+++ b/apache-rat-core/src/it/resources/ReportTest/RAT_81/verify.groovy
@@ -23,7 +23,7 @@ import org.w3c.dom.NodeList
import javax.xml.xpath.XPath
import javax.xml.xpath.XPathFactory
-import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals
doc = XmlUtils.toDom(new FileInputStream(args[0]))
XPath xPath = XPathFactory.newInstance().newXPath()
diff --git
a/apache-rat-core/src/main/java/org/apache/rat/DeprecationReporter.java
b/apache-rat-core/src/main/java/org/apache/rat/DeprecationReporter.java
index 2a1dd63a..fe3acda1 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/DeprecationReporter.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/DeprecationReporter.java
@@ -134,7 +134,7 @@ public final class DeprecationReporter {
/**
* Annotation to provide deprecation information for Java8.
- * TODO remove this when Java 8 no longer supported.
+ * TODO RAT-528: remove this when Java 8 is no longer supported.
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
diff --git a/apache-rat-core/src/main/java/org/apache/rat/OptionCollection.java
b/apache-rat-core/src/main/java/org/apache/rat/OptionCollection.java
index 7a993cb9..6ce2e1c2 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/OptionCollection.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/OptionCollection.java
@@ -22,6 +22,7 @@ import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Serializable;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
@@ -149,7 +150,7 @@ public final class OptionCollection {
}
if (commandLine.hasOption(Arg.HELP_LICENSES.option())) {
- new Licenses(createConfiguration(argumentContext), new
PrintWriter(System.out)).printHelp();
+ new Licenses(createConfiguration(argumentContext), new
PrintWriter(System.out, false, StandardCharsets.UTF_8)).printHelp();
return null;
}
diff --git
a/apache-rat-core/src/main/java/org/apache/rat/analysis/AnalyserFactory.java
b/apache-rat-core/src/main/java/org/apache/rat/analysis/AnalyserFactory.java
index 681adb47..f2eca190 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/analysis/AnalyserFactory.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/analysis/AnalyserFactory.java
@@ -122,14 +122,11 @@ public final class AnalyserFactory {
*/
private Predicate<ILicense> licenseFilter(final
ReportConfiguration.Processing proc) {
return license -> {
- switch (proc) {
- case PRESENCE:
- return
!license.getLicenseFamily().equals(UnknownLicense.INSTANCE.getLicenseFamily());
- case ABSENCE:
- return true;
- default:
- return false;
- }
+ return switch (proc) {
+ case PRESENCE ->
!license.getLicenseFamily().equals(UnknownLicense.INSTANCE.getLicenseFamily());
+ case ABSENCE -> true;
+ default -> false;
+ };
};
}
diff --git
a/apache-rat-core/src/main/java/org/apache/rat/annotation/AbstractLicenseAppender.java
b/apache-rat-core/src/main/java/org/apache/rat/annotation/AbstractLicenseAppender.java
index bb9f791d..3444676a 100644
---
a/apache-rat-core/src/main/java/org/apache/rat/annotation/AbstractLicenseAppender.java
+++
b/apache-rat-core/src/main/java/org/apache/rat/annotation/AbstractLicenseAppender.java
@@ -103,17 +103,17 @@ public abstract class AbstractLicenseAppender {
private static final int TYPE_GO = 26;
/** PM files */
private static final int TYPE_PM = 27;
- /** markdown files */
+ /** Markdown files */
private static final int TYPE_MD = 28;
/** YAML files */
private static final int TYPE_YAML = 29;
/**
- * the line separator for this OS
+ * The line separator for this OS.
*/
private static final String LINE_SEP = System.lineSeparator();
/**
- * Files that are in the C family
+ * Files that are in the C family.
*/
private static final int[] FAMILY_C = new int[]{
TYPE_JAVA, TYPE_JAVASCRIPT, TYPE_C, TYPE_H, TYPE_SCALA,
@@ -146,25 +146,25 @@ public abstract class AbstractLicenseAppender {
TYPE_APT,
};
/**
- * Files in the velocity family
+ * Files in the velocity family.
*/
private static final int[] FAMILY_VELOCITY = new int[] {
TYPE_VM,
};
/**
- * Files that expect "#/some/path"
+ * Files that expect "#/some/path".
*/
private static final int[] EXPECTS_HASH_PLING = new int[] {
TYPE_PYTHON, TYPE_SH, TYPE_RUBY, TYPE_PERL, TYPE_TCL,
};
/**
- * Files that expect "@Echo"
+ * Files that expect "@Echo".
*/
private static final int[] EXPECTS_AT_ECHO = new int[]{
TYPE_BAT,
};
/**
- * Files that expact package names
+ * Files that expect package names.
*/
private static final int[] EXPECTS_PACKAGE = new int[]{
TYPE_JAVA, TYPE_GO, TYPE_PM,
@@ -176,7 +176,7 @@ public abstract class AbstractLicenseAppender {
TYPE_XML,
};
/**
- * Files that expect the PHP header
+ * Files that expect the PHP header.
*/
private static final int[] EXPECTS_PHP_PI = new int[] {
TYPE_PHP,
@@ -189,7 +189,7 @@ public abstract class AbstractLicenseAppender {
};
/**
- * Mapping of extension to fmaily type.
+ * Mapping of extension to family type.
*/
private static final Map<String, Integer> EXT2TYPE = new HashMap<>();
@@ -283,7 +283,7 @@ public abstract class AbstractLicenseAppender {
* Append the default license header to the supplied document.
*
* @param document document to append to.
- * @throws IOException if there is a problem while reading or writing the
file
+ * @throws IOException if there is a problem while reading or writing the
file.
*/
public void append(final File document) throws IOException {
int type = getType(document);
@@ -299,7 +299,7 @@ public abstract class AbstractLicenseAppender {
boolean expectsMSVSSF = expectsMSVisualStudioSolutionFileHeader(type);
File newDocument = new File(document.getAbsolutePath() + ".new");
- try (FileWriter writer = new FileWriter(newDocument)) {
+ try (FileWriter writer = new FileWriter(newDocument,
StandardCharsets.UTF_8)) {
if (!attachLicense(writer, document,
expectsHashPling, expectsAtEcho, expectsPackage,
expectsXMLDecl, expectsPhpPI, expectsMSVSSF)) {
@@ -329,7 +329,7 @@ public abstract class AbstractLicenseAppender {
DefaultLog.getInstance().warn(String.format("Could not set
%s as executable.", document));
}
} catch (InvalidPathException | IOException e) {
- DefaultLog.getInstance().error(String.format("Failed to rename
new file to %s, Original file is unchanged.", document), e);
+ DefaultLog.getInstance().error(String.format("Failed to rename
new file to %s, original file is unchanged.", document), e);
}
}
}
@@ -420,8 +420,8 @@ public abstract class AbstractLicenseAppender {
/**
* Check first line for specified text and process.
*/
- private void doFirstLine(final File document, final Writer writer, final
String line, final String lookfor) throws IOException {
- if (line.startsWith(lookfor)) {
+ private void doFirstLine(final File document, final Writer writer, final
String line, final String lookFor) throws IOException {
+ if (line.startsWith(lookFor)) {
writer.write(line);
writer.write(LINE_SEP);
writer.write(getLicenseHeader(document));
@@ -486,7 +486,6 @@ public abstract class AbstractLicenseAppender {
return "";
}
-
/**
* Get the last line of the license header formatted
* for the given type of file.
@@ -503,13 +502,12 @@ public abstract class AbstractLicenseAppender {
return "";
}
-
/**
* Get a line of the license header formatted
* for the given type of file.
*
- * @param type the type of file, see the TYPE_* constants
- * @param content the content for this line
+ * @param type the type of file, see the TYPE_* constants.
+ * @param content the content for this line.
* @return not null
*/
protected String getLine(final int type, final String content) {
diff --git
a/apache-rat-core/src/main/java/org/apache/rat/annotation/ApacheV2LicenseAppender.java
b/apache-rat-core/src/main/java/org/apache/rat/annotation/ApacheV2LicenseAppender.java
index 530bdff8..cd04fd17 100644
---
a/apache-rat-core/src/main/java/org/apache/rat/annotation/ApacheV2LicenseAppender.java
+++
b/apache-rat-core/src/main/java/org/apache/rat/annotation/ApacheV2LicenseAppender.java
@@ -52,6 +52,7 @@ public class ApacheV2LicenseAppender extends
AbstractLicenseAppender {
public String getLicenseHeader(final File document) {
int type = getType(document);
StringBuilder sb = new StringBuilder();
+
if (copyright == null) {
sb.append(getFirstLine(type));
sb.append(getLine(type, "Licensed to the Apache Software
Foundation (ASF) under one"));
@@ -61,16 +62,6 @@ public class ApacheV2LicenseAppender extends
AbstractLicenseAppender {
sb.append(getLine(type, "to you under the Apache License, Version
2.0 (the"));
sb.append(getLine(type, "\"License\"); you may not use this file
except in compliance"));
sb.append(getLine(type, "with the License. You may obtain a copy
of the License at"));
- sb.append(getLine(type, ""));
- sb.append(getLine(type, "
http://www.apache.org/licenses/LICENSE-2.0"));
- sb.append(getLine(type, ""));
- sb.append(getLine(type, "Unless required by applicable law or
agreed to in writing,"));
- sb.append(getLine(type, "software distributed under the License is
distributed on an"));
- sb.append(getLine(type, "\"AS IS\" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY"));
- sb.append(getLine(type, "KIND, either express or implied. See the
License for the"));
- sb.append(getLine(type, "specific language governing permissions
and limitations"));
- sb.append(getLine(type, "under the License."));
- sb.append(getLastLine(type));
} else {
sb.append(getFirstLine(type));
sb.append(getLine(type, copyright));
@@ -78,17 +69,19 @@ public class ApacheV2LicenseAppender extends
AbstractLicenseAppender {
sb.append(getLine(type, "Licensed under the Apache License,
Version 2.0 (the \"License\");"));
sb.append(getLine(type, "you may not use this file except in
compliance with the License."));
sb.append(getLine(type, "You may obtain a copy of the License
at"));
- sb.append(getLine(type, ""));
- sb.append(getLine(type, "
http://www.apache.org/licenses/LICENSE-2.0"));
- sb.append(getLine(type, ""));
- sb.append(getLine(type, "Unless required by applicable law or
agreed to in writing,"));
- sb.append(getLine(type, "software distributed under the License is
distributed on an"));
- sb.append(getLine(type, "\"AS IS\" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY"));
- sb.append(getLine(type, "KIND, either express or implied. See the
License for the"));
- sb.append(getLine(type, "specific language governing permissions
and limitations"));
- sb.append(getLine(type, "under the License."));
- sb.append(getLastLine(type));
}
+
+ sb.append(getLine(type, ""));
+ sb.append(getLine(type, "
http://www.apache.org/licenses/LICENSE-2.0"));
+ sb.append(getLine(type, ""));
+ sb.append(getLine(type, "Unless required by applicable law or agreed
to in writing,"));
+ sb.append(getLine(type, "software distributed under the License is
distributed on an"));
+ sb.append(getLine(type, "\"AS IS\" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY"));
+ sb.append(getLine(type, "KIND, either express or implied. See the
License for the"));
+ sb.append(getLine(type, "specific language governing permissions and
limitations"));
+ sb.append(getLine(type, "under the License."));
+ sb.append(getLastLine(type));
+
return sb.toString();
}
}
diff --git a/apache-rat-core/src/main/java/org/apache/rat/api/EnvVar.java
b/apache-rat-core/src/main/java/org/apache/rat/api/EnvVar.java
index 0a31798d..4abc67d2 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/api/EnvVar.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/api/EnvVar.java
@@ -24,6 +24,9 @@ import java.util.stream.Collectors;
import org.apache.rat.utils.Log;
+/**
+ * This enumeration contains and documents RAT-specific environment variables.
+ */
public enum EnvVar {
/**
* Ignore Git Global ignore file.
diff --git a/apache-rat-core/src/main/java/org/apache/rat/api/RatException.java
b/apache-rat-core/src/main/java/org/apache/rat/api/RatException.java
index 8a8b9a77..7e007bb4 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/api/RatException.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/api/RatException.java
@@ -18,31 +18,53 @@
*/
package org.apache.rat.api;
+import java.io.Serial;
+
+/**
+ * This exception is used to indicate error conditions during RAT runs.
+ */
public class RatException extends Exception {
/**
- * Creates a RatException out of any other type of exception.
- * If the exception is already a RatException, just return it.
+ * Creates a {@code RatException} out of any other type of exception.
+ * If the exception is already a {@code RatException}, just return it.
* @param exception the exception to convert.
- * @return A RatException.
+ * @return a {@code RatException}.
*/
public static RatException makeRatException(final Exception exception) {
return exception instanceof RatException ? (RatException) exception :
new RatException(exception);
}
+ @Serial
private static final long serialVersionUID = 4940711222435919034L;
+ /**
+ * Constructor.
+ */
public RatException() {
super();
}
+ /**
+ * Constructor with message and cause.
+ * @param message an error message to give more context.
+ * @param cause a cause.
+ */
public RatException(final String message, final Throwable cause) {
super(message, cause);
}
+ /**
+ * Constructor with message only.
+ * @param message an error message to give more context.
+ */
public RatException(final String message) {
super(message);
}
+ /**
+ * Constructor with cause only.
+ * @param cause a cause.
+ */
public RatException(final Throwable cause) {
super(cause);
}
diff --git
a/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/ExclusionUtils.java
b/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/ExclusionUtils.java
index 4c7f9ced..5908b3c8 100644
---
a/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/ExclusionUtils.java
+++
b/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/ExclusionUtils.java
@@ -20,9 +20,9 @@ package org.apache.rat.config.exclusion;
import java.io.File;
import java.io.FileFilter;
-import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
@@ -136,9 +136,9 @@ public final class ExclusionUtils {
verifyFile(patternFile);
Objects.requireNonNull(commentFilters, "commentFilters");
try {
- return ExtendedIterator.create(IOUtils.lineIterator(new
FileReader(patternFile))).filter(commentFilters);
- } catch (FileNotFoundException e) {
- throw new ConfigurationException(format("%s is not a valid file.",
patternFile));
+ return ExtendedIterator.create(IOUtils.lineIterator(new
FileReader(patternFile, StandardCharsets.UTF_8))).filter(commentFilters);
+ } catch (IOException e) {
+ throw new ConfigurationException(format("%s is not a valid file.",
patternFile), e);
}
}
@@ -165,7 +165,7 @@ public final class ExclusionUtils {
Objects.requireNonNull(commentFilters, "commentFilters");
// can not return LineIterator directly as the patternFile will not be
closed leading
// to a resource leak in some cases.
- try (FileReader reader = new FileReader(patternFile)) {
+ try (FileReader reader = new FileReader(patternFile,
StandardCharsets.UTF_8)) {
List<String> result = new ArrayList<>();
Iterator<String> iter = new LineIterator(reader) {
@Override
diff --git
a/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/StandardCollection.java
b/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/StandardCollection.java
index 13c0cb5d..7ec79ae6 100644
---
a/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/StandardCollection.java
+++
b/apache-rat-core/src/main/java/org/apache/rat/config/exclusion/StandardCollection.java
@@ -103,12 +103,13 @@ public enum StandardCollection {
*/
HIDDEN_DIR("The hidden directories. Directories with names that start with
'.'",
null,
- new DocumentNameMatcher("HIDDEN_DIR", new
Predicate<DocumentName>() {
+ new DocumentNameMatcher("HIDDEN_DIR", new Predicate<>() {
@Override
public boolean test(final DocumentName documentName) {
File file = documentName.asFile();
return file.isDirectory() &&
ExclusionUtils.isHidden(documentName.getShortName());
}
+
@Override
public String toString() {
return "HIDDEN_DIR";
@@ -120,12 +121,13 @@ public enum StandardCollection {
*/
HIDDEN_FILE("The hidden files. Directories with names that start with '.'",
null,
- new DocumentNameMatcher("HIDDEN_FILE", new
Predicate<DocumentName>() {
+ new DocumentNameMatcher("HIDDEN_FILE", new Predicate<>() {
@Override
public boolean test(final DocumentName documentName) {
File file = documentName.asFile();
return file.isFile() &&
ExclusionUtils.isHidden(documentName.getShortName());
}
+
@Override
public String toString() {
return "HIDDEN_FILE";
diff --git
a/apache-rat-core/src/main/java/org/apache/rat/config/parameters/Description.java
b/apache-rat-core/src/main/java/org/apache/rat/config/parameters/Description.java
index c5524971..6aa20bd3 100644
---
a/apache-rat-core/src/main/java/org/apache/rat/config/parameters/Description.java
+++
b/apache-rat-core/src/main/java/org/apache/rat/config/parameters/Description.java
@@ -246,19 +246,14 @@ public class Description {
*/
public Method setter(final Class<?> clazz) throws NoSuchMethodException,
SecurityException {
String methodName = methodName(isCollection ? "add" : "set");
- switch (type) {
- case LICENSE:
- throw new NoSuchMethodException("Can not set a License as a
child");
- case MATCHER:
- return clazz.getMethod(methodName, IHeaderMatcher.Builder.class);
- case PARAMETER:
- return clazz.getMethod(methodName,
+ return switch (type) {
+ case LICENSE -> throw new NoSuchMethodException("Can not set a
License as a child");
+ case MATCHER -> clazz.getMethod(methodName,
IHeaderMatcher.Builder.class);
+ case PARAMETER -> clazz.getMethod(methodName,
IHeaderMatcher.class.isAssignableFrom(childClass) ?
IHeaderMatcher.Builder.class : childClass);
- case BUILD_PARAMETER:
- return clazz.getMethod(methodName, childClass);
- }
+ case BUILD_PARAMETER -> clazz.getMethod(methodName, childClass);
+ };
// should not happen
- throw new IllegalStateException("Type " + type + " not valid.");
}
private void callSetter(final Description description, final
IHeaderMatcher.Builder builder, final String value) {
diff --git
a/apache-rat-core/src/main/java/org/apache/rat/config/parameters/DescriptionBuilder.java
b/apache-rat-core/src/main/java/org/apache/rat/config/parameters/DescriptionBuilder.java
index 52d16b63..2d2df5de 100644
---
a/apache-rat-core/src/main/java/org/apache/rat/config/parameters/DescriptionBuilder.java
+++
b/apache-rat-core/src/main/java/org/apache/rat/config/parameters/DescriptionBuilder.java
@@ -50,8 +50,7 @@ public final class DescriptionBuilder {
* @return the Description of the object.
*/
public static Description build(final Object object) {
- if (object instanceof ILicense) {
- ILicense license = (ILicense) object;
+ if (object instanceof ILicense license) {
Class<?> clazz = object.getClass();
ConfigComponent configComponent =
clazz.getAnnotation(ConfigComponent.class);
if (configComponent == null || configComponent.type() !=
ComponentType.LICENSE) {
diff --git
a/apache-rat-core/src/main/java/org/apache/rat/configuration/XMLConfigurationWriter.java
b/apache-rat-core/src/main/java/org/apache/rat/configuration/XMLConfigurationWriter.java
index da232834..79e7da99 100644
---
a/apache-rat-core/src/main/java/org/apache/rat/configuration/XMLConfigurationWriter.java
+++
b/apache-rat-core/src/main/java/org/apache/rat/configuration/XMLConfigurationWriter.java
@@ -68,14 +68,11 @@ public class XMLConfigurationWriter {
private Predicate<Description> attributeFilter(final Description parent) {
return d -> {
if (d.getType() == ComponentType.PARAMETER) {
- switch (parent.getType()) {
- case MATCHER:
- return !XMLConfig.isInlineNode(parent.getCommonName(),
d.getCommonName());
- case LICENSE:
- return !licenseChildren.contains(d.getCommonName());
- default:
- return true;
- }
+ return switch (parent.getType()) {
+ case MATCHER ->
!XMLConfig.isInlineNode(parent.getCommonName(), d.getCommonName());
+ case LICENSE ->
!licenseChildren.contains(d.getCommonName());
+ default -> true;
+ };
}
return false;
};
diff --git
a/apache-rat-core/src/main/java/org/apache/rat/document/ArchiveEntryName.java
b/apache-rat-core/src/main/java/org/apache/rat/document/ArchiveEntryName.java
index 99bdcc45..13b4668e 100644
---
a/apache-rat-core/src/main/java/org/apache/rat/document/ArchiveEntryName.java
+++
b/apache-rat-core/src/main/java/org/apache/rat/document/ArchiveEntryName.java
@@ -71,4 +71,14 @@ public class ArchiveEntryName extends DocumentName {
superLocal = superLocal.substring(superLocal.lastIndexOf("#") + 1);
return archiveFileName.localized(dirSeparator) + "#" + superLocal;
}
+
+ @Override
+ public boolean equals(final Object other) {
+ return super.equals(other);
+ }
+
+ @Override
+ public int hashCode() {
+ return super.hashCode();
+ }
}
diff --git
a/apache-rat-core/src/main/java/org/apache/rat/document/DocumentNameMatcher.java
b/apache-rat-core/src/main/java/org/apache/rat/document/DocumentNameMatcher.java
index 676981e9..99192635 100644
---
a/apache-rat-core/src/main/java/org/apache/rat/document/DocumentNameMatcher.java
+++
b/apache-rat-core/src/main/java/org/apache/rat/document/DocumentNameMatcher.java
@@ -115,7 +115,7 @@ public final class DocumentNameMatcher {
public Iterable<DocumentNameMatcher> getMatchers() {
final List<DocumentNameMatcher> result = new ArrayList<>();
matchers.patterns().forEach(p -> result.add(new
DocumentNameMatcher(p.source(),
- new Predicate<DocumentName>() {
+ new Predicate<>() {
private final MatchPatterns patterns =
MatchPatterns.from("/", p.source());
@Override
diff --git a/apache-rat-core/src/main/java/org/apache/rat/help/Help.java
b/apache-rat-core/src/main/java/org/apache/rat/help/Help.java
index eeff0808..70adb9ff 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/help/Help.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/help/Help.java
@@ -21,6 +21,9 @@ package org.apache.rat.help;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Writer;
+import java.nio.charset.StandardCharsets;
+import java.util.Collections;
+import java.util.List;
import org.apache.commons.cli.Options;
import org.apache.rat.OptionCollection;
@@ -36,12 +39,12 @@ public class Help extends AbstractHelp {
/**
* An array of notes to go at the bottom of the help output
*/
- protected static final String[] NOTES = {
+ protected static final List<String> NOTES =
Collections.unmodifiableList(List.of(
"RAT highlights possible issues.",
"RAT reports require interpretation.",
"RAT often requires some tuning before it runs well against a
project.",
- "RAT relies on heuristics: it may miss issues"
- };
+ "RAT relies on heuristics: it may miss issues")
+ );
/** The writer this instance writes to */
protected final PrintWriter writer;
@@ -60,7 +63,7 @@ public class Help extends AbstractHelp {
* @param stream the PrintStream to write to.
*/
public Help(final PrintStream stream) {
- this(new PrintWriter(stream));
+ this(new PrintWriter(stream, false, StandardCharsets.UTF_8));
}
/**
diff --git a/apache-rat-core/src/main/java/org/apache/rat/license/ILicense.java
b/apache-rat-core/src/main/java/org/apache/rat/license/ILicense.java
index 6058a725..c81acf2f 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/license/ILicense.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/license/ILicense.java
@@ -91,10 +91,9 @@ public interface ILicense extends IHeaderMatcher,
Comparable<ILicense> {
if (license1 == o) {
return true;
}
- if (!(o instanceof ILicense)) {
+ if (!(o instanceof ILicense that)) {
return false;
}
- ILicense that = (ILicense) o;
return license1.compareTo(that) == 0;
}
diff --git
a/apache-rat-core/src/main/java/org/apache/rat/utils/CasedString.java
b/apache-rat-core/src/main/java/org/apache/rat/utils/CasedString.java
index f772d0ea..79b29d10 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/utils/CasedString.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/utils/CasedString.java
@@ -134,7 +134,7 @@ public class CasedString {
StringBuilder sb = new StringBuilder();
for (char c : string.toCharArray()) {
if (splitter.test(c)) {
- if (sb.length() > 0) {
+ if (!sb.isEmpty()) {
lst.add(sb.toString());
sb.setLength(0);
}
@@ -145,7 +145,7 @@ public class CasedString {
sb.append(c);
}
}
- if (sb.length() > 0) {
+ if (!sb.isEmpty()) {
lst.add(sb.toString());
}
return lst.toArray(new String[0]);
diff --git a/apache-rat-core/src/main/java/org/apache/rat/utils/Log.java
b/apache-rat-core/src/main/java/org/apache/rat/utils/Log.java
index b58f0ea1..5cb6999f 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/utils/Log.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/utils/Log.java
@@ -219,7 +219,7 @@ public interface Log {
@Override
public void flush() {
- if (sb.length() > 0) {
+ if (!sb.isEmpty()) {
Log.this.log(level, sb.toString());
}
sb = new StringBuilder();
diff --git
a/apache-rat-core/src/main/java/org/apache/rat/utils/ReportingSet.java
b/apache-rat-core/src/main/java/org/apache/rat/utils/ReportingSet.java
index d3c8ea8b..4acbed3b 100644
--- a/apache-rat-core/src/main/java/org/apache/rat/utils/ReportingSet.java
+++ b/apache-rat-core/src/main/java/org/apache/rat/utils/ReportingSet.java
@@ -121,15 +121,14 @@ public class ReportingSet<T> implements SortedSet<T> {
new RatException("just for trace").printStackTrace(new
PrintWriter(DefaultLog.getInstance().asWriter()));
DefaultLog.getInstance().warn(new RatException("just for
trace"));
}
- switch (duplicateOption) {
- case FAIL:
- throw new IllegalArgumentException(msg);
- case IGNORE:
- return false;
- case OVERWRITE:
- delegate.remove(e);
- return delegate.add(e);
- }
+ return switch (duplicateOption) {
+ case FAIL -> throw new IllegalArgumentException(msg);
+ case IGNORE -> false;
+ case OVERWRITE -> {
+ delegate.remove(e);
+ yield delegate.add(e);
+ }
+ };
}
return delegate.add(e);
}
diff --git
a/apache-rat-core/src/test/java/org/apache/rat/ReporterOptionsProvider.java
b/apache-rat-core/src/test/java/org/apache/rat/ReporterOptionsProvider.java
index 6cf7b458..547d16c7 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/ReporterOptionsProvider.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/ReporterOptionsProvider.java
@@ -162,25 +162,27 @@ class ReporterOptionsProvider extends
AbstractOptionsProvider implements Argumen
assertThat(contents).isEqualTo("class NoLicense {}");
assertThat(resultFile).exists();
contents = String.join("\n", IOUtils.readLines(new
FileReader(resultFile)));
- assertThat(contents).isEqualTo("/*\n" +
- " * Licensed to the Apache Software Foundation (ASF) under
one\n" +
- " * or more contributor license agreements. See the
NOTICE file\n" +
- " * distributed with this work for additional
information\n" +
- " * regarding copyright ownership. The ASF licenses this
file\n" +
- " * to you under the Apache License, Version 2.0 (the\n" +
- " * \"License\"); you may not use this file except in
compliance\n" +
- " * with the License. You may obtain a copy of the
License at\n" +
- " * \n" +
- " * http://www.apache.org/licenses/LICENSE-2.0\n" +
- " * \n" +
- " * Unless required by applicable law or agreed to in
writing,\n" +
- " * software distributed under the License is distributed
on an\n" +
- " * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
ANY\n" +
- " * KIND, either express or implied. See the License for
the\n" +
- " * specific language governing permissions and
limitations\n" +
- " * under the License.\n" +
- " */\n\n" +
- "class NoLicense {}");
+ assertThat(contents).isEqualTo("""
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under
one
+ * or more contributor license agreements. See the NOTICE
file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this
file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in
compliance
+ * with the License. You may obtain a copy of the License
at
+ *\s
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *\s
+ * Unless required by applicable law or agreed to in
writing,
+ * software distributed under the License is distributed
on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for
the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+ class NoLicense {}""");
} catch (IOException | RatException e) {
fail(e.getMessage(), e);
}
@@ -871,11 +873,12 @@ class ReporterOptionsProvider extends
AbstractOptionsProvider implements Argumen
System.setOut(out);
configureSourceDir(option);
// create a dummy stylesheet so that we have a local file for
users of the testing jar.
- File file = writeFile("stylesheet", "<xsl:stylesheet
version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n" +
- " <xsl:template match=\"@*|node()\">\n" +
- " Hello world\n" +
- " </xsl:template>\n" +
- "</xsl:stylesheet>");
+ File file = writeFile("stylesheet", """
+ <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:template match="@*|node()">
+ Hello world
+ </xsl:template>
+ </xsl:stylesheet>""");
String[] args = {null};
for (StyleSheets sheet : StyleSheets.values()) {
@@ -946,11 +949,12 @@ class ReporterOptionsProvider extends
AbstractOptionsProvider implements Argumen
System.setOut(out);
configureSourceDir(option);
// create a dummy stylesheet so that we match the stylesheet tests.
- File file = writeFile("stylesheet", "<xsl:stylesheet
version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">\n" +
- " <xsl:template match=\"@*|node()\">\n" +
- " Hello world\n" +
- " </xsl:template>\n" +
- "</xsl:stylesheet>");
+ File file = writeFile("stylesheet", """
+ <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:template match="@*|node()">
+ Hello world
+ </xsl:template>
+ </xsl:stylesheet>""");
ReportConfiguration config =
generateConfig(ImmutablePair.of(option, null));
Reporter reporter = new Reporter(config);
diff --git a/apache-rat-core/src/test/java/org/apache/rat/ReporterTest.java
b/apache-rat-core/src/test/java/org/apache/rat/ReporterTest.java
index 3de3e23e..3c2a9a72 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/ReporterTest.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/ReporterTest.java
@@ -501,21 +501,16 @@ public class ReporterTest {
.isTrue();
}
- private static class LicenseInfo {
- final String id;
- final String family;
- final boolean approval;
- final boolean hasNotes;
-
- LicenseInfo(String id, boolean approval, boolean hasNotes) {
- this(id, id, approval, hasNotes);
- }
+ private record LicenseInfo(String id, String family, boolean approval,
boolean hasNotes) {
+ LicenseInfo(String id, boolean approval, boolean hasNotes) {
+ this(id, id, approval, hasNotes);
+ }
- LicenseInfo(String id, String family, boolean approval, boolean
hasNotes) {
- this.id = id;
- this.family = ILicenseFamily.makeCategory(family);
- this.approval = approval;
- this.hasNotes = hasNotes;
+ private LicenseInfo(String id, String family, boolean approval,
boolean hasNotes) {
+ this.id = id;
+ this.family = ILicenseFamily.makeCategory(family);
+ this.approval = approval;
+ this.hasNotes = hasNotes;
+ }
}
- }
}
diff --git
a/apache-rat-core/src/test/java/org/apache/rat/analysis/HeaderCheckWorkerTest.java
b/apache-rat-core/src/test/java/org/apache/rat/analysis/HeaderCheckWorkerTest.java
index d776f0ab..b00aec08 100644
---
a/apache-rat-core/src/test/java/org/apache/rat/analysis/HeaderCheckWorkerTest.java
+++
b/apache-rat-core/src/test/java/org/apache/rat/analysis/HeaderCheckWorkerTest.java
@@ -22,7 +22,7 @@ package org.apache.rat.analysis;
import java.io.StringReader;
import java.util.Collections;
-import java.util.stream.Collectors;
+
import org.apache.rat.Defaults;
import org.apache.rat.api.Document;
import org.apache.rat.configuration.builders.AnyBuilder;
@@ -46,7 +46,7 @@ public class HeaderCheckWorkerTest {
HeaderCheckWorker worker = new HeaderCheckWorker(new TestingMatcher(),
new StringReader(""), Lists.list(matcher), subject);
worker.read();
assertThat(subject.getMetaData().unapprovedLicenses().count()).isEqualTo(1);
-
assertThat(subject.getMetaData().unapprovedLicenses().collect(Collectors.toList()).get(0).getLicenseFamily()).isEqualTo(ILicenseFamily.UNKNOWN);
+
assertThat(subject.getMetaData().unapprovedLicenses().toList().get(0).getLicenseFamily()).isEqualTo(ILicenseFamily.UNKNOWN);
}
@Test
diff --git
a/apache-rat-core/src/test/java/org/apache/rat/analysis/license/ApacheSoftwareLicenseTest.java
b/apache-rat-core/src/test/java/org/apache/rat/analysis/license/ApacheSoftwareLicenseTest.java
index da090788..956514c2 100644
---
a/apache-rat-core/src/test/java/org/apache/rat/analysis/license/ApacheSoftwareLicenseTest.java
+++
b/apache-rat-core/src/test/java/org/apache/rat/analysis/license/ApacheSoftwareLicenseTest.java
@@ -42,25 +42,39 @@ public class ApacheSoftwareLicenseTest extends
AbstractLicenseTest {
{ "txt", "http://www.apache.org/licenses/LICENSE-2.0.txt" },
{ "txts", "https://www.apache.org/licenses/LICENSE-2.0.txt" },
{ "fullTxt",
- "Licensed under the Apache License, Version 2.0 (the
\"License\")\nyou may not use this file except "
- + "in compliance with the License.\nYou may obtain
a copy of the License at\n"
- +
"http://www.apache.org/licenses/LICENSE-2.0\nUnless required by applicable "
- + "law or agreed to in writing,
software\ndistributed under the License is "
- + "distributed on an \"AS IS\" BASIS,\nWITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either "
- + "express or implied.\nSee the License for the
specific language governing permissions and\n"
- + "limitations under the License.\n" },
+ """
+Licensed under the Apache License, Version 2.0 (the "License")
+you may not use this file except \
+in compliance with the License.
+You may obtain a copy of the License at
+http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable \
+law or agreed to in writing, software
+distributed under the License is \
+distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either \
+express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""},
{ "spdx-tab", "SPDX-License-Identifier:\tApache-2.0" },
{ "spdx-space", "SPDX-License-Identifier: Apache-2.0" },
{ "long text",
- "/*\n" + " * Licensed under the Apache License, Version
2.0 (the \"License\");\n"
- + " * you may not use this file except in
compliance with the License.\n" + " *\n"
- + " * You may obtain a copy of the License at\n"
- + " *
http://www.apache.org/licenses/LICENSE-2.0\n" + " *\n"
- + " * Unless required by applicable law or agreed
to in writing, software\n"
- + " * distributed under the License is
distributed on an \"AS IS\" BASIS,\n"
- + " * WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.\n"
- + " * See the License for the specific language
governing permissions and\n"
- + " * limitations under the License.\n" + " */\n"
}
+ """
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+"""}
};
diff --git
a/apache-rat-core/src/test/java/org/apache/rat/analysis/license/GPLLicenseTest.java
b/apache-rat-core/src/test/java/org/apache/rat/analysis/license/GPLLicenseTest.java
index b4d43576..1de16081 100644
---
a/apache-rat-core/src/test/java/org/apache/rat/analysis/license/GPLLicenseTest.java
+++
b/apache-rat-core/src/test/java/org/apache/rat/analysis/license/GPLLicenseTest.java
@@ -32,30 +32,36 @@ public class GPLLicenseTest extends AbstractLicenseTest {
private static final Arguments GPL1 = Arguments.of("GPL1", "GPL", "GNU
General Public License, version 1", null,
new String[][] {
{ "fulltext",
- "This program is free software; you can
redistribute it and/or modify\n "
- + "it under the terms of the GNU General
Public License as published by\n "
- + "the Free Software Foundation; either
version 1, or (at your option)\n "
- + "any later version." },
+ """
+This program is free software; you can redistribute it and/or modify
+ \
+it under the terms of the GNU General Public License as published by
+ \
+the Free Software Foundation; either version 1, or (at your option)
+ \
+any later version."""},
{ "spdx-tab", "SPDX-License-Identifier:\tGPL-1.0-only" },
{ "spdx-space", "SPDX-License-Identifier: GPL-1.0-only" },
});
private static final Arguments GPL2 = Arguments.of("GPL2", "GPL", "GNU
General Public License, version 2", null,
new String[][] {
{ "fulltext",
- "This program is free software; you can
redistribute it and/or\n"
- + "modify it under the terms of the GNU
General Public License\n"
- + "as published by the Free Software
Foundation; either version 2\n"
- + "of the License, or (at your option) any
later version." },
+ """
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version."""},
{ "spdx-tab", "SPDX-License-Identifier:\tGPL-2.0-only" },
{ "spdx-space", "SPDX-License-Identifier: GPL-2.0-only" },
});
private static final Arguments GPL3 = Arguments.of("GPL3", "GPL", "GNU
General Public License, version 3", null,
new String[][] {
{ "fulltext",
- "This program is free software: you can
redistribute it and/or modify\n"
- + " it under the terms of the GNU
General Public License as published by\n"
- + " the Free Software Foundation,
either version 3 of the License, or\n"
- + " (at your option) any later
version." },
+ """
+This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version."""},
{ "spdx-tab", "SPDX-License-Identifier:\tGPL-3.0-only" },
{ "spdx-space", "SPDX-License-Identifier: GPL-3.0-only" },
});
diff --git
a/apache-rat-core/src/test/java/org/apache/rat/analysis/license/W3CLicenseTest.java
b/apache-rat-core/src/test/java/org/apache/rat/analysis/license/W3CLicenseTest.java
index b185103e..09571e32 100644
---
a/apache-rat-core/src/test/java/org/apache/rat/analysis/license/W3CLicenseTest.java
+++
b/apache-rat-core/src/test/java/org/apache/rat/analysis/license/W3CLicenseTest.java
@@ -24,8 +24,10 @@ import org.junit.jupiter.params.provider.Arguments;
public class W3CLicenseTest extends AbstractLicenseTest {
- private static final String W3C_note = "Note that W3C requires a
NOTICE.\n" + "All modifications require notes.\n"
- + "See
http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231.";
+ private static final String W3C_note = """
+ Note that W3C requires a NOTICE.
+ All modifications require notes.
+ See
http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231.""";
private static final Arguments W3C = Arguments.of("W3C", "W3C", "W3C
Software Copyright", W3C_note,
new String[][] { { "fulltext",
"http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231" },
{ "spdx-tab", "SPDX-License-Identifier:\tW3C" },
diff --git
a/apache-rat-core/src/test/java/org/apache/rat/config/results/ClaimValidatorTest.java
b/apache-rat-core/src/test/java/org/apache/rat/config/results/ClaimValidatorTest.java
index cc2108c5..41ecaffd 100644
---
a/apache-rat-core/src/test/java/org/apache/rat/config/results/ClaimValidatorTest.java
+++
b/apache-rat-core/src/test/java/org/apache/rat/config/results/ClaimValidatorTest.java
@@ -147,7 +147,7 @@ public class ClaimValidatorTest {
@Test
public void listIssuesTest() {
ClaimStatistic statistic = new ClaimStatistic();
- List<String> required =
getRequiredCounters().stream().map(ClaimStatistic.Counter::name).collect(Collectors.toList());
+ List<String> required =
getRequiredCounters().stream().map(ClaimStatistic.Counter::name).toList();
int value = 5;
for (ClaimStatistic.Counter counter : ClaimStatistic.Counter.values())
{
diff --git
a/apache-rat-core/src/test/java/org/apache/rat/configuration/XMLConfigurationReaderTest.java
b/apache-rat-core/src/test/java/org/apache/rat/configuration/XMLConfigurationReaderTest.java
index 9176361f..a7863273 100644
---
a/apache-rat-core/src/test/java/org/apache/rat/configuration/XMLConfigurationReaderTest.java
+++
b/apache-rat-core/src/test/java/org/apache/rat/configuration/XMLConfigurationReaderTest.java
@@ -28,7 +28,6 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Collection;
-import java.util.stream.Collectors;
import org.apache.rat.analysis.IHeaderMatcher;
import org.apache.rat.config.parameters.ComponentType;
@@ -74,9 +73,7 @@ public class XMLConfigurationReaderTest {
URL url =
XMLConfigurationReaderTest.class.getResource("/org/apache/rat/default.xml");
reader.read(url.toURI());
- Collection<String> readCategories =
reader.readLicenses().stream().map(IHeaderMatcher::getId)
- .collect(Collectors.toList());
- assertArrayEquals(EXPECTED_LICENSES, readCategories.toArray(new
String[0]));
+ assertArrayEquals(EXPECTED_LICENSES,
reader.readLicenses().stream().map(IHeaderMatcher::getId).toArray(String[]::new));
}
@Test
@@ -85,9 +82,7 @@ public class XMLConfigurationReaderTest {
URL url =
XMLConfigurationReaderTest.class.getResource("/org/apache/rat/default.xml");
reader.read(url.toURI());
- Collection<String> readCategories =
reader.readFamilies().stream().map(x -> x.getFamilyCategory().trim())
- .collect(Collectors.toList());
- assertArrayEquals(EXPECTED_IDS, readCategories.toArray(new
String[readCategories.size()]));
+ assertArrayEquals(EXPECTED_IDS, reader.readFamilies().stream().map(x
-> x.getFamilyCategory().trim()).toArray(String[]::new));
}
private void checkMatcher(String name, Class<? extends AbstractBuilder>
clazz) {
diff --git
a/apache-rat-core/src/test/java/org/apache/rat/testhelpers/TestingLog.java
b/apache-rat-core/src/test/java/org/apache/rat/testhelpers/TestingLog.java
index 549e5225..171cacac 100644
--- a/apache-rat-core/src/test/java/org/apache/rat/testhelpers/TestingLog.java
+++ b/apache-rat-core/src/test/java/org/apache/rat/testhelpers/TestingLog.java
@@ -99,6 +99,6 @@ public class TestingLog implements Log {
* @return {@code true} if the log is empty.
*/
public boolean isEmpty() {
- return captured.length() == 0;
+ return captured.isEmpty();
}
}
diff --git
a/apache-rat-core/src/test/java/org/apache/rat/walker/DirectoryWalkerTest.java
b/apache-rat-core/src/test/java/org/apache/rat/walker/DirectoryWalkerTest.java
index b1e5f151..32a8360f 100644
---
a/apache-rat-core/src/test/java/org/apache/rat/walker/DirectoryWalkerTest.java
+++
b/apache-rat-core/src/test/java/org/apache/rat/walker/DirectoryWalkerTest.java
@@ -134,7 +134,7 @@ public class DirectoryWalkerTest {
assertThat(actual).as(()-> String.format("Missing %s",
ex)).contains(ex);
}
- List<Document> excluded =
scanned.stream().filter(Document::isIgnored).collect(Collectors.toList());
+ List<Document> excluded =
scanned.stream().filter(Document::isIgnored).toList();
assertThat(excluded.size()).isEqualTo(1);
Document d = excluded.get(0);
assertThat(d.getName().localized("/")).isEqualTo("/.hidden");
diff --git a/apache-rat-plugin/pom.xml b/apache-rat-plugin/pom.xml
index 883103ba..e10aa8e0 100644
--- a/apache-rat-plugin/pom.xml
+++ b/apache-rat-plugin/pom.xml
@@ -445,7 +445,7 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
- <version>3.5.1</version>
+ <version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
diff --git a/apache-rat-plugin/spotbugs-ignore.xml
b/apache-rat-plugin/spotbugs-ignore.xml
index db1af674..2957d104 100644
--- a/apache-rat-plugin/spotbugs-ignore.xml
+++ b/apache-rat-plugin/spotbugs-ignore.xml
@@ -19,8 +19,8 @@
<Match>
<!--
Convenience constructors that allow setting a charset are not available in
Java8 for FileReader.
- -->
<Class
name="org.apache.rat.config.exclusion.fileProcessors.GlobIgnoreMatcher"/>
<Bug pattern="DM_DEFAULT_ENCODING"/>
+ -->
</Match>
</FindBugsFilter>
diff --git
a/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java
b/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java
index 63b98aa5..7bd6b1da 100644
--- a/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java
+++ b/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java
@@ -235,7 +235,9 @@ public class RatCheckMojo extends AbstractRatMojo {
try {
ByteArrayOutputStream baos = new
ByteArrayOutputStream();
reporter.output(StyleSheets.UNAPPROVED_LICENSES.getStyleSheet(), () -> baos);
-
getLog().warn(baos.toString(StandardCharsets.UTF_8.name()));
+ getLog().warn(baos.toString(StandardCharsets.UTF_8));
+ } catch (RuntimeException rte) {
+ throw rte;
} catch (Exception e) {
getLog().warn("Unable to print the files with
unapproved licenses to the console.");
}
diff --git a/apache-rat-plugin/src/main/java/org/apache/rat/mp/Regex.java
b/apache-rat-plugin/src/main/java/org/apache/rat/mp/Regex.java
index 8cd7b84d..ded13f7a 100644
--- a/apache-rat-plugin/src/main/java/org/apache/rat/mp/Regex.java
+++ b/apache-rat-plugin/src/main/java/org/apache/rat/mp/Regex.java
@@ -30,12 +30,12 @@ public class Regex extends RegexBuilder {
@Named("expr")
public RegexBuilder setExpression(String expression) {
- System.out.format("Calling setText() with %s\n", expression);
+ System.out.format("Calling setText() with %s%n", expression);
return super.setExpression(expression);
}
- public void set(String exp) {
- System.out.format("Calling set() with %s\n", exp);
- setExpression(exp);
+ public void set(String expression) {
+ System.out.format("Calling set() with %s%n", expression);
+ setExpression(expression);
}
}
diff --git a/apache-rat-tasks/run-antunit.xml b/apache-rat-tasks/run-antunit.xml
index c81fbf61..77ffb9fe 100644
--- a/apache-rat-tasks/run-antunit.xml
+++ b/apache-rat-tasks/run-antunit.xml
@@ -31,11 +31,11 @@
<pathelement location="../apache-rat-api/target/classes"/>
<pathelement location="target/test-classes"/>
<pathelement
location="${user.home}/.m2/repository/org/apache/ant/ant-antunit/1.4.1/ant-antunit-1.4.1.jar"/>
- <pathelement
location="${user.home}/.m2/repository/org/apache/commons/commons-lang3/3.12.0/commons-lang3-3.12.0.jar"/>
- <pathelement
location="${user.home}/.m2/repository/commons-cli/commons-cli/1.5.0/commons-cli-1.3.1.jar"/>
- <pathelement
location="${user.home}/.m2/repository/org/apache/commons/commons-collections4/4.4/commons-collections4-4.4.jar"/>
- <pathelement
location="${user.home}/.m2/repository/commons-io/commons-io/2.11.0/commons-io-2.11.0.jar"/>
- <pathelement
location="${user.home}/.m2/repository/commons-beanutils/commons-beanutils/1.9.4/commons-beanutils-1.9.4.jar"/>
+ <pathelement
location="${user.home}/.m2/repository/org/apache/commons/commons-lang3/3.20.0/commons-lang3-3.20.0.jar"/>
+ <pathelement
location="${user.home}/.m2/repository/commons-cli/commons-cli/1.8.0/commons-cli-1.8.0.jar"/>
+ <pathelement
location="${user.home}/.m2/repository/org/apache/commons/commons-collections4/4.5.0/commons-collections4-4.5.0.jar"/>
+ <pathelement
location="${user.home}/.m2/repository/commons-io/commons-io/2.21.0/commons-io-2.21.0.jar"/>
+ <pathelement
location="${user.home}/.m2/repository/commons-beanutils/commons-beanutils/1.11.0/commons-beanutils-1.11.0.jar"/>
</path>
<property name="test.classpath" refid="test-classpath"/>
diff --git a/apache-rat-tasks/spotbugs-ignore.xml
b/apache-rat-tasks/spotbugs-ignore.xml
index 971c02aa..e8c3e32c 100644
--- a/apache-rat-tasks/spotbugs-ignore.xml
+++ b/apache-rat-tasks/spotbugs-ignore.xml
@@ -19,8 +19,8 @@
<Match>
<!--
Convenience constructors that allow setting a charset are not available in
Java8 for PrintStream.
- -->
<Class name="org.apache.rat.anttasks.Report"/>
<Bug pattern="DM_DEFAULT_ENCODING"/>
+ -->
</Match>
</FindBugsFilter>
diff --git a/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Help.java
b/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Help.java
index 3b46cba1..7c6256a1 100644
--- a/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Help.java
+++ b/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Help.java
@@ -168,7 +168,6 @@ public class Help extends BaseAntTask {
@Override
protected StringBuffer renderOptions(final StringBuffer sb, final int
width, final Options options, final int leftPad, final int descPad) {
- final String lpad = createPadding(leftPad);
final String dpad = createPadding(descPad);
// first create list containing only <lpad>-a,--aaa where
// -a is opt and --aaa is long opt; in parallel look for
diff --git a/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java
b/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java
index add845ff..1dd3414a 100644
--- a/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java
+++ b/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java
@@ -26,7 +26,6 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import java.util.stream.Collectors;
import org.apache.commons.cli.Option;
import org.apache.commons.io.filefilter.IOFileFilter;
@@ -98,7 +97,7 @@ public class Report extends BaseAntTask {
*/
private IOFileFilter inputFileFilter;
/**
- * the set of approved licence categories
+ * the set of approved license categories
*/
private final Set<String> approvedLicenseCategories = new HashSet<>();
/**
@@ -325,7 +324,7 @@ public class Report extends BaseAntTask {
}
/**
- * Sets the copyright message
+ * Sets the copyright message.
*
* @param copyrightMessage the copyright message
* @deprecated use copyright attribute
@@ -359,7 +358,7 @@ public class Report extends BaseAntTask {
}
/**
- * Adds definition information
+ * Adds definition information.
*
* @param fileName the file to add
* @deprecated Use Config child element
@@ -454,7 +453,7 @@ public class Report extends BaseAntTask {
}
/**
- * validates the task's configuration.
+ * Validates the task's configuration.
*/
protected ReportConfiguration validate(final ReportConfiguration cfg) {
try {
@@ -523,7 +522,7 @@ public class Report extends BaseAntTask {
@Override
public String[] getValues() {
return
Arrays.stream(LicenseSetFactory.LicenseFilter.values()).map(LicenseSetFactory.LicenseFilter::name)
- .collect(Collectors.toList()).toArray(new
String[LicenseSetFactory.LicenseFilter.values().length]);
+ .toList().toArray(new
String[LicenseSetFactory.LicenseFilter.values().length]);
}
public LicenseSetFactory.LicenseFilter internalFilter() {
@@ -555,19 +554,13 @@ public class Report extends BaseAntTask {
* @return the equivalent RAT log level.
*/
public static Log.Level fromProjectLevel(final int level) {
- switch (level) {
- case Project.MSG_DEBUG:
- case Project.MSG_VERBOSE:
- return Log.Level.DEBUG;
- case Project.MSG_INFO:
- return Log.Level.INFO;
- case Project.MSG_WARN:
- return Log.Level.WARN;
- case Project.MSG_ERR:
- return Log.Level.ERROR;
- default:
- return Log.Level.OFF;
- }
+ return switch (level) {
+ case Project.MSG_DEBUG, Project.MSG_VERBOSE -> Log.Level.DEBUG;
+ case Project.MSG_INFO -> Log.Level.INFO;
+ case Project.MSG_WARN -> Log.Level.WARN;
+ case Project.MSG_ERR -> Log.Level.ERROR;
+ default -> Log.Level.OFF;
+ };
}
/**
@@ -576,19 +569,13 @@ public class Report extends BaseAntTask {
* @return the equivalent Ant Project log level.
*/
static int toProjectLevel(final Log.Level level) {
- switch (level) {
- case DEBUG:
- return Project.MSG_DEBUG;
- case INFO:
- return Project.MSG_INFO;
- case WARN:
- return Project.MSG_WARN;
- case ERROR:
- return Project.MSG_ERR;
- case OFF:
- default:
- return -1;
- }
+ return switch (level) {
+ case DEBUG -> Project.MSG_DEBUG;
+ case INFO -> Project.MSG_INFO;
+ case WARN -> Project.MSG_WARN;
+ case ERROR -> Project.MSG_ERR;
+ default -> -1;
+ };
}
/**
diff --git a/apache-rat-tasks/src/templates/apt/index.apt.vm.vm
b/apache-rat-tasks/src/templates/apt/index.apt.vm.vm
index 8d68ecce..5b00a242 100644
--- a/apache-rat-tasks/src/templates/apt/index.apt.vm.vm
+++ b/apache-rat-tasks/src/templates/apt/index.apt.vm.vm
@@ -53,10 +53,7 @@ Apache RAT Ant Task Library
works well with 1.8.x), Apache RAT core and transitively all
dependencies of Apache RAT core.
- In order to use the tasks Java 5 is required as of RAT 0.9 - RAT 0.8
- and earlier require Java 1.4.
-
- Java 8 is required for RAT 0.14 and above.
+ Java 17 is required for RAT 0.18 and above.
* Installation
diff --git
a/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/GeneratedReportTest.java
b/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/GeneratedReportTest.java
index 17286aec..ca86ee4e 100644
---
a/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/GeneratedReportTest.java
+++
b/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/GeneratedReportTest.java
@@ -29,7 +29,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.lang3.StringUtils;
import org.apache.rat.OptionCollection;
@@ -115,22 +114,25 @@ public class GeneratedReportTest {
* The prefix for the ant build.xml file.
*/
private static final String BUILD_XML_PREFIX =
- "<project default=\"all\"\n" +
- " xmlns:au=\"antlib:org.apache.ant.antunit\"\n" +
- " xmlns:rat=\"antlib:org.apache.rat.anttasks\">\n" +
- "\n" +
- " <taskdef uri=\"antlib:org.apache.ant.antunit\"\n" +
- " \tresource=\"org/apache/ant/antunit/antlib.xml\"\n" +
- " \tclasspath=\"${test.classpath}\" />\n" +
- "\n" +
- " <taskdef uri=\"antlib:org.apache.rat.anttasks\"\n" +
- " \tresource=\"org/apache/rat/anttasks/antlib.xml\"\n" +
- " \tclasspath=\"${test.classpath}\" />\n" +
- "\n" +
- " <property name=\"File\" value='test.file' />\n" +
- " <property name=\"Integer\" value=\"5\" />\n" +
- " <property name=\"String\" value=\"hello\" />\n" +
- " <property name=\"ConfigFile\" location=\"configData.xml\"
/>\n\n";
+ """
+ <project default="all"
+ xmlns:au="antlib:org.apache.ant.antunit"
+ xmlns:rat="antlib:org.apache.rat.anttasks">
+
+ <taskdef uri="antlib:org.apache.ant.antunit"
+ \tresource="org/apache/ant/antunit/antlib.xml"
+ \tclasspath="${test.classpath}" />
+
+ <taskdef uri="antlib:org.apache.rat.anttasks"
+ \tresource="org/apache/rat/anttasks/antlib.xml"
+ \tclasspath="${test.classpath}" />
+
+ <property name="File" value='test.file' />
+ <property name="Integer" value="5" />
+ <property name="String" value="hello" />
+ <property name="ConfigFile" location="configData.xml" />
+
+ """;
private static File writeFile(String name, String contents) throws
IOException {
final File testFile = new File(tempDir.toFile(), name);
@@ -230,7 +232,7 @@ public class GeneratedReportTest {
List<AntOption> options = Arg.getOptions().getOptions().stream()
.filter(o ->
!AntOption.getFilteredOptions().contains(o)).map(AntOption::new)
- .collect(Collectors.toList());
+ .toList();
List<Arguments> lst = new ArrayList<>();
@@ -304,109 +306,85 @@ public class GeneratedReportTest {
}
private static String getData(String name) {
try {
- switch (name) {
- case "copyright":
- case "editCopyright":
- return "My Copyright info";
- case "config":
+ return switch (name) {
+ case "copyright", "editCopyright" -> "My Copyright info";
+ case "config" -> {
writeFile("configData.xml", "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n<rat-config/>");
- return "${ConfigFile}";
- case "licenses":
- return writeFile("licensesData.xml", "<?xml
version=\"1.0\" encoding=\"UTF-8\"?>\n<rat-config/>").getName();
- case "licenseFamiliesApprovedFile":
- return writeFile("licenseFamiliesApprovedFile.txt",
getData("licenseFamiliesApproved")).getName();
- case "licenseFamiliesDeniedFile":
- return writeFile("licenseFamiliesDeniedFile.txt",
getData("licenseFamiliesDenied")).getName();
- case "licensesApproved":
- case "licenseFamiliesApproved":
- case "licenseFamiliesDenied":
- case "licensesDenied":
- return "AL, CC";
- case "licensesApprovedFile":
- return writeFile("licensesApprovedFile.txt",
getData("licensesApproved")).getName();
- case "licensesDeniedFile":
- return writeFile("licensesDeniedFile.txt",
getData("licensesDenied")).getName();
- case "configurationNoDefaults":
- writeFile("noDefaultsConfig.xml", "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n" +
- "<rat-config>\n" +
- "\t<families>\n" +
- "\t\t<family id=\"DUMMY\" name=\"A Dummy license\"
/>\n" +
- "\t</families>\n" +
- "\t<licenses>\n" +
- "\t\t<license family=\"DUMMY\">\n" +
- "\t\t\t<text>Any old text</text>\n" +
- "\t\t</license>\n" +
- "\t</licenses>\n" +
- "\t<approved>\n" +
- "\t\t<family license_ref='DUMMY' />\n" +
- "\t</approved>\n" +
- "\t<matchers>\n" +
- "\t\t<matcher
class=\"org.apache.rat.configuration.builders.AllBuilder\" />\n" +
- "\t\t<matcher
class=\"org.apache.rat.configuration.builders.AnyBuilder\" />\n" +
- "\t\t<matcher
class=\"org.apache.rat.configuration.builders.CopyrightBuilder\" />\n" +
- "\t\t<matcher
class=\"org.apache.rat.configuration.builders.MatcherRefBuilder\" />\n" +
- "\t\t<matcher
class=\"org.apache.rat.configuration.builders.NotBuilder\" />\n" +
- "\t\t<matcher
class=\"org.apache.rat.configuration.builders.RegexBuilder\" />\n" +
- "\t\t<matcher
class=\"org.apache.rat.configuration.builders.SpdxBuilder\" />\n" +
- "\t\t<matcher
class=\"org.apache.rat.configuration.builders.TextBuilder\" />\n" +
- "\t</matchers>\n" +
- "</rat-config>\n");
- return "true";
- case "noDefaultLicenses":
- writeFile("noDefaultLicensesConfig.xml", "<?xml
version=\"1.0\" encoding=\"UTF-8\"?>\n" +
- "<rat-config>\n" +
- "\t<families>\n" +
- "\t\t<family id=\"DUMMY\" name=\"A Dummy license\"
/>\n" +
- "\t</families>\n" +
- "\t<licenses>\n" +
- "\t\t<license family=\"DUMMY\">\n" +
- "\t\t\t<text>Any old text</text>\n" +
- "\t\t</license>\n" +
- "\t</licenses>\n" +
- "</rat-config>\n");
- return "true";
- case "out":
- case "outputFile":
- return tempDir.resolve(name + ".txt").toString();
- case "xml":
- return "true";
- case "stylesheet":
- case "outputStyle":
- return StyleSheets.PLAIN.arg();
- case "inputInclude":
- case "inputExclude":
- case "exclude":
- case "include":
- return "a/**file/stuff";
- case "excludeFile" :
- return writeFile("excludeFile.txt",
getData("exclude")).getAbsolutePath();
- case "includesFile" :
- return writeFile("includeFile.txt",
getData("include")).getAbsolutePath();
- case "inputIncludeFile" :
- return writeFile("inputIncludeFile.txt",
getData("inputInclude")).getName();
- case "inputExcludeFile" :
- return writeFile("inputExcludeFile.txt",
getData("inputExclude")).getName();
- case "inputExcludeSize":
- return "500";
- case "inputIncludeStd":
- case "inputExcludeStd":
- return "GIT";
- case "counterMin":
- case "counterMax":
- return "BINARIES:3";
- case "inputExcludeParsedScm":
- return "IDEA";
- case "outputLicenses":
- case "outputFamilies":
- case "listLicenses":
- case "listFamilies":
- return LicenseSetFactory.LicenseFilter.ALL.name();
- case "outputArchive":
- case "outputStandard":
- return ReportConfiguration.Processing.ABSENCE.name();
- default:
- return null;
- }
+ yield "${ConfigFile}";
+ }
+ case "licenses" ->
+ writeFile("licensesData.xml", "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n<rat-config/>").getName();
+ case "licenseFamiliesApprovedFile" ->
+ writeFile("licenseFamiliesApprovedFile.txt",
getData("licenseFamiliesApproved")).getName();
+ case "licenseFamiliesDeniedFile" ->
+ writeFile("licenseFamiliesDeniedFile.txt",
getData("licenseFamiliesDenied")).getName();
+ case "licensesApproved", "licenseFamiliesApproved",
"licenseFamiliesDenied", "licensesDenied" ->
+ "AL, CC";
+ case "licensesApprovedFile" ->
+ writeFile("licensesApprovedFile.txt",
getData("licensesApproved")).getName();
+ case "licensesDeniedFile" ->
writeFile("licensesDeniedFile.txt", getData("licensesDenied")).getName();
+ case "configurationNoDefaults" -> {
+ writeFile("noDefaultsConfig.xml", """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <rat-config>
+ \t<families>
+ \t\t<family id="DUMMY" name="A Dummy license" />
+ \t</families>
+ \t<licenses>
+ \t\t<license family="DUMMY">
+ \t\t\t<text>Any old text</text>
+ \t\t</license>
+ \t</licenses>
+ \t<approved>
+ \t\t<family license_ref='DUMMY' />
+ \t</approved>
+ \t<matchers>
+ \t\t<matcher
class="org.apache.rat.configuration.builders.AllBuilder" />
+ \t\t<matcher
class="org.apache.rat.configuration.builders.AnyBuilder" />
+ \t\t<matcher
class="org.apache.rat.configuration.builders.CopyrightBuilder" />
+ \t\t<matcher
class="org.apache.rat.configuration.builders.MatcherRefBuilder" />
+ \t\t<matcher
class="org.apache.rat.configuration.builders.NotBuilder" />
+ \t\t<matcher
class="org.apache.rat.configuration.builders.RegexBuilder" />
+ \t\t<matcher
class="org.apache.rat.configuration.builders.SpdxBuilder" />
+ \t\t<matcher
class="org.apache.rat.configuration.builders.TextBuilder" />
+ \t</matchers>
+ </rat-config>
+ """);
+ yield "true";
+ }
+ case "noDefaultLicenses" -> {
+ writeFile("noDefaultLicensesConfig.xml", """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <rat-config>
+ \t<families>
+ \t\t<family id="DUMMY" name="A Dummy license" />
+ \t</families>
+ \t<licenses>
+ \t\t<license family="DUMMY">
+ \t\t\t<text>Any old text</text>
+ \t\t</license>
+ \t</licenses>
+ </rat-config>
+ """);
+ yield "true";
+ }
+ case "out", "outputFile" -> tempDir.resolve(name +
".txt").toString();
+ case "xml" -> "true";
+ case "stylesheet", "outputStyle" -> StyleSheets.PLAIN.arg();
+ case "inputInclude", "inputExclude", "exclude", "include" ->
"a/**file/stuff";
+ case "excludeFile" -> writeFile("excludeFile.txt",
getData("exclude")).getAbsolutePath();
+ case "includesFile" -> writeFile("includeFile.txt",
getData("include")).getAbsolutePath();
+ case "inputIncludeFile" -> writeFile("inputIncludeFile.txt",
getData("inputInclude")).getName();
+ case "inputExcludeFile" -> writeFile("inputExcludeFile.txt",
getData("inputExclude")).getName();
+ case "inputExcludeSize" -> "500";
+ case "inputIncludeStd", "inputExcludeStd" -> "GIT";
+ case "counterMin", "counterMax" -> "BINARIES:3";
+ case "inputExcludeParsedScm" -> "IDEA";
+ case "outputLicenses", "outputFamilies", "listLicenses",
"listFamilies" ->
+ LicenseSetFactory.LicenseFilter.ALL.name();
+ case "outputArchive", "outputStandard" ->
ReportConfiguration.Processing.ABSENCE.name();
+ default -> null;
+ };
} catch (IOException e) {
throw new RuntimeException(e);
}
diff --git
a/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/ReportOptionTest.java
b/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/ReportOptionTest.java
index fcebbfea..c7c91612 100644
---
a/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/ReportOptionTest.java
+++
b/apache-rat-tasks/src/test/java/org/apache/rat/anttasks/ReportOptionTest.java
@@ -209,31 +209,32 @@ public class ReportOptionTest {
$3 = file name to read
$4 = classname
*/
- final static String ANT_FILE = "<?xml version='1.0'?>\n" +
- "\n" +
- "<project\n" +
- "\txmlns:au=\"antlib:org.apache.ant.antunit\"\n" +
- "\txmlns:rat=\"antlib:org.apache.rat.anttasks\">\n" +
- "\n" +
- "\t<taskdef uri=\"antlib:org.apache.ant.antunit\"\n" +
- "\t\tresource=\"org/apache/rat/anttasks/antlib.xml\"\n" +
- "\t\tclasspath=\"${test.classpath}\" />\n" +
- "\n" +
- "\t<taskdef uri=\"antlib:org.apache.rat.anttasks\"\n" +
- "\t\tresource=\"org/apache/rat/anttasks/antlib.xml\"\n" +
- "\t\tclasspath=\"${test.classpath}\" />\n" +
- "\n" +
- "\t<taskdef \n" +
- "\t\tname=\"optionTest\"\n" +
- "\t\tclassname=\"%5$s\"\n" +
- "\t\tclasspath=\"${test.classpath}\" />\n" +
- "\n" +
- "\t<target name=\"%1$s\">\n" +
- "\t\t<optionTest %2$s>\n" +
- "%3$s" +
- "\t\t\t<file file=\"%4$s\" />\n" +
- "\t\t</optionTest>\n" +
- "\t</target>\n" +
- "\n" +
- "</project>";
+ final static String ANT_FILE = """
+ <?xml version='1.0'?>
+
+ <project
+ \txmlns:au="antlib:org.apache.ant.antunit"
+ \txmlns:rat="antlib:org.apache.rat.anttasks">
+
+ \t<taskdef uri="antlib:org.apache.ant.antunit"
+ \t\tresource="org/apache/rat/anttasks/antlib.xml"
+ \t\tclasspath="${test.classpath}" />
+
+ \t<taskdef uri="antlib:org.apache.rat.anttasks"
+ \t\tresource="org/apache/rat/anttasks/antlib.xml"
+ \t\tclasspath="${test.classpath}" />
+
+ \t<taskdef\s
+ \t\tname="optionTest"
+ \t\tclassname="%5$s"
+ \t\tclasspath="${test.classpath}" />
+
+ \t<target name="%1$s">
+ \t\t<optionTest %2$s>
+ %3$s\
+ \t\t\t<file file="%4$s" />
+ \t\t</optionTest>
+ \t</target>
+
+ </project>""";
}
diff --git a/apache-rat-tools/spotbugs-ignore.xml
b/apache-rat-tools/spotbugs-ignore.xml
index 878aaf80..2d4d66ea 100644
--- a/apache-rat-tools/spotbugs-ignore.xml
+++ b/apache-rat-tools/spotbugs-ignore.xml
@@ -19,7 +19,7 @@
<Match>
<!--
Convenience constructors that allow setting a charset are not
available in Java8 for PrintStream.
- -->
<Bug pattern="DM_DEFAULT_ENCODING"/>
+ -->
</Match>
</FindBugsFilter>
diff --git
a/apache-rat-tools/src/main/java/org/apache/rat/documentation/Exporter.java
b/apache-rat-tools/src/main/java/org/apache/rat/documentation/Exporter.java
index be3fe056..af51e30f 100644
--- a/apache-rat-tools/src/main/java/org/apache/rat/documentation/Exporter.java
+++ b/apache-rat-tools/src/main/java/org/apache/rat/documentation/Exporter.java
@@ -22,7 +22,6 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
@@ -67,16 +66,10 @@ public class Exporter {
* </ol>
*
* @param args the arguments
- * @throws IOException on IO error.
- * @throws ClassNotFoundException if the configuration is not found.
- * @throws NoSuchMethodException if the method name is not found.
- * @throws InvocationTargetException if the method can not be invoked.
- * @throws InstantiationException if the class can not be instantiated.
- * @throws IllegalAccessException if there are access restrictions on the
class.
* @throws RatException on RAT processing error.
*/
- public static void main(final String[] args) throws IOException,
ClassNotFoundException, NoSuchMethodException,
- InvocationTargetException, InstantiationException,
IllegalAccessException, RatException {
+ public static void main(final String[] args) throws
+ RatException {
String templateDir = args[0];
String outputDir = args[1];
@@ -163,39 +156,35 @@ public class Exporter {
/**
* A RatReport implementation that processes the {@code .vm} files in the
template tree and writes the
* results to the output tree.
+ *
+ * @param targetDir The base directory we are targeting for output
*/
- private static class Cleaner implements RatReport {
- /**
- * The base directory we are targeting for output
- */
- private final DocumentName targetDir;
-
+ private record Cleaner(DocumentName targetDir) implements RatReport {
/**
* Create a rewriter.
*
* @param targetDir the root of the output directory tree.
*/
- Cleaner(final DocumentName targetDir) {
- this.targetDir = targetDir;
+ private Cleaner {
}
- /**
- * Processes the input document and creates an output document at an
equivalent place in the output tree.
- *
- * @param document the input document.
- */
- @Override
- public void report(final Document document) {
- String localized = document.getName().localized();
- DocumentName outputFile = targetDir.resolve(localized.substring(0,
localized.length() - 3));
- try {
- final File file = outputFile.asFile();
- if (file.exists()) {
- Files.delete(file.toPath());
+ /**
+ * Processes the input document and creates an output document at
an equivalent place in the output tree.
+ *
+ * @param document the input document.
+ */
+ @Override
+ public void report(final Document document) {
+ String localized = document.getName().localized();
+ DocumentName outputFile =
targetDir.resolve(localized.substring(0, localized.length() - 3));
+ try {
+ final File file = outputFile.asFile();
+ if (file.exists()) {
+ Files.delete(file.toPath());
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
}
- } catch (IOException e) {
- throw new RuntimeException(e);
}
}
- }
}
diff --git
a/apache-rat-tools/src/main/java/org/apache/rat/documentation/options/AntOption.java
b/apache-rat-tools/src/main/java/org/apache/rat/documentation/options/AntOption.java
index 4ddc1e9b..7cbfa16c 100644
---
a/apache-rat-tools/src/main/java/org/apache/rat/documentation/options/AntOption.java
+++
b/apache-rat-tools/src/main/java/org/apache/rat/documentation/options/AntOption.java
@@ -150,7 +150,7 @@ public class AntOption extends AbstractOption {
default:
buildType = new BuildType(type, type.getDisplayName()) {
protected String getMethodFormat(final AntOption
antOption) {
- return String.format("<%1$s>%%s</%1$s>\n",
WordUtils.uncapitalize(antOption.getArgName()));
+ return String.format("<%1$s>%%s</%1$s>%n",
WordUtils.uncapitalize(antOption.getArgName()));
}
};
BUILD_TYPE_MAP.put(type, buildType);
@@ -348,7 +348,7 @@ public class AntOption extends AbstractOption {
* @return the format used for multiple arguments.
*/
protected String getMultipleFormat(final AntOption antOption) {
- return String.format("<%1$s>%%s</%1$s>\n", tag);
+ return String.format("<%1$s>%%s</%1$s>%n", tag);
}
/**
@@ -357,7 +357,7 @@ public class AntOption extends AbstractOption {
* @return the method format for the option.
*/
protected String getMethodFormat(final AntOption antOption) {
- return antOption.hasArgs() ? getMultipleFormat(antOption) :
String.format("<%1$s>%%s</%1$s>\n", tag);
+ return antOption.hasArgs() ? getMultipleFormat(antOption) :
String.format("<%1$s>%%s</%1$s>%n", tag);
}
/**
diff --git
a/apache-rat-tools/src/main/java/org/apache/rat/documentation/velocity/Matcher.java
b/apache-rat-tools/src/main/java/org/apache/rat/documentation/velocity/Matcher.java
index 55f36e34..cab7c000 100644
---
a/apache-rat-tools/src/main/java/org/apache/rat/documentation/velocity/Matcher.java
+++
b/apache-rat-tools/src/main/java/org/apache/rat/documentation/velocity/Matcher.java
@@ -138,8 +138,7 @@ public class Matcher {
*/
Collection<Matcher> getChildren() {
if (self != null && enclosed != null &&
IHeaderMatcher.class.equals(enclosed.desc.getChildType())) {
- if (self instanceof AbstractMatcherContainer) {
- AbstractMatcherContainer matcherContainer =
(AbstractMatcherContainer) self;
+ if (self instanceof AbstractMatcherContainer matcherContainer) {
return
matcherContainer.getEnclosed().stream().map(Matcher::new).collect(Collectors.toList());
}
try {
diff --git
a/apache-rat-tools/src/main/java/org/apache/rat/tools/AntGenerator.java
b/apache-rat-tools/src/main/java/org/apache/rat/tools/AntGenerator.java
index e40e9520..c9bb7aaf 100644
--- a/apache-rat-tools/src/main/java/org/apache/rat/tools/AntGenerator.java
+++ b/apache-rat-tools/src/main/java/org/apache/rat/tools/AntGenerator.java
@@ -66,13 +66,15 @@ public final class AntGenerator {
case DIRORARCHIVE:
generateType = new GenerateType("fileset") {
protected String getMethodFormat(final AntOption
antOption) {
- return " public void
addConfiguredFileset(FileSet fileSet) {\n" +
- " for (Resource resource :
fileSet) {\n" +
- " if
(resource.isFilesystemOnly()) {\n" +
- " addArg(%1$s,
((FileResource) resource).getFile().getAbsolutePath());\n" +
- " }\n" +
- " }\n" +
- " }\n\n";
+ return """
+ public void
addConfiguredFileset(FileSet fileSet) {
+ for (Resource resource :
fileSet) {
+ if
(resource.isFilesystemOnly()) {
+ addArg(%1$s,
((FileResource) resource).getFile().getAbsolutePath());
+ }
+ }
+ }
+ """;
}
};
break;
@@ -110,7 +112,6 @@ public final class AntGenerator {
private AntGenerator() { }
-
/**
* Gets the key for the Args array.
* @param option the option to get the key for.
@@ -147,9 +148,9 @@ public final class AntGenerator {
File file = new File(new File(new File(destDir), pkgName), className +
".java");
file.getParentFile().mkdirs();
try (InputStream template =
AntGenerator.class.getResourceAsStream("/Ant.tpl");
- FileWriter writer = new FileWriter(file);
+ FileWriter writer = new FileWriter(file, StandardCharsets.UTF_8);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- OutputStreamWriter customClasses = new OutputStreamWriter(bos)) {
+ OutputStreamWriter customClasses = new OutputStreamWriter(bos,
StandardCharsets.UTF_8);) {
if (template == null) {
throw new RuntimeException("Template /Ant.tpl not found");
}
@@ -178,9 +179,10 @@ public final class AntGenerator {
writer.append(format("package %s;%n", packageName));
break;
case "${constructor}":
- writer.append(format(" protected %s() {\n" +
- " setDeprecationReporter();\n" +
- " }%n", className));
+ writer.append(format("""
+ protected %s() {
+ setDeprecationReporter();
+ }%n""", className));
break;
case "${class}":
writer.append(format("public abstract class %s extends
Task {%n", className));
@@ -229,8 +231,9 @@ public final class AntGenerator {
private static String getElementClass(final AntOption option) {
String elementConstructor =
- " public class %1$s {\n" +
- " %1$s() { }\n\n";
+ """
+ public class %1$s {
+ %1$s() { }%n""";
String funcName = WordUtils.capitalize(option.getName());
StringBuilder result = new StringBuilder(format(elementConstructor,
funcName));
@@ -252,9 +255,10 @@ public final class AntGenerator {
}
protected String getMethodFormat(final AntOption antOption) {
- return String.format(" public void addConfigured%1$s(%1$s
%%2$s) {\n" +
- " addArg(%%1$s, %%2$s.value);\n" +
- " }\n\n", innerClass);
+ return String.format("""
+ public void addConfigured%1$s(%1$s %%2$s) {
+ addArg(%%1$s, %%2$s.value);
+ }%n""", innerClass);
}
public String getPattern(final AntOption delegateOption, final
AntOption antOption) {
diff --git
a/apache-rat-tools/src/main/java/org/apache/rat/tools/ArgumentTypes.java
b/apache-rat-tools/src/main/java/org/apache/rat/tools/ArgumentTypes.java
index 21d6aa31..3ca4e414 100644
--- a/apache-rat-tools/src/main/java/org/apache/rat/tools/ArgumentTypes.java
+++ b/apache-rat-tools/src/main/java/org/apache/rat/tools/ArgumentTypes.java
@@ -22,6 +22,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
+import java.nio.charset.StandardCharsets;
import org.apache.rat.help.Help;
@@ -41,7 +42,7 @@ public final class ArgumentTypes {
private ArgumentTypes() { }
public static void main(final String[] args) throws IOException {
- try (Writer writer = args.length > 0 ? new FileWriter(args[0]) : new
OutputStreamWriter(System.out)) {
+ try (Writer writer = args.length > 0 ? new FileWriter(args[0],
StandardCharsets.UTF_8) : new OutputStreamWriter(System.out,
StandardCharsets.UTF_8)) {
new Help(writer).printArgumentTypes();
}
}
diff --git
a/apache-rat-tools/src/main/java/org/apache/rat/tools/MavenGenerator.java
b/apache-rat-tools/src/main/java/org/apache/rat/tools/MavenGenerator.java
index 20c5a58b..7c2aea91 100644
--- a/apache-rat-tools/src/main/java/org/apache/rat/tools/MavenGenerator.java
+++ b/apache-rat-tools/src/main/java/org/apache/rat/tools/MavenGenerator.java
@@ -80,7 +80,7 @@ public final class MavenGenerator {
System.out.println("Creating " + file);
file.getParentFile().mkdirs();
try (InputStream template =
MavenGenerator.class.getResourceAsStream("/Maven.tpl");
- FileWriter writer = new FileWriter(file)) {
+ FileWriter writer = new FileWriter(file, StandardCharsets.UTF_8))
{
if (template == null) {
throw new RuntimeException("Template /Maven.tpl not found");
}
@@ -109,9 +109,10 @@ public final class MavenGenerator {
writer.append(format("package %s;%n", packageName));
break;
case "${constructor}":
- writer.append(format(" protected %s() {\n" +
- " setDeprecationReporter();\n" +
- " }%n", className));
+ writer.append(format("""
+ protected %s() {
+ setDeprecationReporter();
+ }%n""", className));
break;
case "${class}":
writer.append(format("public abstract class %s extends
AbstractMojo {%n", className));
diff --git a/apache-rat-tools/src/main/java/org/apache/rat/tools/Naming.java
b/apache-rat-tools/src/main/java/org/apache/rat/tools/Naming.java
index 498883a6..d7c94a05 100644
--- a/apache-rat-tools/src/main/java/org/apache/rat/tools/Naming.java
+++ b/apache-rat-tools/src/main/java/org/apache/rat/tools/Naming.java
@@ -156,7 +156,8 @@ public final class Naming {
};
}
- try (Writer underWriter = cl.getArgs().length != 0 ? new
FileWriter(cl.getArgs()[0]) : new OutputStreamWriter(System.out,
StandardCharsets.UTF_8)) {
+ try (Writer underWriter = cl.getArgs().length != 0 ?
+ new FileWriter(cl.getArgs()[0], StandardCharsets.UTF_8) : new
OutputStreamWriter(System.out, StandardCharsets.UTF_8)) {
if (cl.hasOption(CSV)) {
printCSV(columns, filter, cl.hasOption(CLI), showMaven,
showAnt, descriptionFunction, underWriter);
}
diff --git
a/apache-rat-tools/src/main/java/org/apache/rat/tools/xsd/XsdGenerator.java
b/apache-rat-tools/src/main/java/org/apache/rat/tools/xsd/XsdGenerator.java
index f1369e63..6d1529da 100644
--- a/apache-rat-tools/src/main/java/org/apache/rat/tools/xsd/XsdGenerator.java
+++ b/apache-rat-tools/src/main/java/org/apache/rat/tools/xsd/XsdGenerator.java
@@ -93,7 +93,7 @@ public class XsdGenerator {
*/
public InputStream getInputStream() throws IOException {
try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
- Writer writer = new OutputStreamWriter(baos)) {
+ Writer writer = new OutputStreamWriter(baos,
StandardCharsets.UTF_8)) {
write(writer);
return new ByteArrayInputStream(baos.toByteArray());
}
diff --git a/apache-rat-tools/src/main/resources/Ant.tpl
b/apache-rat-tools/src/main/resources/Ant.tpl
index 407bc164..952f4551 100644
--- a/apache-rat-tools/src/main/resources/Ant.tpl
+++ b/apache-rat-tools/src/main/resources/Ant.tpl
@@ -42,7 +42,6 @@ import java.util.Objects;
import java.util.stream.Collectors;
/**
* Generated class to provide Ant support for standard RAT command line
options.
- *
* DO NOT EDIT - GENERATED FILE
*/
${class}
diff --git a/apache-rat-tools/src/main/resources/Args.tpl
b/apache-rat-tools/src/main/resources/Args.tpl
index c30422d5..0d8e537f 100644
--- a/apache-rat-tools/src/main/resources/Args.tpl
+++ b/apache-rat-tools/src/main/resources/Args.tpl
@@ -31,7 +31,7 @@
List<String> result = new ArrayList<>();
for (Map.Entry<String, List<String>> entry : args.entrySet()) {
result.add("--" + entry.getKey());
-
result.addAll(entry.getValue().stream().filter(Objects::nonNull).collect(Collectors.toList()));
+
result.addAll(entry.getValue().stream().filter(Objects::nonNull).toList());
}
return result;
}
@@ -95,7 +95,7 @@
* @param value the array of values to set.
*/
protected void addArg(String key, String[] value) {
- List<String> newValues =
Arrays.stream(value).filter(StringUtils::isNotBlank).collect(Collectors.toList());
+ List<String> newValues =
Arrays.stream(value).filter(StringUtils::isNotBlank).toList();
if (!newValues.isEmpty()) {
if (validateSet(key)) {
if (DefaultLog.getInstance().isEnabled(Log.Level.DEBUG)) {
diff --git a/apache-rat-tools/src/main/resources/Maven.tpl
b/apache-rat-tools/src/main/resources/Maven.tpl
index 13d9453e..c1bc2c19 100644
--- a/apache-rat-tools/src/main/resources/Maven.tpl
+++ b/apache-rat-tools/src/main/resources/Maven.tpl
@@ -38,10 +38,9 @@ import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
-/* DO NOT EDIT - GENERATED FILE */
-
/**
* Generated class to provide Maven support for standard RAT command line
options
+ * DO NOT EDIT - GENERATED FILE
*/
${class}
diff --git a/apache-rat/spotbugs-ignore.xml b/apache-rat/spotbugs-ignore.xml
index fc94fe36..085293a2 100644
--- a/apache-rat/spotbugs-ignore.xml
+++ b/apache-rat/spotbugs-ignore.xml
@@ -16,22 +16,6 @@
limitations under the License.
-->
<FindBugsFilter>
- <Match>
- <!--
- Convenience constructors that allow setting a charset are not available in
Java8 for PrintStream.
- -->
- <Class name="org.apache.rat.Report"/>
- <Bug pattern="DM_DEFAULT_ENCODING"/>
- </Match>
-
- <Match>
- <!--
- Convenience constructors that allow setting a charset are not available in
Java8 for PrintStream.
- -->
- <Class name="org.apache.rat.annotation.AbstractLicenseAppender"/>
- <Bug pattern="DM_DEFAULT_ENCODING"/>
- </Match>
-
<Match>
<Bug pattern='PATH_TRAVERSAL_IN'/>
</Match>
diff --git a/apache-rat/src/site/apt/known_issues.apt
b/apache-rat/src/site/apt/known_issues.apt
index acb4fe56..eb2681f1 100644
--- a/apache-rat/src/site/apt/known_issues.apt
+++ b/apache-rat/src/site/apt/known_issues.apt
@@ -23,8 +23,10 @@ Known issues
This page collects any known issues with Apache RAT™. As it is
developed as an open source project, you are free to help, comment or provide
insights about the known issues.
- * {{{https://issues.apache.org/jira/browse/RAT-476}RAT-476}}: RAT's
include/exclude precedence rules do not match gitignore semantics
+ * {{{https://issues.apache.org/jira/browse/RAT-476}RAT-476}}: RAT's
include/exclude precedence rules do not match gitignore semantics.
- * {{{https://issues.apache.org/jira/browse/RAT-97}RAT-97}}: Maven plugin
parameter <<<excludeSubProjects>>> does not work properly if deeper than one
hierarchy level
+ * {{{https://issues.apache.org/jira/browse/RAT-97}RAT-97}}: Maven plugin
parameter <<<excludeSubProjects>>> does not work properly if deeper than one
hierarchy level.
+
+ * {{{https://issues.apache.org/jira/browse/RAT-497}RAT-497}}: Due to a
JDK-error during Javadoc generation we cannot build RAT completely with JDK17
and recommend using JDK21 instead.
Feel free to have a look into our project's
{{{https://issues.apache.org/jira/browse/RAT}Jira}} to find other reported
{{{https://issues.apache.org/jira/issues/?jql=project%20%3D%20%22Apache%20Rat%22%20%20and%20issuetype%20%3D%20Bug%20and%20status%20not%20in%20(resolved%2C%20closed)}bugs}}
or open issues.
\ No newline at end of file
diff --git a/apache-rat/src/site/markdown/migration_guide.md
b/apache-rat/src/site/markdown/migration_guide.md
index e13f0c68..57b4ad9d 100644
--- a/apache-rat/src/site/markdown/migration_guide.md
+++ b/apache-rat/src/site/markdown/migration_guide.md
@@ -23,4 +23,3 @@ The subpages listed here help you to make the most out of the
corresponding vers
* [0.17](./migrationguide/0.17.html)
* [0.18](./migrationguide/0.18.html)
-* [1.0.0](./migrationguide/1.0.0.html)
\ No newline at end of file
diff --git a/apache-rat/src/site/markdown/migrationguide/0.18.md
b/apache-rat/src/site/markdown/migrationguide/0.18.md
index 3705e3e6..57a40499 100644
--- a/apache-rat/src/site/markdown/migrationguide/0.18.md
+++ b/apache-rat/src/site/markdown/migrationguide/0.18.md
@@ -18,6 +18,12 @@
# Creadur RAT Migration Guide - Release 0.18
Release 0.18 is an intermediate release as we are working on big architectural
changes within the 1.0.0 feature development.
+In order to use release 0.18 you need to run with at least Java 17 as we
finally dropped the Java 8 support in this release.
+
+## General
+
+* [RAT-478](https://issues.apache.org/jira/browse/RAT-478) raised the Java
language level to 17! We recommend running with Java 21, due to an existing
problem in the JDK to generate RAT's Javadoc (tracked via
[RAT-497](https://issues.apache.org/jira/browse/RAT-497)).
+* [RAT-478](https://issues.apache.org/jira/browse/RAT-478) introduced the
possibility to allow setting default charsets when processing files. We use
```UTF-8``` to read configuration and exclusion definition files instead of the
system encoding in pre-0.18 releases.
## Maven
diff --git a/pom.xml b/pom.xml
index 14e0ebf6..b1c01a55 100644
--- a/pom.xml
+++ b/pom.xml
@@ -48,9 +48,10 @@ agnostic home for software distribution comprehension and
audit tools.
<!-- MSITE-1018, RAT-397: nil out timestamp in order to get current build
timestamp -->
<project.build.outputTimestamp>a</project.build.outputTimestamp>
<ant.version>1.10.15</ant.version>
- <mockito.version>4.11.0</mockito.version>
- <javaVersion>1.8</javaVersion>
- <tika.version>2.9.4</tika.version>
+ <assertj.version>4.0.0-M1</assertj.version>
+ <javaVersion>17</javaVersion>
+ <tika.version>3.2.3</tika.version>
+ <mockito.version>5.21.0</mockito.version>
<maven.compiler.source>${javaVersion}</maven.compiler.source>
<maven.compiler.target>${javaVersion}</maven.compiler.target>
<!-- This is the version of Maven required to use the RAT Maven Plugin -->
@@ -155,18 +156,26 @@ agnostic home for software distribution comprehension and
audit tools.
<artifactId>commons-csv</artifactId>
<version>1.14.1</version>
</dependency>
+ <dependency>
+ <groupId>org.assertj</groupId>
+ <artifactId>assertj-bom</artifactId>
+ <version>${assertj.version}</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
- <version>5.13.4</version>
+ <version>6.1.0-M1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
- <artifactId>mockito-core</artifactId>
+ <artifactId>mockito-bom</artifactId>
<version>${mockito.version}</version>
- <scope>test</scope>
+ <type>pom</type>
+ <scope>import</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
@@ -213,7 +222,7 @@ agnostic home for software distribution comprehension and
audit tools.
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
- <version>3.27.6</version>
+ <version>${assertj.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -239,6 +248,7 @@ agnostic home for software distribution comprehension and
audit tools.
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
+ <!-- TODO RAT-527: migrate to newer version under ASF umbrella: 5.x
including itests in RAT's core -->
<version>2.4.21</version>
<scope>test</scope>
</dependency>
@@ -466,8 +476,8 @@ agnostic home for software distribution comprehension and
audit tools.
Note that this cannot use our ${javaVersion} property, so it
must
be changed manually when we decide to move to a higher version
of
Java
- -->
- <id>check-java-1.8-compat</id>
+ RAT-478: Opened
https://github.com/mojohaus/animal-sniffer/issues/316 to ask how to proceed here
+ <id>check-java-17-compat</id>
<phase>process-classes</phase>
<goals>
<goal>check</goal>
@@ -479,6 +489,7 @@ agnostic home for software distribution comprehension and
audit tools.
<version>1.0</version>
</signature>
</configuration>
+ -->
</execution>
</executions>
</plugin>
@@ -490,10 +501,9 @@ agnostic home for software distribution comprehension and
audit tools.
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
- <version>4.8.6.6</version>
+ <version>4.9.8.2</version>
<configuration>
- <!-- RAT-369: JDK21 finds 98 errors, while older releases find
fewer -->
- <maxAllowedViolations>98</maxAllowedViolations>
+ <maxAllowedViolations>46</maxAllowedViolations>
<failOnError>true</failOnError>
<!-- we only want to see our own problems in all subpackages -->
<onlyAnalyze>org.apache.rat.-</onlyAnalyze>
@@ -531,6 +541,11 @@ agnostic home for software distribution comprehension and
audit tools.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.1</version>
+ <configuration>
+ <release>${javaVersion}</release>
+ <source>${javaVersion}</source>
+ <target>${javaVersion}</target>
+ </configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -663,7 +678,7 @@ agnostic home for software distribution comprehension and
audit tools.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
- <version>3.6.2</version>
+ <version>3.6.3</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
@@ -1000,7 +1015,7 @@ agnostic home for software distribution comprehension and
audit tools.
be changed manually when we decide to move to a higher version of
Java
-->
- <maven.compiler.release>8</maven.compiler.release>
+ <maven.compiler.release>17</maven.compiler.release>
</properties>
</profile>
<profile>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 6d93ce2e..e8ed0a06 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -68,6 +68,30 @@ in order to be properly linked in site reports.
</release>
-->
<release version="1.0.0" date="xxxx-yy-zz" description="Current SNAPSHOT -
release to be done">
+ <action issue="RAT-478" type="add" dev="pottlinger">
+ Due to the switch to Java17 language level we use UTF-8 as default
charset to process configuration and exclusion configuration files within RAT.
+ </action>
+ <action issue="RAT-498" type="update" dev="pottlinger">
+ Update assertj from 3.27.6 to 4.0.0-M1 and use bom for dependency
management.
+ </action>
+ <action issue="RAT-498" type="update" dev="pottlinger">
+ Update plexus-utils from 3.5.1 to 3.6.0.
+ </action>
+ <action issue="RAT-498" type="update" dev="pottlinger">
+ Update exec-maven-plugin from 3.6.1 to 3.6.3.
+ </action>
+ <action issue="RAT-498" type="update" dev="pottlinger">
+ Update junit from 5.13.4 to 6.1.0-M1.
+ </action>
+ <action issue="RAT-498" type="update" dev="pottlinger">
+ Update mockito from 4.11.0 to 5.21.0 and use bom for dependency
management.
+ </action>
+ <action issue="RAT-478" type="add" dev="pottlinger">
+ Switch to Java17 language level in Creadur RAT. Due to RAT-497 we
cannot generate Javadocs/the site with JDK17, thus use JDK21 to build the
project.
+ </action>
+ <action issue="RAT-498" type="update" dev="pottlinger">
+ Update tika from 2.9.4 to 3.2.3 due to CVE-2025-66516.
+ </action>
<action issue="RAT-512" type="fix" dev="pottlinger" due-to="Niels
Basjes">
Bugfix to mark PDF files as binary instead of standard files as they
do not contain licenses.
</action>
diff --git a/src/changes/release-notes.vm b/src/changes/release-notes.vm
index 0989f97c..fc3ac84e 100644
--- a/src/changes/release-notes.vm
+++ b/src/changes/release-notes.vm
@@ -126,9 +126,11 @@ Historical list of changes:
https://creadur.apache.org/rat/changes.html
Known issues: https://creadur.apache.org/rat/apache-rat/known_issues.html
+Migration guide: https://creadur.apache.org/rat/apache-rat/migration-guide.html
+
=WEBPAGE=
For complete information on Apache Creadur RAT, including instructions on how
to submit bug reports,
-patches, or suggestions for improvement, see the Apache Apache Creadur RAT
website:
+patches, or suggestions for improvement, see the Apache Creadur RAT website:
https://creadur.apache.org/rat/
diff --git a/src/conf/checkstyle-suppressions.xml
b/src/conf/checkstyle-suppressions.xml
index 7bfacfc2..8c654e16 100644
--- a/src/conf/checkstyle-suppressions.xml
+++ b/src/conf/checkstyle-suppressions.xml
@@ -32,12 +32,12 @@
files="src[/\\]main[/\\]java[/\\]org[/\\]apache[/\\]rat[/\\]mp[/\\]All.java" />
<suppress checks="[a-zA-Z0-9]*"
files="src[/\\]main[/\\]java[/\\]org[/\\]apache[/\\]rat[/\\]mp[/\\]Any.java" />
- <!-- most all plugin java files not starting with A or R -->
+ <!-- most plugin java files not starting with A or R -->
<suppress checks="[a-zA-Z0-9]*"
files="src[/\\]main[/\\]java[/\\]org[/\\]apache[/\\]rat[/\\]mp[/\\]([B-Q]|[S-Z]).*.java"
/>
<suppress checks="[a-zA-Z0-9]*"
files="src[/\\]main[/\\]java[/\\]org[/\\]apache[/\\]rat[/\\]mp[/\\]Regex.java"
/>
- <!-- most all task java files not starting with R -->
+ <!-- most task java files not starting with R -->
<suppress checks="[a-zA-Z0-9]*"
files="src[/\\]main[/\\]java[/\\]org[/\\]apache[/\\]rat[/\\]anttasks[/\\]([A-Q]|[S-Z]).*.java"
/>
<suppress checks="[a-zA-Z0-9]*"
diff --git a/src/conf/spotbugs-exclude.xml b/src/conf/spotbugs-exclude.xml
index aaabf3c7..5ce630df 100644
--- a/src/conf/spotbugs-exclude.xml
+++ b/src/conf/spotbugs-exclude.xml
@@ -16,22 +16,6 @@
limitations under the License.
-->
<FindBugsFilter>
- <Match>
- <!--
- Convenience constructors that allow setting a charset are not
available in Java8 for PrintStream.
- -->
- <Class name="org.apache.rat.Report"/>
- <Bug pattern="DM_DEFAULT_ENCODING"/>
- </Match>
-
- <Match>
- <!--
- Convenience constructors that allow setting a charset are not
available in Java8 for PrintStream.
- -->
- <Class name="org.apache.rat.annotation.AbstractLicenseAppender"/>
- <Bug pattern="DM_DEFAULT_ENCODING"/>
- </Match>
-
<Match>
<Bug pattern='PATH_TRAVERSAL_IN'/>
</Match>
diff --git a/src/site/apt/index.apt.vm b/src/site/apt/index.apt.vm
index 553170ef..e76fc7f7 100644
--- a/src/site/apt/index.apt.vm
+++ b/src/site/apt/index.apt.vm
@@ -128,6 +128,8 @@ git clone
https://gitbox.apache.org/repos/asf/creadur-rat.git
Build RAT with {{{https://maven.apache.org/}Apache Maven}} preferably version
${mavenVersion} or later.
+ RAT requires Java 17, but due to an existing JDK-error
({{{https://issues.apache.org/jira/browse/RAT-497}RAT-497}}) Javadoc cannot be
generated with Java 17, use Java 21 instead.
+
There are two methods for building the RAT suite:
+------------------------------------------+
@@ -150,6 +152,6 @@ cd creadur-rat
2. Execute the maven install noted above. This will place the current jars in
your local repository.
- 3. Run "mvn package" and use the resulting jar in the apache-rat sub-module
for testing.
+ 3. Run "mvn package" and use the resulting jar in the apache-rat submodule
for testing.
- If you modify code in one sub-module you need to run "mvn install" in that
module to get it into your repository so that you can use it in later
repository builds. Alternatively, you can run "mvn package", or "mvn install"
on the entire project.
+ If you modify code in one submodule you need to run "mvn install" in that
module to get it into your repository so that you can use it in later
repository builds. Alternatively, you can run "mvn package", or "mvn install"
on the entire project.