Accepting request 961693 from Java:packages

Fix builds in non-utf-8 locales with utf-8 encoded sources

OBS-URL: https://build.opensuse.org/request/show/961693
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/maven-javadoc-plugin?expand=0&rev=8
This commit is contained in:
Dominique Leuenberger 2022-03-14 18:35:47 +00:00 committed by Git OBS Bridge
commit c685ecc8d2
3 changed files with 63 additions and 0 deletions

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Mon Mar 14 06:23:46 UTC 2022 - Fridrich Strba <fstrba@suse.com>
- Added patch:
* stale-data-encoding.patch
+ use the same encoding when writing and getting the stale data
+ fixes build with utf-8 sources on non utf-8 platforms
-------------------------------------------------------------------
Fri Mar 11 07:05:23 UTC 2022 - Fridrich Strba <fstrba@suse.com>

View File

@ -32,6 +32,7 @@ URL: http://maven.apache.org/plugins/maven-javadoc-plugin
Source0: https://repo1.maven.org/maven2/org/apache/maven/plugins/%{base_name}/%{version}/%{base_name}-%{version}-source-release.zip
Source1: %{base_name}-build.xml
Patch0: %{base_name}-bootstrap-resources.patch
Patch1: stale-data-encoding.patch
BuildRequires: apache-commons-cli
BuildRequires: apache-commons-io
BuildRequires: apache-commons-lang3
@ -120,6 +121,7 @@ API documentation for %{name}.
cp %{SOURCE1} build.xml
%patch0 -p1
%endif
%patch1 -p1
%pom_xpath_remove pom:project/pom:parent/pom:relativePath
%pom_remove_dep :::test:

53
stale-data-encoding.patch Normal file
View File

@ -0,0 +1,53 @@
--- maven-javadoc-plugin-3.3.2/src/main/java/org/apache/maven/plugins/javadoc/StaleHelper.java 2022-02-07 20:52:42.000000000 +0100
+++ maven-javadoc-plugin-3.3.2/src/main/java/org/apache/maven/plugins/javadoc/StaleHelper.java 2022-03-14 07:46:55.466835949 +0100
@@ -43,6 +43,19 @@
public class StaleHelper
{
+ private static Charset getDataCharset()
+ {
+ if ( JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast( "9" )
+ && JavaVersion.JAVA_SPECIFICATION_VERSION.isBefore( "12" ) )
+ {
+ return StandardCharsets.UTF_8;
+ }
+ else
+ {
+ return Charset.defaultCharset();
+ }
+ }
+
/**
* Compute the data used to detect a stale javadoc
*
@@ -61,16 +74,7 @@
String[] args = cmd.getArguments();
Collections.addAll( options, args );
- final Charset cs;
- if ( JavaVersion.JAVA_SPECIFICATION_VERSION.isAtLeast( "9" )
- && JavaVersion.JAVA_SPECIFICATION_VERSION.isBefore( "12" ) )
- {
- cs = StandardCharsets.UTF_8;
- }
- else
- {
- cs = Charset.defaultCharset();
- }
+ final Charset cs = getDataCharset();
for ( String arg : args )
{
@@ -141,9 +145,11 @@
{
try
{
+ final Charset cs = getDataCharset();
+
String curdata = getStaleData( cmd );
Files.createDirectories( path.getParent() );
- Files.write( path, Collections.singleton( curdata ), Charset.defaultCharset() );
+ Files.write( path, Collections.singleton( curdata ), cs);
}
catch ( IOException e )
{