2

I have a gradle multimodule project using the maven publish plugin. The publish task fails as the maven publish plugin generates an invalid 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">

It clearly is invalid as there are duplicated attributes in the project starting element and the closing element has 'xmlns="http://maven.apache.org/POM/4.0.0"'

I tried gradle 5.6.0 and 6.1.1 with the same outcome.

Any idea how to fix this and what could be the cause?

Marco Tizzoni
  • 532
  • 4
  • 13
  • Well, can you describe to us how you arrived at this startling outcome? – barfuin Jan 27 '20 at 19:36
  • Nothing special. Multi-module project with 2 sub projects. When I add this to one of the subproject I want to publish the generated pom is invalid: plugins { id 'nebula.release' version '14.0.3' id 'maven-publish' id 'nebula.maven-publish' version '14.1.1' } – Marco Tizzoni Jan 28 '20 at 08:09

1 Answers1

0

I solved by applying the maven publish plugin at root project level.

When I add the code below to one of the subproject I want to publish, the generated pom is invalid:

   plugins {
       id 'nebula.release' version '14.0.3'
       id 'maven-publish'
       id 'nebula.maven-publish' version '14.1.1'
}
Marco Tizzoni
  • 532
  • 4
  • 13