Java插件库底纹 [英] Java plugin library shading

查看:76
本文介绍了Java插件库底纹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用类似bukkit(minecraft)的插件系统构建基于Java的HTTP Server.我想以不互相干扰的方式加载插件库,例如如果两个插件在其jar中打包了相同的库,则可能会出错.

I'm building a Java based HTTP Server with a bukkit-like (minecraft) plugin system. And I want to load plugin libraries in such a way that they don't interfere with each other, e.g. if two plugins package the same library in their jar something might go wrong.

我知道这可以通过阴影"来完成.但是,我所知道的关于Maven的唯一一件事就是如何向项目添加依赖项.而且,maven教程并没有使我变得更明智.

I know this can be done with "maven shading". However, the only thing about maven I know is how to add dependencies to a project. And maven tutorials are not making me any wiser.

我已经阅读了一些有关构建目标的内容,但是却找不到任何pom.xml示例来说明其工作原理或所拥有的选项.当我搜索"Java插件maven阴影"或类似内容时,我得到的唯一结果是关于maven阴影插件的(我都不了解这两者的第一件事)

I have read up about somethings like build goals, yet nowhere any pom.xml examples explaining how this works or what kind of options you have. And when I search for "Java plugin maven shading" or similar the only results I get are about the maven shading plugin (which I don't understand the first thing about either)

我不想深入了解Maven命令行,我正在使用Eclipse Maven插件.

I don't want to get too deep into maven commandline, I'm using a eclipse maven plugin.

也欢迎其他解决方案.

推荐答案

另一个论坛上的某人告诉我要在fat jar的上下文中进行搜索,这有助于我找到答案.我发现网站有一个如何打包jar文件的好例子:

Someone on another forum told me to search in the context of fat jar which helped me find my answer. I found this website with a nice example of how to package the jar file:

<!-- Maven Shade Plugin -->
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-shade-plugin</artifactId>
  <version>2.3</version>
  <executions>
    <!-- Run shade goal on package phase -->
    <execution>
        <phase>package</phase>
      <goals>
        <goal>shade</goal>
      </goals>
      <configuration>
        <transformers>
          <!-- add Main-Class to manifest file -->
          <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
            <mainClass>com.mkyong.core.utils.App</mainClass>
          </transformer>
        </transformers>
      </configuration>
    </execution>
  </executions>
</plugin>

这篇关于Java插件库底纹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆