|
| 1 | +import io.opentelemetry.instrumentation.gradle.CheckMavenPublicationCoordinatesTask |
1 | 2 | import okhttp3.MediaType.Companion.toMediaType |
2 | 3 | import okhttp3.OkHttpClient |
3 | 4 | import okhttp3.RequestBody.Companion.asRequestBody |
| 5 | +import org.gradle.api.publish.PublishingExtension |
| 6 | +import org.gradle.api.publish.maven.MavenPublication |
4 | 7 | import java.time.Duration |
5 | 8 | import java.util.Base64 |
6 | 9 |
|
@@ -67,6 +70,22 @@ if (project.findProperty("skipTests") as String? == "true") { |
67 | 70 | } |
68 | 71 | } |
69 | 72 |
|
| 73 | +val mavenPublicationCoordinates = objects.listProperty<String>() |
| 74 | + |
| 75 | +subprojects { |
| 76 | + val projectPath = path |
| 77 | + pluginManager.withPlugin("maven-publish") { |
| 78 | + extensions.getByType<PublishingExtension>().publications |
| 79 | + .withType<MavenPublication>() |
| 80 | + .configureEach { |
| 81 | + val publication = this |
| 82 | + mavenPublicationCoordinates.add(provider { |
| 83 | + "${publication.groupId}:${publication.artifactId}:${publication.version}=$projectPath:${publication.name}" |
| 84 | + }) |
| 85 | + } |
| 86 | + } |
| 87 | +} |
| 88 | + |
70 | 89 | if (gradle.startParameter.taskNames.contains("listTestsInPartition")) { |
71 | 90 | tasks { |
72 | 91 | register<DefaultTask>("listTestsInPartition") { |
@@ -129,6 +148,21 @@ if (gradle.startParameter.taskNames.contains("listTestsInPartition")) { |
129 | 148 | tasks { |
130 | 149 | val stableVersion = version.toString().replace("-alpha", "") |
131 | 150 |
|
| 151 | + val checkMavenPublicationCoordinates = register<CheckMavenPublicationCoordinatesTask>("checkMavenPublicationCoordinates") { |
| 152 | + group = "Verification" |
| 153 | + description = "Checks that Maven publications have unique coordinates" |
| 154 | + publicationCoordinates.set(mavenPublicationCoordinates) |
| 155 | + } |
| 156 | + |
| 157 | + subprojects { |
| 158 | + tasks.matching { it.name == "check" }.configureEach { |
| 159 | + dependsOn(checkMavenPublicationCoordinates) |
| 160 | + } |
| 161 | + tasks.withType<PublishToMavenRepository>().configureEach { |
| 162 | + dependsOn(checkMavenPublicationCoordinates) |
| 163 | + } |
| 164 | + } |
| 165 | + |
132 | 166 | register<DefaultTask>("generateFossaConfiguration") { |
133 | 167 | group = "Help" |
134 | 168 | description = "Generate .fossa.yml configuration file" |
|
0 commit comments