maven - Maven 程序集插件 - 忽略“存档不能为空”
问题描述
我有组装插件的问题。我必须使用一个程序集定义来为更多模块创建 JAR 文件。所以项目结构看起来像这样
module/
----module1/
-------- pom.xml
----module2/
-------- pom.xml
----moduleX/
-------- pom.xml
assembly_jar.xml
pom.xml (this is parent)
父 pom 文件如下所示:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.my.project</groupId>
<artifactId>parent-module</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make-jar</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<attach>false</attach>
<descriptors>
<descriptor>${source-systems.basedir}/assembly_jar.xml</descriptor>
</descriptors>
<finalName>${project.artifactId}-${project.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</execution>
</plugin>
</plugins>
</build>
</project>
assembly_jar.xml 如下所示:
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>jar-with-some-dependencies</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<scope>runtime</scope>
<unpack>true</unpack>
</dependencySet>
</dependencySets>
</assembly>
模块 1 的 pom 文件如下所示:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.my.project</groupId>
<artifactId>parent-module</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
<groupId>com.my.project</groupId>
<artifactId>module1</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>oracle_rds</name>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4</version>
</dependency>
</dependencies>
</project>
当我为 module1 运行mvn clean install时,一切正常并创建了 jar 文件。但是我有 module2 不需要任何特定的依赖项。所以 pom 文件看起来像这样:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.my.project</groupId>
<artifactId>parent-module</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<packaging>pom</packaging>
<groupId>com.my.project</groupId>
<artifactId>module2</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>oracle_rds</name>
</project>
当我运行mvn clean install我有错误 创建程序集存档 jar-with-some-dependencies: archive cannot be empty这是因为没有依赖项可以打包到 jar 文件中。
如果模块中没有依赖项,有什么方法可以忽略此错误并且不创建 jar 文件?
由于重复性很大,我不想将程序集定义移动到模块中(我将拥有 100 多个模块,其中大多数会有一些特殊的依赖项)谢谢您的帮助。
解决方案
推荐阅读
- python - Django 个人资料图像错误地显示登录用户的图像(在每个个人资料上)
- amazon-web-services - 没有在 AWS quicksight 中获取顶部和底部过滤器中的所有行
- javascript - 如何使用 Formik 在页面上有多个提交处理程序?
- java - 如何进一步减小android画中画窗口的大小?
- relationship - Adonis V4 - 如何删除关系
- python - Pycharm:无法上传远程解释器的帮助程序:身份验证失败:可用的身份验证方法已用尽
- python - 为什么我的 python 代码打印“函数”和很多数字?
- javascript - 如何转发 ref 函数声明而不是箭头函数?
- amazon-web-services - Route53 和 ElasticBeanstalk,如何使 DNS 记录对应用程序更新具有持久性?
- c - lang-c 使用嵌套的for循环和函数打印两个中间有空格的金字塔?