Skip to content

Commit

Permalink
make finding a staging profile more lenient (#498)
Browse files Browse the repository at this point in the history
* make finding a staging profile more lenient

* use ifEmpty
  • Loading branch information
gabrielittner committed Jan 15, 2023
1 parent 6686704 commit 93a2188
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
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
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,18 @@ 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]
}

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

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

0 comments on commit 93a2188

Please sign in to comment.