Scenario: App needs dependency A.jar.

A.jar has a ProGuard obfuscation stage that generates a mapping file (A-mapping.txt).

App is getting obfuscation as well.

How do I pass A-mapping.txt to the app in its build process? I'd need something like a shared directory between all the dependencies where I put all my mapping files.

I want to include A-mapping.txt in app ProGuard configuration file with: -applymapping A-mapping.txt

Would this be possible with Maven?

1

There are 1 best solutions below

0
Cédric On

I would use the unpack goal of the maven-dependency plugin .

Its documentation is here: https://maven.apache.org/plugins/maven-dependency-plugin/unpack-mojo.html

For your case it should look like:

       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-dependency-plugin</artifactId>
         <version>3.6.1</version>
         <executions>
           <execution>
             <id>unpack</id>
             <phase>process-resources</phase> <!-- change to best relevant phase -->
             <goals>
               <goal>unpack</goal>
             </goals>
             <configuration>
               <artifactItems>
                 <artifactItem>
                   <groupId><!-- 'A' groupId--></groupId>
                   <artifactId>A</artifactId>
                   <version><!-- 'A' version--></version>
                   <type>jar</type>
                   <includes>/dir/inside/jar/to/A-mapping.txt</includes>
                 </artifactItem>
                 <!-- you may extract some more artifacts here -->
               </artifactItems>
               <outputDirectory>${project.build.directory}/your/mappings</outputDirectory>
             </configuration>
           </execution>
         </executions>
       </plugin>

You will have your mapping file extracted in ${project.build.directory}/your/mappings so you can use them to build your final application in a subsequent maven phase.