You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/04/14 18:41:22 UTC

[GitHub] [maven-war-plugin] michael-o commented on a diff in pull request #22: [MWAR-450] ISO-8859-1 properties files get changed into UTF-8 when fi…

michael-o commented on code in PR #22:
URL: https://github.com/apache/maven-war-plugin/pull/22#discussion_r850709295


##########
src/main/java/org/apache/maven/plugins/war/packaging/AbstractWarPackagingTask.java:
##########
@@ -257,8 +258,16 @@ protected boolean copyFilteredFile( String sourceId, final WarPackagingContext c
                 }
                 else
                 {
-                    // For all others we use the configured encoding
-                    encoding = context.getResourceEncoding();
+                    // Fix for MWAR-450
+                    if ( isPropertiesFile( file ) && StringUtils.isNotEmpty( context.getPropertiesEncoding() ) )

Review Comment:
   Why not put it in an `else if`? This looks like unnecessary nesting...



##########
src/main/java/org/apache/maven/plugins/war/packaging/AbstractWarPackagingTask.java:
##########
@@ -257,8 +258,16 @@ protected boolean copyFilteredFile( String sourceId, final WarPackagingContext c
                 }
                 else
                 {
-                    // For all others we use the configured encoding
-                    encoding = context.getResourceEncoding();
+                    // Fix for MWAR-450

Review Comment:
   This line is redundant, we have `git blame`



##########
src/main/java/org/apache/maven/plugins/war/packaging/AbstractWarPackagingTask.java:
##########
@@ -477,6 +486,18 @@ protected String getArtifactFinalName( WarPackagingContext context, Artifact art
 
     }
 
+    /**
+     * Determine whether a file is a properties file or not.
+     *
+     * @param file The file to check
+     * @return <code>true</code> if the file is a properties file, otherwise <code>false</code>
+     * @since 3.4.0
+     */
+    private boolean isPropertiesFile( File file )
+    {
+        return file != null && file.isFile() && file.getName().endsWith( ".properties" );

Review Comment:
   This now bacially duplicates `isXmlFile(File)`. Why refactor to a single method and pass two args to that new method?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org