[ 
https://issues.apache.org/jira/browse/MSHARED-1330?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17821210#comment-17821210
 ] 

ASF GitHub Bot commented on MSHARED-1330:
-----------------------------------------

elharo commented on code in PR #97:
URL: https://github.com/apache/maven-filtering/pull/97#discussion_r1504163149


##########
src/main/java/org/apache/maven/shared/filtering/FilteringUtils.java:
##########
@@ -371,6 +375,23 @@ private static void copyFilePermissions(File source, File 
destination) throws IO
         }
     }
 
+    @SuppressWarnings("ResultOfMethodCallIgnored")
+    private static void setAllPermissions(File file) throws IOException {
+        if (file.exists()) {
+            try {
+                Files.setPosixFilePermissions(
+                        file.toPath(),
+                        EnumSet.of(
+                                PosixFilePermission.OWNER_READ, 
PosixFilePermission.OWNER_WRITE,
+                                PosixFilePermission.GROUP_READ, 
PosixFilePermission.GROUP_WRITE,
+                                PosixFilePermission.OTHERS_READ, 
PosixFilePermission.OTHERS_WRITE));

Review Comment:
   I think the copied file is now world readable and writable when everything 
completes. That might leave arbitrary world writable files sitting around in 
the file system, which feels risky. Can this work without world or even group 
permissions? And/or can the file be set back to owner only after the copy 
finishes?
   
   



##########
src/main/java/org/apache/maven/shared/filtering/FilteringUtils.java:
##########
@@ -371,6 +375,23 @@ private static void copyFilePermissions(File source, File 
destination) throws IO
         }
     }
 
+    @SuppressWarnings("ResultOfMethodCallIgnored")
+    private static void setAllPermissions(File file) throws IOException {

Review Comment:
   makeWriteable as it no longer sets all permissions





> Incremental builds fail on filtered read-only resources  
> ---------------------------------------------------------
>
>                 Key: MSHARED-1330
>                 URL: https://issues.apache.org/jira/browse/MSHARED-1330
>             Project: Maven Shared Components
>          Issue Type: Bug
>          Components: maven-filtering
>            Reporter: G.Vaysman
>            Assignee: Guillaume Nodet
>            Priority: Major
>             Fix For: maven-filtering-3.3.2
>
>         Attachments: create-license.zip
>
>
> Under certain SCM's, such as Perforce, files under ./src are read-only. With 
> the latest maven-resources-plugin (3.3.1) which has maven-filtering 3.3.1 as 
> a dependency, filtered resources end up as read-only in ./target. Since 
> filtered resources are always updated in target, this fails with exception 
> below. This worked in maven-resources-plugin 2.7, but seems to break, at 
> least, starting from maven-resources-plugin 3.0.0. Additionally note, that 
> deprecating certain maven-filtering methods (copyFile, etc) that take the 
> Boolean _overwrite_ has broken the maven-resource-plugin contract for the 
> resources:resources (see 
> [https://maven.apache.org/plugins/maven-resources-plugin/resources-mojo.html).]
> I am attaching a very simple project that demonstrates it. When unzipping, 
> make sure src/main/resources/license.txt is read-only. Execute mvn install 
> twice (without "clean") . It fails on both Windows and Linux.  
> Further, a kind of semi-independent issue is the following: if a module 
> contains multiple resources, some to be filtered and others not, a typical 
> Maven pattern is (abridged):
> {{   <resources>}}
> {{      <resource>}}
> {{        <filtering>true</filtering>}}
> {{        <includes> ...   </includes>}}
> {{      </resource>}}
> {{      <resource>}}
> {{        <filtering>false</filtering>}}
> {{        <excludes> ...  </excludes>}}
> {{      </resource>}}
> {{    </resources>}}
> This causes both filtered and unfiltered resources go through 
> maven-filtering, and it breaks incremental builds on unfiltered resources as 
> well.
> Error:
>  {{Caused by: java.io.FileNotFoundException: 
> D:\tmp\create-license\target\classes\license.txt (Access is denied)}}
> {{    at java.io.RandomAccessFile.open0 (Native Method)}}
> {{    at java.io.RandomAccessFile.open (RandomAccessFile.java:346)}}
> {{    at java.io.RandomAccessFile.<init> (RandomAccessFile.java:260)}}
> {{    at java.io.RandomAccessFile.<init> (RandomAccessFile.java:215)}}
> {{    at org.apache.maven.shared.filtering.FilteringUtils.copyFile 
> (FilteringUtils.java:348)}}
> {{    at org.apache.maven.shared.filtering.DefaultMavenFileFilter.copyFile 
> (DefaultMavenFileFilter.java:104)}}
> {{    at 
> org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering.filterResources
>  (DefaultMavenResourcesFiltering.java:268)}}
> {{    at org.apache.maven.plugins.resources.ResourcesMojo.execute 
> (ResourcesMojo.java:343)}}
> {{    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo 
> (DefaultBuildPluginManager.java:137)}}
> {{    at org.apache.maven.lifecycle.internal.MojoExecutor.execute 
> (MojoExecutor.java:210) }}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to