Skip to content

Commit

Permalink
Add proper gradle-plugin-portal publication channel
Browse files Browse the repository at this point in the history
* Remove explicit flag for version checking, will be executed automatically if publication channels are present
* Update publish to GH pages script to include SNAPSHOT docs
  • Loading branch information
IgnatBeresnev committed Mar 24, 2022
1 parent eae5885 commit 4628f67
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
java-version: 11
- uses: gradle/gradle-build-action@v2
- name: Get current dokka version
run: echo "DOKKA_VERSION=`./gradlew :properties | grep '^version:.*' | cut -d ' ' -f 2 | cut -d '-' -f 1`" >> $GITHUB_ENV
run: echo "DOKKA_VERSION=`./gradlew :properties | grep '^version:.*' | cut -d ' ' -f 2`" >> $GITHUB_ENV
if: github.event_name == 'release' || steps.filter.outputs.docs_changed == 'true'
working-directory: ./dokka
- name: Build docs
Expand Down
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Building dokka
## Building Dokka

Dokka is built with Gradle. To build it, use `./gradlew build`.
Alternatively, open the project directory in IntelliJ IDEA and use the IDE to build and run dokka.
Expand All @@ -24,6 +24,8 @@ Here's how to import and configure Dokka in IntelliJ IDEA:
message: "Error Loading Project: Cannot load 3 modules". Open up the details
of the error, and click "Remove Selected", as these module `.iml` files are
safe to remove.

## Using/testing locally built Dokka

If you want to use/test your locally built Dokka in a project, do the following:
1. Change `dokka_version` in `gradle.properties` to something that you will use later on as the dependency version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ enum class DokkaPublicationChannel {

fun isMavenRepository() = this == MAVEN_CENTRAL || this == MAVEN_CENTRAL_SNAPSHOT

fun isGradlePluginPortal() = this == GRADLE_PLUGIN_PORTAL

companion object {
fun fromPropertyString(value: String): DokkaPublicationChannel = when (value) {
"space-dokka-dev" -> SPACE_DOKKA_DEV
Expand Down
17 changes: 9 additions & 8 deletions buildSrc/src/main/kotlin/org/jetbrains/ValidatePublications.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.jetbrains
import org.gradle.api.DefaultTask
import org.gradle.api.GradleException
import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.ProjectDependency
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
Expand Down Expand Up @@ -33,9 +34,10 @@ open class ValidatePublications : DefaultTask() {
}

private fun checkProjectDependenciesArePublished(project: Project) {
val implementationDeps = project.configurations.findByName("implementation")?.allDependencies.orEmpty()
val apiDependencies = project.configurations.findByName("api")?.allDependencies.orEmpty()
val allDependencies = implementationDeps + apiDependencies
val implementationDependencies = project.findDependenciesByName("implementation")
val apiDependencies = project.findDependenciesByName("api")

val allDependencies = implementationDependencies + apiDependencies

allDependencies
.filterIsInstance<ProjectDependency>()
Expand All @@ -54,12 +56,11 @@ open class ValidatePublications : DefaultTask() {
}
}

private fun Project.assertPublicationVersion() {
val isVersionCheckEnabled = System.getenv("ENABLE_VERSION_CHECK").equals("true", ignoreCase = true)
if (!isVersionCheckEnabled) {
return
}
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 ->
acceptedVersionType == dokkaVersionType
Expand Down
4 changes: 4 additions & 0 deletions buildSrc/src/main/kotlin/org/jetbrains/publication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ fun Project.createDokkaPublishTaskIfNecessary() {
if (publicationChannels.any { it.isMavenRepository() }) {
dependsOn(tasks.named("publishToSonatype"))
}

if (publicationChannels.any { it.isGradlePluginPortal() }) {
dependsOn(tasks.named("publishPlugins"))
}
}
}

Expand Down

0 comments on commit 4628f67

Please sign in to comment.