Skip to content

Commit 52d0df3

Browse files
authored
Merge pull request #3782 from bjhargrave/issues/3780
gradle: Avoid multiple sets of org.gradle.libraryelements to jar
2 parents 8c910aa + 72e90fb commit 52d0df3

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndUtils.groovy

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,15 @@ class BndUtils {
6565

6666
public static void jarLibraryElements(Project project, String configurationName) {
6767
if (IS_GRADLE_COMPATIBLE_5_6) {
68-
project.configurations[configurationName].attributes.attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.class, LibraryElements.JAR))
68+
def attributes = project.configurations[configurationName].attributes
69+
if (attributes.getAttribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE)?.name != LibraryElements.JAR) {
70+
try {
71+
attributes.attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements.class, LibraryElements.JAR))
72+
project.logger.info 'Set {}:{} configuration attribute {} to {}', project.path, configurationName, LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, attributes.getAttribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE)
73+
} catch (IllegalArgumentException e) {
74+
project.logger.info 'Unable to set {}:{} configuration attribute {} to {}', project.path, configurationName, LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, LibraryElements.JAR, e
75+
}
76+
}
6977
}
7078
}
7179
}

0 commit comments

Comments
 (0)