我有一个使用maven发布插件的gradle多模块项目。发布任务失败,因为maven发布插件生成无效的POM。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xmlns="http://www.w3.org/2000/xmlns/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xmlns="http://www.w3.org/2000/xmlns/">
<modelVersion xmlns="http://maven.apache.org/POM/4.0.0">4.0.0</modelVersion>
<groupId xmlns="http://maven.apache.org/POM/4.0.0">com.example</groupId>
<artifactId xmlns="http://maven.apache.org/POM/4.0.0">application</artifactId>
<version xmlns="http://maven.apache.org/POM/4.0.0">0.2.0-SNAPSHOT</version>
<packaging xmlns="http://maven.apache.org/POM/4.0.0">pom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.2.1.RELEASE</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
</project xmlns="http://maven.apache.org/POM/4.0.0">
它显然是无效的,因为项目起始元素中有重复的属性,而结束元素具有'xmlns="http://maven.apache.org/POM/4.0.0"'
我尝试了gradle 5.6.0和6.1.1,结果相同。
知道如何解决这个问题吗?原因是什么?
我通过在根项目级别应用maven发布插件解决了这个问题。
当我将下面的代码添加到我要发布的子项目之一时,生成的pom无效:
plugins {
id 'nebula.release' version '14.0.3'
id 'maven-publish'
id 'nebula.maven-publish' version '14.1.1'
}