Skip to content

Commit

Permalink
Remove "project dependencies are published" check (#3078)
Browse files Browse the repository at this point in the history
The check was likely added because bintray did not perform any checks of its own, but Maven Central should check for that before the staging repository is closed and all the artifacts are published, so it's not needed locally
  • Loading branch information
IgnatBeresnev committed Jul 21, 2023
1 parent 3f50846 commit 99062cb
Showing 1 changed file with 0 additions and 34 deletions.
34 changes: 0 additions & 34 deletions build-logic/src/main/kotlin/org/jetbrains/ValidatePublications.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,11 @@ open class ValidatePublications : DefaultTask() {
.filterIsInstance<MavenPublication>()
.filter { it.version == project.dokkaVersion }
.forEach { _ ->
checkProjectDependenciesArePublished(subProject)
subProject.assertPublicationVersion()
}
}
}

private fun checkProjectDependenciesArePublished(project: Project) {
val implementationDependencies = project.findDependenciesByName("implementation")
val apiDependencies = project.findDependenciesByName("api")

val allDependencies = implementationDependencies + apiDependencies

allDependencies
.filterIsInstance<ProjectDependency>()
.forEach { projectDependency ->
val publishing = projectDependency.dependencyProject.extensions.findByType<PublishingExtension>()
?: throw UnpublishedProjectDependencyException(
project = project, dependencyProject = projectDependency.dependencyProject
)

val isPublished = publishing.publications.filterIsInstance<MavenPublication>()
.any { it.version == project.dokkaVersion }

if (!isPublished) {
throw UnpublishedProjectDependencyException(project, projectDependency.dependencyProject)
}
}
}

private fun Project.findDependenciesByName(name: String): Set<Dependency> {
return configurations.findByName(name)?.allDependencies.orEmpty()
}

private fun Project.assertPublicationVersion() {
val versionTypeMatchesPublicationChannels = publicationChannels.all { publicationChannel ->
publicationChannel.acceptedDokkaVersionTypes.any { acceptedVersionType ->
Expand All @@ -70,10 +42,4 @@ open class ValidatePublications : DefaultTask() {
throw AssertionError("Wrong version $dokkaVersion for configured publication channels $publicationChannels")
}
}

private class UnpublishedProjectDependencyException(
project: Project, dependencyProject: Project
): GradleException(
"Published project ${project.path} cannot depend on unpublished project ${dependencyProject.path}"
)
}

0 comments on commit 99062cb

Please sign in to comment.