Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cached default charset and update URL fragment #360

Merged
merged 1 commit into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}