Skip to content

Commit 6645136

Browse files
committed
checksum-dependency: infer artifact classifier from the file name
Sometimes Gradle uses componentId + fileName for artifact identifier, however, we have to use classifier+extension for resolving the signature files.
1 parent 40e9887 commit 6645136

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ This library is distributed under terms of Apache License 2.0
8787

8888
Change log
8989
----------
90+
v1.88
91+
* stage-vote-release: avoid failures when "init" does not exist
92+
* chore: fixed build warnings
93+
* checksum-dependency: infer artifact classifier from the file name
94+
9095
v1.87
9196
* gradle-extensions: requiredString, requiredBool, requiredInt, requiredLong property accessors
9297
* gradle-extensions: display TestNG initialization failures

plugins/checksum-dependency-plugin/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,9 @@ Verification options
500500

501501
Changelog
502502
---------
503+
v1.88
504+
* Infer artifact classifier from the file name
505+
503506
v1.86
504507
* Use full fingerprint for PGP verification
505508

plugins/checksum-dependency-plugin/src/main/kotlin/com/github/vlsi/gradle/checksum/ComponentArtifactIdentifierExtensions.kt

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,27 @@ import org.gradle.api.artifacts.DependencyArtifact
2121
import org.gradle.api.artifacts.component.ComponentArtifactIdentifier
2222
import org.gradle.api.artifacts.component.ModuleComponentIdentifier
2323
import org.gradle.internal.component.external.model.DefaultModuleComponentArtifactIdentifier
24+
import org.gradle.internal.component.external.model.ModuleComponentFileArtifactIdentifier
2425

2526
private fun ComponentArtifactIdentifier.artifactOrSignatureId(artifact: Boolean): Id {
2627
val id = componentIdentifier as ModuleComponentIdentifier
2728
var classifier: String? = null
2829
var extension: String
29-
if (this is DefaultModuleComponentArtifactIdentifier) {
30+
if (this is ModuleComponentFileArtifactIdentifier) {
31+
val prefix = id.module + "-" + id.version
32+
if (!fileName.startsWith(prefix)) {
33+
// The file name does not follow Maven conventions. Assume it is a default file
34+
// In the worst case, we won't be able to find the signature, and we'll downgrade
35+
// to checksums
36+
extension = fileName.substringAfterLast('.')
37+
} else {
38+
val rest = fileName.removePrefix(prefix)
39+
extension = rest.substringAfterLast('.')
40+
if (rest.startsWith('-')) {
41+
classifier = rest.substring(1, rest.length - extension.length - 1)
42+
}
43+
}
44+
} else if (this is DefaultModuleComponentArtifactIdentifier) {
3045
classifier = name.classifier
3146
extension = name.extension ?: DependencyArtifact.DEFAULT_TYPE
3247
} else {

0 commit comments

Comments
 (0)