Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make finding a staging profile more lenient #498

Merged
merged 2 commits into from
Jan 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

## 0.23.2 **UNRELEASED**

- Fix signing when using the final Gradle 8.0 release.
- Fix signing when using the final Gradle 8.0 release.
- Finding a matching staging profile in Sonatype is more lenient. If there is just one that one will always be used.
The plugin will also fallback to any staging profile that has a matching prefix with the group id.
- As a workaround for an issue in Gradle that causes invalid module metadata for `java-test-fixtures` projects, `project.group`
and `project.version` are now being set again for those projects. [#490](https://github.com/vanniktech/gradle-maven-publish-plugin/pull/490)

Expand Down
16 changes: 14 additions & 2 deletions nexus/src/main/kotlin/com/vanniktech/maven/publish/nexus/Nexus.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,24 @@ class Nexus(
throw IllegalArgumentException("No staging profiles found in account $username. Make sure you called \"./gradlew publish\".")
}

val candidateProfiles = allProfiles.filter { group == it.name || group.startsWith(it.name) }
if (allProfiles.size == 1) {
return allProfiles[0]
}

var candidateProfiles = allProfiles.filter { group == it.name }

if (candidateProfiles.isEmpty()) {
candidateProfiles = allProfiles.filter { group.startsWith(it.name) }
}

if (candidateProfiles.isEmpty()) {
candidateProfiles = allProfiles.filter { group.commonPrefixWith(it.name).isNotEmpty() }
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be done in one-liner as...

val candidateProfiles = allProfiles.filter { group == it.name }
    .ifEmpty { allProfiles.filter { group.startsWith(it.name) } }
    .ifEmpty { allProfiles.filter { group.commonPrefixWith(it.name).isNotEmpty() } }

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 updated it e2a725f


if (candidateProfiles.isEmpty()) {
throw IllegalArgumentException(
"No matching staging profile found in account $username. It is expected that the account contains a staging " +
"profile that matches or is the start of $group." +
"profile that matches or is the start of $group. " +
"Available profiles are: ${allProfiles.joinToString(separator = ", ") { it.name }}"
)
}
Expand Down