license-maven-plugin
license-maven-plugin copied to clipboard
Unwanted removal of surrounding comments
Version affected
4.1
Describe the bug
Formatting licenses also removes surrounding comments.
My license is a two line SPDX tag:
// SPDX-FileCopyrightText: 2019-2019 Matus Faro <[email protected]>
// SPDX-License-Identifier: Apache-2.0
/// <reference path="../@types/transform-media-imports.d.ts"/>
After first round of license update:
-// SPDX-FileCopyrightText: 2019-2019 Matus Faro <[email protected]>
+// SPDX-FileCopyrightText: 2019-2020 Matus Faro <[email protected]>
// SPDX-License-Identifier: Apache-2.0
-
/// <reference path="../@types/transform-media-imports.d.ts"/>
After second round of license update:
-// SPDX-FileCopyrightText: 2019-2020 Matus Faro <[email protected]>
+// SPDX-FileCopyrightText: 2019-2022 Matus Faro <[email protected]>
// SPDX-License-Identifier: Apache-2.0
- /// <reference path="../@types/transform-media-imports.d.ts"/>
The quick fix is to add a /* */ comment in-between like so:
// SPDX-FileCopyrightText: 2019-2022 Matus Faro <[email protected]>
// SPDX-License-Identifier: Apache-2.0
/** Intentional comment to prevent licence-maven-plugin from deleting the below line */
/// <reference path="../@types/transform-media-imports.d.ts"/>
How to Reproduce
Snippet from pom.xml
<plugin>
<inherited>false</inherited>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>${license-maven-plugin.version}</version>
<configuration>
<!-- Due to performance, only run this when necessary -->
<skip>${skipLicenseUpdate}</skip>
<aggregate>true</aggregate>
<headerDefinitions>
<headerDefinition>tools/comment-template-SINGLE_LINE_DOUBLEDASH_STYLE.xml
</headerDefinition>
<headerDefinition>tools/comment-template-SINGLE_LINE_DOUBLEHASH_STYLE.xml
</headerDefinition>
</headerDefinitions>
<licenseSets>
<licenseSet>
<includes>
<include>**/*.java</include>
<include>**/*.js</include>
<include>**/*.jsx</include>
<include>**/*.ts</include>
<include>**/*.tsx</include>
<include>**/*.yml</include>
<include>**/*.yaml</include>
<include>**/*.sql</include>
<include>**/*.proto</include>
<include>**/*.painless</include>
</includes>
<header>tools/file-header-template.txt</header>
</licenseSet>
</licenseSets>
<mapping>
<java>SINGLE_LINE_DOUBLESLASH_STYLE</java>
<js>SINGLE_LINE_DOUBLESLASH_STYLE</js>
<jsx>SINGLE_LINE_DOUBLESLASH_STYLE</jsx>
<ts>SINGLE_LINE_DOUBLESLASH_STYLE</ts>
<tsx>SINGLE_LINE_DOUBLESLASH_STYLE</tsx>
<yaml>SINGLE_LINE_DOUBLEHASH_STYLE</yaml>
<yml>SINGLE_LINE_DOUBLEHASH_STYLE</yml>
<sql>SINGLE_LINE_DOUBLEDASH_STYLE</sql>
<painless>SINGLE_LINE_DOUBLESLASH_STYLE</painless>
<proto>SINGLE_LINE_DOUBLESLASH_STYLE</proto>
</mapping>
<project>
<inceptionYear>2019</inceptionYear>
</project>
<properties>
<owner>Matus Faro</owner>
<email>[email protected]</email>
<license>Apache-2.0</license>
</properties>
</configuration>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin-git</artifactId>
<version>${license-maven-plugin.version}</version>
</dependency>
</dependencies>
</plugin>
tools/file-header-template.txt:
SPDX-FileCopyrightText: ${license.git.copyrightYears} ${owner} <${email}>
SPDX-License-Identifier: ${license}