在项目依赖阴影重命名
In project dependency shade rename
正如在 中所读,SBT (sbt-assembly) 允许在导入重命名库的项目中重命名包。例如:
我想在我的项目中使用包 org.pfcoperez.algorithms
但我想 "see" 它,即:能够导入它,如 com.algorithms
.
我知道 Maven Shade 插件可以按照描述重新定位依赖关系 here:
<relocations>
<relocation>
<pattern>org.codehaus.plexus.util</pattern>
<shadedPattern>org.shaded.plexus.util</shadedPattern>
<excludes>
<exclude>org.codehaus.plexus.util.xml.Xpp3Dom</exclude>
<exclude>org.codehaus.plexus.util.xml.pull.*</exclude>
</excludes>
</relocation>
</relocations>
我可以用它来生成具有新包结构的中间 jar。但是,我想避免使用那个中间工件。
是否可以像在 SBT 中一样在 Maven 项目中执行此操作?如果答案是肯定的,那怎么可能呢?
我认为您可以将 shade:shade
目标附加到 process-resources
阶段并将生成的 jar 设置为 system
依赖项,以便在 compile
期间可用] 阶段。
不过我不会推荐它,因为您的 IDE 几乎肯定会在理解您的 POM 时遇到问题。
正如在
我想在我的项目中使用包 org.pfcoperez.algorithms
但我想 "see" 它,即:能够导入它,如 com.algorithms
.
我知道 Maven Shade 插件可以按照描述重新定位依赖关系 here:
<relocations>
<relocation>
<pattern>org.codehaus.plexus.util</pattern>
<shadedPattern>org.shaded.plexus.util</shadedPattern>
<excludes>
<exclude>org.codehaus.plexus.util.xml.Xpp3Dom</exclude>
<exclude>org.codehaus.plexus.util.xml.pull.*</exclude>
</excludes>
</relocation>
</relocations>
我可以用它来生成具有新包结构的中间 jar。但是,我想避免使用那个中间工件。
是否可以像在 SBT 中一样在 Maven 项目中执行此操作?如果答案是肯定的,那怎么可能呢?
我认为您可以将 shade:shade
目标附加到 process-resources
阶段并将生成的 jar 设置为 system
依赖项,以便在 compile
期间可用] 阶段。
不过我不会推荐它,因为您的 IDE 几乎肯定会在理解您的 POM 时遇到问题。