Skip to content

Commit 7e4209c

Browse files
committed
Make generated annotation marking idempotent
1 parent a53a129 commit 7e4209c

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

build.gradle

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -607,11 +607,13 @@ tasks.register('markGeneratedEqualsHashCode') {
607607
def jacocoDir = layout.buildDirectory.dir('classes-jacoco/java/main')
608608

609609
inputs.dir(originalDir)
610+
inputs.property("generatedAnnotationTaskVersion", 2)
610611
outputs.dir(jacocoDir)
611612

612613
doLast {
613614
def src = originalDir.get().asFile
614615
def dest = jacocoDir.get().asFile
616+
project.delete(dest)
615617
if (!src.exists()) return
616618

617619
// Copy all class files to a separate directory for JaCoCo
@@ -635,8 +637,10 @@ tasks.register('markGeneratedEqualsHashCode') {
635637
if (method.invisibleAnnotations == null) {
636638
method.invisibleAnnotations = []
637639
}
638-
method.invisibleAnnotations.add(new org.objectweb.asm.tree.AnnotationNode(ANNOTATION))
639-
modified = true
640+
if (!method.invisibleAnnotations.any { it.desc == ANNOTATION }) {
641+
method.invisibleAnnotations.add(new org.objectweb.asm.tree.AnnotationNode(ANNOTATION))
642+
modified = true
643+
}
640644
}
641645
}
642646

@@ -799,4 +803,3 @@ tasks.withType(GenerateModuleMetadata) {
799803
}
800804

801805

802-

0 commit comments

Comments
 (0)