Maven Shade:仅包含特定工件并排除所有其余工件 [英] Maven Shade : include only specific artifacts and exclude all the rest

查看:59
本文介绍了Maven Shade:仅包含特定工件并排除所有其余工件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图实现一个非常简单的事情:只在我的构建中包含一些工件,而排除其他所有内容.我不想同时指定包含和排除.

(实际上,我对 Maven Shade 的问题比语法更深,这也是关于它的逻辑,这让我感到困惑:我发现双重范式(包含 + 排除)令人困惑,因为对我来说两者都是相关联的.)

我已经为此挠头好几个小时了.尽管在此处中提供了一些示例在文档中,我未能在我的案例中找到有效的语法(无论我尝试过什么,我都会继续包含所有内容).
(恕我直言,我发现文档很简单,我找不到这个插件的全面参考.)

我确信有一种方法可以实现这一目标.

<预><代码><过滤器><过滤器><神器>**:**</神器><包括><include>org/apache/logging/**</include></包括><排除><exclude>all/the/rest/**</exclude></排除></过滤器></过滤器>

还有:

这是什么/path/to/artifact 语法?org/apache/logging 是指工件 org.apache.logging 还是我弄错了.

解决方案

我按照评论中的建议使用了以下方法:

 <插件><groupId>org.apache.maven.plugins</groupId><artifactId>maven-shade-plugin</artifactId><version>3.2.1</version><执行><执行><phase>包</phase><目标><目标>阴影</目标></目标><配置>#有趣的部分来了<工件集><包括><include>org.apache.logging.log4j:*</include></包括></artifactSet></配置></执行></执行></插件>

I am trying to achieve a very simple thing : Only include some artifacts in my build, while excluding everything else. I do not want to specify both include and excludes.

(Actually my problem with Maven Shade goes deeper than syntax, it is also about its logic, that puzzles me : I find the double paradigm (Inclusion + Exclusion) confusing because to me both are linked.)

I have been scratching my head for hours about this. Although a few examples are provided here in the doc, I failed to find a working syntax in my case (I keep on getting everything included whatever I tried).
(I find the documentation pretty light IMHO and I can't find a thorough comprehensive reference for this plugin.)

I am sure there is a way to achieve this.


              <filters>
                <filter>
                  <artifact>**:**</artifact>

                  <includes>
                    <include>org/apache/logging/**</include>
                  </includes>

                  <excludes>
                    <exclude>all/the/rest/**</exclude>
                  </excludes>

                </filter>
               </filters>

also :

what is this /path/to/artifact syntax ? Does org/apache/logging refer to artifact org.apache.logging or am I mistaken.

解决方案

I used the following approach as suggested in a comment :

     <plugin>

         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-shade-plugin</artifactId>
         <version>3.2.1</version>

         <executions>
          <execution>
            <phase>package</phase> 
            <goals>
              <goal>shade</goal>
            </goals>

            <configuration>

              #here comes the interesting part
              <artifactSet>
                <includes>
                    <include>org.apache.logging.log4j:*</include>
                </includes>
              </artifactSet>

            </configuration>

          </execution>
        </executions>
      </plugin>

这篇关于Maven Shade:仅包含特定工件并排除所有其余工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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