Search code examples
mavenfilteringmaven-resources-plugin

Disable resource filtering for maven-remote-resources-plugin


I am trying to use the maven-remote-resources-plugin to share a number of resources across modules in a multi module maven project. Unfortunately the shared binary resources are being corrupted during bundlling, presumably by filtering.

I am confident the corruption is happening at this stage as extracting the shared-resources jar from my local repository contains broken binary files.

Is there any to switch off filtering for maven-remote-resources-plugin?

At the moment the pom in my shared resources module looks like

<build>
  <plugins>
    <plugin>
       <artifactId>maven-remote-resources-plugin</artifactId>
       <executions>
         <execution>
           <goals>
             <goal>bundle</goal>
           </goals>
         </execution>
       </executions>
       <configuration>
         <includes>
           <include>**/*</include>
         </includes>
       </configuration>
     </plugin>
  </plugins>
</build>

<dependencies>
  <dependency>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-remote-resources-plugin</artifactId>
    <version>1.3</version>
  </dependency>
</dependencies>

Solution

  • It sounds like the resources are being corrupted during bundling. Since the resource project is just a jar it executes the resources plugin as part of the default lifecycle. Try adding this to the resource project's POM.

    <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.6</version>
        <executions>
          <execution>
            <id>default-resources</id>
            <configuration>
              <nonFilteredFileExtensions>
                <nonFilteredFileExtension>exe</nonFilteredFileExtension>
                <nonFilteredFileExtension>dontFilterMeEither</nonFilteredFileExtension>
              </nonFilteredFileExtensions>
              [...]
            </configuration>
          </execution>
        </executions>
      </plugin>
    

    The docs describe which binary files are left unfiltered by default; the config above adds extensions to the list.