3

I have a jar build by maven-shade-plugin. It contains META-INF/services with several files. These files have wrong names (because of the bug https://issues.apache.org/jira/browse/MSHADE-182). I'd like to rename these files.

What is the easiest way of doing this with maven?

long
  • 414
  • 4
  • 15
  • ideally you'd show what you've tried to do to solve this problem. that is probably why your question was downvoted. – Martin Serrano Nov 20 '15 at 11:51
  • You link to a bug. This bug has a patch attached, why not install it? Since there is a bug, I don't see what kind of answers you expect, except "There is a bug.". – Tunaki Nov 20 '15 at 11:53
  • @Tunaki I'm not an Apache committer. Thus, I have 2 possible ways - 1) Wait for a new release of plugin; 2) Apply some temporary solution. – long Nov 20 '15 at 11:58
  • You don't have to be an Apache committer to install the patch. Just fork the repo, apply the patch and install the dependency to your Maven repo with a custom version. – Tunaki Nov 20 '15 at 11:59
  • I'm not the only one who needs this fix (distributed team). It should be released and accessible through the central repo. – long Nov 20 '15 at 12:02

1 Answers1

1

Dirty hack, but it works for me

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution>
                    <id>unpack</id>
                    <phase>package</phase>
                    <configuration>
                        <target>
                            <echo message="unjar" />
                            <unzip src="${project.build.directory}/${artifactId}-${version}.jar" dest="${project.build.directory}/unpacked/" />
                            <echo message="rename service providers in META-INF/services" />
                            <move todir="${project.build.directory}/unpacked/META-INF/services" includeemptydirs="false">
                                <fileset dir="${project.build.directory}/unpacked/META-INF/services"/>
                                <mapper type="glob" from="*" to="${shade.package}.*"/>
                            </move>
                            <echo message="jar back" />
                            <jar destfile="${project.build.directory}/${artifactId}-${version}.jar" basedir="${project.build.directory}/unpacked" />
                        </target>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
long
  • 414
  • 4
  • 15