gpt4 book ai didi

maven-2 - 模块:referencing another module from the desciptor

转载 作者:行者123 更新时间:2023-12-02 15:13:32 25 4
gpt4 key购买 nike

我的模块(APP1)的程序集描述符是:

  <?xml version="1.0" encoding="UTF-8"?>
<assembly>
<id>report</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<includes>
<include>*-APP2</include>[trying to refer to another module ie module-APP2]
</includes>
<sources>
<fileSets>
<fileSet>
<directory>/</directory>
<includes>
<include>**/target</include>
</includes>
</fileSet>
</fileSets>
<excludeSubModuleDirectories>false</excludeSubModuleDirectories>
<outputDirectoryMapping>/</outputDirectoryMapping>
</sources>
</moduleSet>
</moduleSets>
</assembly>

当我运行 mvn install cmd 时,我得到

[WARNING] The following patterns were never triggered in this artifact inclusion filter:
o '*-APP2'

我哪里出错了?

我修改为:

<?xml version="1.0" encoding="UTF-8"?><assembly>
<id>report</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<includes>
<include>sampleMaven:module-APP2</include>
</includes>
<sources>
<fileSets>
<fileSet>
<directory>/</directory>
<includes>
<include>target/*</include>
</includes>
</fileSet>
</fileSets>
<excludeSubModuleDirectories>false</excludeSubModuleDirectories>
<outputDirectoryMapping>/</outputDirectoryMapping>
</sources>
</moduleSet>
</moduleSets>
</assembly>

仍然得到:

[WARNING] The following patterns were never triggered in this artifact inclusion filter:
o 'sampleMaven:module-APP2'

9 月 18 日更新:主要项目pom.xml-->

http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 示例Maven 阿努 0.0.1-快照 pom

APP1

<module>APP2</module>

2)对于APP1,pom.xml是-->

   <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

阿努 示例Maven 0.0.1-快照 4.0.0 示例Maven 应用程序1 应用程序1 0.0.1-快照 pom
../APP2

<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-3</version>
<executions>
<execution>
<id>assemblyone</id>
<phase>compile</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>App1</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>${basedir}/src/main/resources/assemblies/report.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project> ...

3)程序集描述符是-->

报告 jar 错误的

 <sources>
<fileSets>
<fileSet>
<directory>/</directory>
<includes>
<include>target/*</include>
</includes>
</fileSet>
</fileSets>
<excludeSubModuleDirectories>false</excludeSubModuleDirectories>
<outputDirectoryMapping>/</outputDirectoryMapping>
</sources>
<binaries>
<outputDirectory>
${module.artifactId}-${module.version}
</outputDirectory>
<dependencySets>
<dependencySet/>
</dependencySets>
</binaries>
</moduleSet>

运行 gettting--> 错误堆栈跟踪:

org.apache.maven.project.DuplicateProjectException: Project 'sampleMaven:APP2' is duplicated in the reactor

最佳答案

更新:Maven 书中有一个关于 including moduleSets 的部分在组件中。您在示例中使用的方法已被弃用。从父级定义 moduleSet 时,构建顺序也存在问题。必须首先构建父级,以便子级可以继承它,但也必须构建子级,以便父级可以将其包含在其程序集中。以下方法解决了这个循环。

定义引用程序集模块的父pom。

<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>name.seller.rich</groupId>
<artifactId>test-parent</artifactId>
<packaging>pom</packaging>
<version>1.0.0</version>
<modules>
<module>test-assembly</module>
</modules>
<dependencies>
</project>

在程序集模块中,定义一个具有实际应用程序模块相对路径的模块,并定义程序集插件配置:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>name.seller.rich</groupId>
<artifactId>test-assembly</artifactId>
<packaging>pom</packaging>
<version>1.0.0-SNAPSHOT</version>
<modules>
<module>../my-app2</module>
</modules>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-4</version>
<executions>
<execution>
<id>assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>App1</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/my-assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

my- assembly.xml 定义如下:

<?xml version="1.0" encoding="UTF-8"?><assembly>
<id>my-assembly</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<binaries>
<outputDirectory>
${module.artifactId}-${module.version}
</outputDirectory>
<dependencySets>
<dependencySet/>
</dependencySets>
</binaries>
</moduleSet>
</moduleSets>
</assembly>

构建父模块将导致构建顺序:

  1. 测试父级
  2. 我的应用2
  3. 测试组装

因此,当程序集被打包时,my-app2 就会被构建,并且可供包含。二进制文件声明将包括 jars。

关于maven-2 - 模块:referencing another module from the desciptor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1438261/

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