Skip to content

Commit

Permalink
Use cached default charset and update URL fragment (#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
elharo authored Feb 23, 2025
1 parent 995d8cf commit 39a28af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ public void execute() throws EnforcerRuleException {
// https://maven.apache.org/plugins/maven-resources-plugin/examples/encoding.html
String projectEncoding = project.getProperties().getProperty("project.build.sourceEncoding", null);
if (StringUtils.isBlank(projectEncoding)) {
projectEncoding = System.getProperty("file.encoding");
getLog().warn("File encoding has not been set, using platform encoding " + projectEncoding
+ ". Build is platform dependent! - https://maven.apache.org/general.html#encoding-warning");
encoding = Charset.defaultCharset();
getLog().warn(
"File encoding has not been set, using platform encoding " + encoding.displayName()
+ ". Build is platform dependent! - https://maven.apache.org/general.html#How_do_I_prevent_.E2.80.9C.5BWARNING.5D_Using_platform_encoding_.28Cp1252_actually.29_to_copy_filtered_resources.2C_i.e._build_is_platform_dependent.21.E2.80.9D");
} else {
encoding = Charset.forName(projectEncoding);
}
encoding = Charset.forName(projectEncoding);
}
super.execute();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void testFileChecksumMd5NormalizedWithMissingFileCharsetParameter() throws IOExc
rule.setNormalizeLineSeparatorTo(LineSeparator.UNIX);

rule.execute();
// name is not unique therefore compare generated charset
Assertions.assertEquals(Charset.forName(System.getProperty("file.encoding")), rule.getEncoding());
// Name is not unique. Therefore compare generated charset.
Assertions.assertEquals(Charset.defaultCharset(), rule.getEncoding());
}
}

0 comments on commit 39a28af

Please sign in to comment.