Unwanted removal of surrounding comments
matusfaro opened this issue · 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 <matus@smotana.com>
// 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 <matus@smotana.com>
+// SPDX-FileCopyrightText: 2019-2020 Matus Faro <matus@smotana.com>
// 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 <matus@smotana.com>
+// SPDX-FileCopyrightText: 2019-2022 Matus Faro <matus@smotana.com>
// 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 <matus@smotana.com>
// 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>matus@smotana.com</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}
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
Issue still present, still affected
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
@matusfaro I guess if you add endLine option as EOL
you might always have newline that would prevent that from happening?