Skip to content

Goal tidy:pom fails if build section is empty #105

@ghusta

Description

@ghusta

Running mvn tidy:pom fails if section build is empty in POM.

Execution failing with :

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>test-tidy-pom</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.10.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
    </build>
</project>

Execution successful with :

    <build>
        <finalName>${project.artifactId}</finalName>
    </build>

or

    <build>
        <plugins>
        </plugins>
    </build>

Error log :

[ERROR] Failed to execute goal org.codehaus.mojo:tidy-maven-plugin:1.3.0:pom (default-cli) on project test-tidy-pom: Illegal processing instruction target ("xml"); xml (case insensitive) is reserved by the specs.
[ERROR]  at [row,col {unknown-source}]: [26,7]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions