title: Configure proguard-maven-plugin to filter META-INF of a library jar
body: <p>I am trying to use ProGuard to obfuscate my Java 8 jar.  I am having trouble configuring the ProGuard plugin in my pom.xml file in order to send the configuration that I need to ProGuard.</p>
  
  <p><strong>BACKGROUND:</strong></p>
  
  <p>One of my dependencies is dependent on Log4j 2.9.1.  I have run into a well documented bug in ProGuard - <a href="https://sourceforge.net/p/proguard/bugs/665/" rel="noreferrer">https://sourceforge.net/p/proguard/bugs/665/</a>.</p>
  
  <p>It suggests as a workaround adding a filter to the log4j library to ignore the META-INF classes.</p>
  
  <pre><code>-libraryjars "log4j-api-2.9.0.jar"(!META-INF/versions/9/**.class)
  </code></pre>
  
  <p><strong>ISSUE:</strong></p>
  
  <p>I have not been able to successfully configure the maven plugin to send this configuration to ProGuard.</p>
  
  <p>(Note: The maven plugin is adding the -libraryjars configuration for log4j automatically because it is a project dependency.)</p>
  
  <p><strong>FAILED ATTEMPT #1:</strong></p>
  
  <p>I have tried adding an exclusion to prevent this library from being included automatically and a lib entry to add it with the filter.</p>
  
  <pre><code>&lt;exclusions&gt;
    &lt;exclude&gt;
      &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;
      &lt;artifactId&gt;log4j-api&lt;/artifactId&gt;
    &lt;/exclude&gt;
  &lt;/exclusions&gt;
  &lt;libs&gt;
    &lt;lib&gt;${env.LOG4J_REPOSITORY}/log4j-api-2.9.1.jar(!META-INF/versions/**.class)&lt;/lib&gt;
  &lt;/libs&gt;
  </code></pre>
  
  <p>The exclusion is successful but the lib entry fails.  It's being treated as a filename so the argument to ProGuard looks like</p>
  
  <pre><code>-libraryjars, '/mnt/juser/repository/org/apache/logging/log4j/log4j-api/2.9.1/log4j-api-2.9.1.jar(!META-INF/versions/**.class)',
  </code></pre>
  
  <p>and I am getting the error</p>
  
  <pre><code> [proguard] Error: Can't read [/mnt/juser/repository/org/apache/logging/log4j/log4j-api/2.9.1/log4j-api-2.9.1.jar(!META-INF/versions/**.class)] (No such file or directory)
  </code></pre>
  
  <p>I tried adding punctuation to the lib declaration</p>
  
  <pre><code>&lt;lib&gt;"${env.LOG4J_REPOSITORY}/log4j-api-2.9.1.jar"(!META-INF/versions/**.class)&lt;/lib&gt;
  </code></pre>
  
  <p>It created this argument for ProGuard</p>
  
  <pre><code>-libraryjars, '"/mnt/juser/repository/org/apache/logging/log4j/log4j-api/2.9.1/log4j-api-2.9.1.jar"(!META-INF/versions/**.class)',
  </code></pre>
  
  <p>and failed with the following error</p>
  
  <pre><code>[proguard] Error: Can't read [/home/juser/working/"/mnt/juser/repository/org/apache/logging/log4j/log4j-api/2.9.1/log4j-api-2.9.1.jar"(!META-INF/versions/**.class)] (No such file or directory)
  </code></pre>
  
  <p><strong>FAILED ATTEMPT #2</strong></p>
  
  <p>I have tried using inclusions to explicitly add this library with a filter.</p>
  
  <pre><code>&lt;assembly&gt;
    &lt;inclusions&gt;
      &lt;inclusion&gt;
        &lt;groupId&gt;org.apache.logging.log4j&lt;/groupId&gt;
        &lt;artifactId&gt;log4j-api&lt;/artifactId&gt;
        &lt;library&gt;true&lt;/library&gt;
        &lt;filter&gt;!META-INF/versions/**.class&lt;/filter&gt;
      &lt;/inclusion&gt;
    &lt;/inclusions&gt;
  &lt;/assembly&gt;
  </code></pre>
  
  <p>The library is listed as a -libraryjars entry, but there is no filter.</p>