File tree Expand file tree Collapse file tree
main/kotlin/org/hiero/gradle/spotless
test/kotlin/org/hiero/gradle/test Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,7 +67,11 @@ class SortModuleInfoRequiresStep {
6767 continue
6868 }
6969 current.add(line)
70- if (line.trimEnd().endsWith(" ;" )) {
70+ if (
71+ line.trimEnd().endsWith(" ;" ) ||
72+ (line.contains(" ;" ) &&
73+ line.substringAfter(" ;" ).trim().startsWith(" //" ))
74+ ) {
7175 flushCurrent()
7276 }
7377 }
Original file line number Diff line number Diff line change @@ -210,6 +210,37 @@ class QualityGateTest {
210210 assertThat(result.task(" :qualityGate" )?.outcome).isEqualTo(TaskOutcome .SUCCESS )
211211 }
212212
213+ @Test
214+ fun `spotlessApply preserves inline comments in module-info directives` () {
215+ val p = GradleProject ().withMinimalStructure()
216+ p.moduleBuildFile(""" plugins { id("org.hiero.gradle.module.library") }""" )
217+ val moduleInfo =
218+ p.moduleInfoFile(
219+ """
220+ module org.hiero.product.module.a {
221+ requires transitive javax.inject;
222+ requires transitive java.compiler; // javax.annotation.processing.Generated
223+ }
224+ """
225+ .trimIndent()
226+ )
227+
228+ val result = p.run (" spotlessApply" )
229+
230+ assertThat(moduleInfo)
231+ .hasContent(
232+ """
233+ // SPDX-License-Identifier: Apache-2.0
234+ module org.hiero.product.module.a {
235+ requires transitive java.compiler; // javax.annotation.processing.Generated
236+ requires transitive javax.inject;
237+ }
238+ """
239+ .trimIndent()
240+ )
241+ assertThat(result.task(" :spotlessApply" )?.outcome).isEqualTo(TaskOutcome .SUCCESS )
242+ }
243+
213244 @Test
214245 fun `spotlessApply formats rust files` () {
215246 val p = GradleProject ().withMinimalStructure()
You can’t perform that action at this time.
0 commit comments