簡體   English   中英

如何通過編輯pom.xml來排除jar中的包?

[英]How to exclude package in jar by editing pom.xml?

我正在嘗試通過編輯pom.xml來排除jar中的包(maven依賴)

所以我嘗試了一些方法,使用maven-shade-plugin和maven-jar-plugin添加標簽。 但它沒有用。 jar中的包仍然存在。

這是我試過的代碼。 謝謝。 artifact是jar名稱, com.domain.package是刪除表單jar的包。

<!-- first trial -->
<dependencies>
  <dependency>
    <groupId>Group</groupId>
    <artifactId>artifact</artifactId>
    <version>1.0</version>
    <scope>system</scope>
    <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/artifact.jar</systemPath>

    <exclusions>
      <exclusion>
     <groupId>com.domain.package</groupId>
     <artifactId>package</artifactId>
      </exclusion>
    </exclusions>
   </dependency>
</dependencies>

<!-- second trial -->
<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>
            <artifactSet>
               <excludes>                            
                  <exclude>artifact:com.domain.package</exclude>
               </excludes>
            </artifactSet>
         </configuration>
      </execution>
   </executions>
</plugin>

<!-- third trial -->
<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-jar-plugin</artifactId>
   <version>2.4</version>
   <executions>
      <execution>
         <id>artifact</id>
         <phase>package</phase>
         <goals>
            <goal>jar</goal>
         </goals>
         <configuration>
            <excludes>
               <exclude>**/com/domain/package/*</exclude>
            </excludes>
         </configuration>
      </execution>
   </executions>
</plugin>

您可以在maven jar插件執行中定義配置以排除和包含文件。

<configuration>
          <includes>
            <include>**/service/*</include>
          </includes>

https://maven.apache.org/plugins/maven-jar-plugin/examples/include-exclude.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM