mathieucarbou / license-maven-plugin

Manage license headers in your source files

Home Page:https://oss.carbou.me/license-maven-plugin/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

XML files become corrupted if existing license header closes comment on the same line

akomakom opened this issue · comments

Running license:format using 4.1 corrupts XML files if the existing (in XML file) license header looks like this:

<!-- All content copyright (c) 2003-2021 Bla, Inc., except as may
  otherwise be noted in a separate copyright notice. All rights reserved. -->

It works correctly if the license header looks like this: (close comment on a new line)

<!-- All content copyright (c) 2003-2021 Bla, Inc., except as may
  otherwise be noted in a separate copyright notice. All rights reserved. 
-->

With the first snippet, the resulting file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<!--

    All content copyright (c) 2003-2021 Bla, Inc., except as may otherwise be
    noted in a separate copyright notice. All rights reserved.

-->
</ns:mytag>

(The last xml close tag is the only survivor)

Config:

 <plugin>
  <groupId>com.mycila</groupId>
  <artifactId>license-maven-plugin</artifactId>
  <version>4.1</version>
  <configuration>
    <inlineHeader><![CDATA[
All content copyright (c) 2003-2021 Bla, Inc., except as may otherwise be
noted in a separate copyright notice. All rights reserved.
        ]]></inlineHeader>
    <mapping>
      <java>SLASHSTAR_STYLE</java>
    </mapping>
    <excludes>
      <exclude>Jenkinsfile</exclude>
      <exclude>**/pom.xml</exclude>
    </excludes>
  </configuration>
</plugin>

FYI:

  • Same behavior with 3.0
  • Problem does not occur with XML_PER_LINE mode