gpt4 book ai didi

maven 程序集忽略父依赖项

转载 作者:行者123 更新时间:2023-12-04 15:05:34 60 4
gpt4 key购买 nike

当依赖项直接包含在 pom 文件中时,我的程序集描述符会正确应用包含和排除。

但是,当我将依赖项放在父 pom 文件中时,程序集:目录目标报告包含和排除尚未触发。

你知道为什么 maven-assembly-plugin 会忽略父依赖吗?我该如何解决?

以下是 Maven 和程序集描述符:

装配描述符:

<assembly>
<id>distribution</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<includes>
<include>readme.txt</include>
</includes>
</fileSet>
<fileSet>
<directory>target</directory>
<outputDirectory>/lib</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>/lib</outputDirectory>
<unpack>false</unpack>
<scope>runtime</scope>
<excludes>
<exclude>org.tanukisoftware:wrapper:exe:3.3.5</exclude>
</excludes>
</dependencySet>
<dependencySet>
<outputDirectory>/bin</outputDirectory>
<unpack>false</unpack>
<scope>runtime</scope>
<includes>
<include>org.tanukisoftware:wrapper:exe:3.3.5</include>
</includes>
</dependencySet>
</dependencySets>
</assembly>

子 POM 程序集插件定义:
    <plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>directory</goal>
</goals>
</execution>
</executions>
</plugin>

父 POM 依赖项:
<dependencies>
<dependency>
<groupId>org.tanukisoftware</groupId>
<artifactId>wrapper</artifactId>
<version>3.3.5</version>
<type>dll</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.tanukisoftware</groupId>
<artifactId>wrapper</artifactId>
<version>3.3.5</version>
<type>exe</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.tanukisoftware</groupId>
<artifactId>wrapper</artifactId>
<version>3.3.5</version>
<scope>runtime</scope>
</dependency>
</dependencies>

构建报告中的警告:
[assembly:directory {execution: make-assembly}]
Reading assembly descriptor: assembly.xml
Processing DependencySet (output=/lib)
[WARNING] The following patterns were never triggered in this artifact exclusion filter:
o 'org.tanukisoftware:wrapper:exe:3.3.5'

Processing DependencySet (output=/bin)
[WARNING] The following patterns were never triggered in this artifact inclusion filter:
o 'org.tanukisoftware:wrapper:exe:3.3.5'

最佳答案

我不知道这是否会有所帮助,但我总是在 parent 的 pom 中将依赖项放在 dependencyManagement block 中;

    <dependencyManagement>
<!-- dependencies with exclusions -->
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>

<version>${version.springframework}</version>

<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>

然后,在子 pom 中,再次列出依赖项,但没有版本和排除项
  <dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</dependency>

但老实说,对于我的第一个也是唯一一个程序集,我无法让它在子模块中工作并将其放入父模块的 pom.xml 中。这是我的程序集文件,用于为由 cron 运行的独立 java 程序制作 zip 文件:
<?xml version="1.0" encoding="UTF-8"?>

<assembly>
<id>${project.layer}-both</id>

<formats>
<format>zip</format>
</formats>

<includeBaseDirectory>false</includeBaseDirectory>

<baseDirectory>/</baseDirectory>

<moduleSets>
<moduleSet>
<includes>
<include>edu.berkeley.ist.cars:cars_upload</include>
</includes>

<binaries>
<unpack>false</unpack>
<useStrictFiltering>true</useStrictFiltering>
<includeDependencies>true</includeDependencies>
<outputDirectory>upload</outputDirectory>
</binaries>
</moduleSet>

<moduleSet>
<includes>
<include>edu.berkeley.ist.cars:cars_download</include>
</includes>

<binaries>
<unpack>false</unpack>
<useStrictFiltering>true</useStrictFiltering>
<includeDependencies>true</includeDependencies>
<outputDirectory>download</outputDirectory>
</binaries>
</moduleSet>
</moduleSets>

<!--
crontab.txt is put in twice, in both upload and download, just in case.
-->
<files>
<!-- upload files -->
<file>
<source>src/stuff/scripts/cars_upload.sh</source>
<lineEnding>unix</lineEnding>
<filtered>true</filtered>
<outputDirectory>upload</outputDirectory>
</file>

<file>
<source>src/stuff/notes/crontab-${project.layer}.txt</source>
<destName>crontab.txt</destName>
<lineEnding>unix</lineEnding>
<filtered>true</filtered>
<outputDirectory>upload</outputDirectory>
</file>

<!-- download files -->
<file>
<source>src/stuff/scripts/cars_download.sh</source>
<lineEnding>unix</lineEnding>
<filtered>true</filtered>
<outputDirectory>download</outputDirectory>
</file>

<file>
<source>src/stuff/notes/crontab-${project.layer}.txt</source>
<destName>crontab.txt</destName>
<lineEnding>unix</lineEnding>
<filtered>true</filtered>
<outputDirectory>download</outputDirectory>
</file>
</files>
</assembly>

zip 文件中有两个顶级目录,上传和下载。

关于maven 程序集忽略父依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1034347/

60 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com