【问题标题】:Exclude jar-with-dependencies from deploying to Nexus从部署到 Nexus 中排除 jar-with-dependencies
【发布时间】:2013-06-09 04:25:28
【问题描述】:

我正在使用maven-shade-plugin 创建一个包含我所有依赖项的附加 jar。阴影阶段与包阶段相关联,因此每次执行mvn package 时都会创建我的 jar-with-dependencies。

但是,我不希望在 mvn deploy 期间将此 jar-with-dependencies 部署到 Nexus。我怎样才能避免这种情况?

【问题讨论】:

  • 你为什么要通过 maven-shade 创建一个补充工件但不喜欢部署它?
  • 我们在运行时需要它。就像您建议的那样,runtime 配置文件可能是正确的做法。让我试试看。

标签: maven maven-shade-plugin


【解决方案1】:

为此目的的最佳解决方案是将 maven-shade-plugin 配置放入在部署阶段未激活的配置文件中。

【讨论】:

  • 你能举个例子吗?
  • 我想要实际上相同但相反:我想排除部署的某些依赖项。
【解决方案2】:

出于同样的需要,我从 GitHub 分叉了 ma​​ven-deploy-plugin 插件,并进行了更改,以便从部署中排除特定的附加工件,如下所示:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-deploy-plugin</artifactId>
  <version>3.0.0-SNAPSHOT</version>
  <configuration>
    <skipAttachedArtifacts>
      <artifact>
        <groupId>com.sample</groupId>
        <artifactId>something</artifactId>
        <version>${project.version}</version>
        <packaging>jar</packaging>
        <classifier>shaded</classifier>
      </artifact>
    </skipAttachedArtifacts>
  </configuration>
</plugin>

当前使用 skip 参数设置为 true 的 ma​​ven-deploy-plugin 插件,所有工件都从部署中排除,而这里的目标是仅从附加的。在我的 fork 中,我引入了 skipAttachedArtifacts 配置参数,以便指定要从部署中排除的附加工件。

这是我在 GitHub 上的分叉项目的链接: https://github.com/gregorycallea/maven-deploy-plugin

这里是我在 apache 插件项目上提交的拉取请求的链接: https://github.com/apache/maven-deploy-plugin/pull/3

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-09-06
    • 2012-01-31
    • 1970-01-01
    • 2017-09-02
    • 2020-08-02
    • 2013-06-22
    • 2011-07-13
    相关资源
    最近更新 更多