Maven 阴影插件覆盖文件

maven shade plugin override a file

我正在使用 maven shade 插件创建一个 fat jar。我想覆盖 1 个来自我无法控制的 jar 的属性文件。我想在创建阴影 jar 之前更新该属性文件。我尝试使用转换器配置,但是当我尝试覆盖时出现错误

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.2.4:shade (default) on project dsp-santa-breakbox: Error creating shaded jar: duplicate entry: assets/components/hystrixCommand/hystrixCommand.js -> [Help 1]

这是我的阴影插件配置

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                                    <resource>assets/components/hystrixCommand/hystrixCommand.js</resource>
                                    <file>src/main/resources/hystrixCommand.js</file>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

有办法实现吗?

我不得不从其他工件中过滤文件, 这是最终配置的样子

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <filters>
                                <filter>
                                    <artifact>com.yammer.breakerbox:breakerbox-service</artifact>
                                    <excludes>
                                        <exclude>assets/components/hystrixCommand/hystrixCommand.js</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.IncludeResourceTransformer">
                                    <resource>assets/components/hystrixCommand/hystrixCommand.js</resource>
                                    <file>src/main/resources/hystrixCommand.js</file>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>