[ 
https://jira.codehaus.org/browse/MRESOURCES-186?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=354218#comment-354218
 ] 

Karl-Heinz Marbaise commented on MRESOURCES-186:
------------------------------------------------

Hm...as i wrote on the [users list i can reproduce this 
issue|http://maven.40175.n5.nabble.com/Problem-with-the-resource-plugin-v2-7-and-nonFilteredFileExtensions-tc5807863.html]
 by filtering an artifact which shouldn't be filtered. I have tested this with 
the integration tests of this plugin 
{{maven-resources-plugin/src/it/binaries-filtering}} which gives me the 
impression that it is not a regression. Can you check your build doing {{mvn -X 
generate-resources}} and look into the output of the log file for output like 
{{filtering}} and which files are being filtered....

like the following:
{code}
[DEBUG] file duke-beerjpg.img has a filtered file extension
[DEBUG] filtering 
/maven-resources-plugin/target/it/possible-bug/src/main/resources/duke-beerjpg.img
to 
/maven-plugins/maven-resources-plugin/target/it/possible-bug/target/classes/duke-beerjpg.img
{code}
In the above it shows that the {{.img}} files will be filtered which is not 
correct cause they contain bytes which are interpreted as markers for encoding 
etc. In this case i have a file duke-beerjpg.img which is filtered but should 
not being filter which is causing the failure...

I have added an example project 
https://github.com/khmarbaise/mresources/tree/master/mresources-186 where you 
can see the results and we can do further discussion to that.

If you run the project as given via {{mvn clean process-resources}} with the 
configured version of maven-resources-plugin (2.6) you will get an sucessfull 
build. But if you take a look into the target folder and compare the created 
files:

First original location:
{code}
Karl-Heinzs-MacBook-Pro:mresources-186 kama$ ls -al src/main/resources/
total 1552
drwxr-xr-x  5 kama  staff     170 Oct 11 19:37 .
drwxr-xr-x  3 kama  staff     102 Oct 11 19:37 ..
-rw-r--r--  1 kama  staff  749914 Oct 11 19:37 duke-beerjpg.img
-rw-r--r--  1 kama  staff     808 Oct 11 19:37 file.txt
-rw-r--r--  1 kama  staff   36092 Oct 11 19:37 happy_duke.gif
{code}
Now target/classes folder:
{code}
Karl-Heinzs-MacBook-Pro:mresources-186 kama$ ls -al target/classes/
total 2664
drwxr-xr-x  5 kama  staff      170 Oct 11 19:39 .
drwxr-xr-x  3 kama  staff      102 Oct 11 19:39 ..
-rw-r--r--  1 kama  staff  1321860 Oct 11 19:39 duke-beerjpg.img
-rw-r--r--  1 kama  staff      806 Oct 11 19:39 file.txt
-rw-r--r--  1 kama  staff    36092 Oct 11 19:39 happy_duke.gif
Karl-Heinzs-MacBook-Pro:mresources-186 kama$
{code}
This shows the size of the {{.img}} has changed which is simply wrong! If i try 
to use resources-plugin 2.7 which result in a failure which gives me a hint 
that this files should be configured not being filtered via:
{{code:xml}
          <configuration>
            <nonFilteredFileExtensions>
              <nonFilteredFileExtension>img</nonFilteredFileExtension>
            </nonFilteredFileExtensions>
          </configuration>
{code}
This results in a sucessfull build and the size of the .img files is the same 
as expected.
{code}
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ 
maven-resources-plugin-binaries-filtering ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 3 resources
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.928s
[INFO] Finished at: Sat Oct 11 19:45:24 CEST 2014
[INFO] Final Memory: 9M/150M
[INFO] ------------------------------------------------------------------------
Karl-Heinzs-MacBook-Pro:mresources-186 kama$ ls -al src/main/resources/
total 1552
drwxr-xr-x  5 kama  staff     170 Oct 11 19:37 .
drwxr-xr-x  3 kama  staff     102 Oct 11 19:37 ..
-rw-r--r--  1 kama  staff  749914 Oct 11 19:37 duke-beerjpg.img
-rw-r--r--  1 kama  staff     808 Oct 11 19:37 file.txt
-rw-r--r--  1 kama  staff   36092 Oct 11 19:37 happy_duke.gif
Karl-Heinzs-MacBook-Pro:mresources-186 kama$ ls -al target/classes/
total 1552
drwxr-xr-x  5 kama  staff     170 Oct 11 19:45 .
drwxr-xr-x  3 kama  staff     102 Oct 11 19:45 ..
-rw-r--r--  1 kama  staff  749914 Oct 11 19:45 duke-beerjpg.img
-rw-r--r--  1 kama  staff     806 Oct 11 19:45 file.txt
-rw-r--r--  1 kama  staff   36092 Oct 11 19:45 happy_duke.gif
{code}
May be you can add some of your examples as pull request to the example project 
so we check if it is a regression or not?

> [Regression] Resource filtering fails when encounters binary files
> ------------------------------------------------------------------
>
>                 Key: MRESOURCES-186
>                 URL: https://jira.codehaus.org/browse/MRESOURCES-186
>             Project: Maven Resources Plugin
>          Issue Type: Bug
>    Affects Versions: 2.7
>            Reporter: Karl-Heinz Marbaise
>            Priority: Critical
>             Fix For: 2.8
>
>
> Sometimes it can happen that filtering is done on files which shouldn't be 
> filtered...which results in the following:
> {code}
> [ERROR] Failed to execute goal 
> org.apache.maven.plugins:maven-resources-plugin:2.7:resources 
> (default-resources) on project OrionCommunity: Mark invalid -> [Hel
> p 1]
> org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute 
> goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources 
> (default-resources)
>  on project OrionCommunity: Mark invalid
>         at 
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:217)
>         at 
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
>         at 
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
>         at 
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
>         at 
> org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
>         at 
> org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
>         at 
> org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
>         at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
>         at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
>         at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
>         at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
>         at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>         at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>         at java.lang.reflect.Method.invoke(Method.java:597)
>         at 
> org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
>         at 
> org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
>         at 
> org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
>         at 
> org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
> Caused by: org.apache.maven.plugin.MojoExecutionException: Mark invalid
>         at 
> org.apache.maven.plugin.resources.ResourcesMojo.execute(ResourcesMojo.java:306)
>         at 
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
>         at 
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
>         ... 19 more
> Caused by: org.apache.maven.shared.filtering.MavenFilteringException: Mark 
> invalid
>         at 
> org.apache.maven.shared.filtering.DefaultMavenFileFilter.copyFile(DefaultMavenFileFilter.java:129)
>         at 
> org.apache.maven.shared.filtering.DefaultMavenResourcesFiltering.filterResources(DefaultMavenResourcesFiltering.java:264)
>         at 
> org.apache.maven.plugin.resources.ResourcesMojo.execute(ResourcesMojo.java:300)
>         ... 21 more
> Caused by: java.io.IOException: Mark invalid
>         at java.io.BufferedReader.reset(BufferedReader.java:485)
>         at 
> org.apache.maven.shared.filtering.MultiDelimiterInterpolatorFilterReaderLineEnding.read(MultiDelimiterInterpolatorFilterReaderLineEnding.java:416)
>         at 
> org.apache.maven.shared.filtering.MultiDelimiterInterpolatorFilterReaderLineEnding.read(MultiDelimiterInterpolatorFilterReaderLineEnding.java:205)
>         at java.io.Reader.read(Reader.java:123)
>         at org.apache.maven.shared.utils.io.IOUtil.copy(IOUtil.java:181)
>         at org.apache.maven.shared.utils.io.IOUtil.copy(IOUtil.java:168)
>         at 
> org.apache.maven.shared.utils.io.FileUtils.copyFile(FileUtils.java:1856)
>         at 
> org.apache.maven.shared.utils.io.FileUtils.copyFile(FileUtils.java:1804)
>         at 
> org.apache.maven.shared.filtering.DefaultMavenFileFilter.copyFile(DefaultMavenFileFilter.java:114)
> {code}
> Currently this only crashes the build. But it might be better to create an 
> appropriate error message for the user.



--
This message was sent by Atlassian JIRA
(v6.1.6#6162)

Reply via email to