Skip to content

Commit

Permalink
create kotlinDoc for publishing/android and publishing/core section
Browse files Browse the repository at this point in the history
  • Loading branch information
sliderzxc committed Dec 23, 2023
1 parent eaceb83 commit a5da081
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package com.sliderzxc.gradle.publishing.config

/**
* Data class representing the configuration for a developer.
*
* @property id The developer's ID.
* @property name The developer's name.
* @property email The developer's email.
* @property username The developer's username.
* @property password The developer's password.
*/
data class DeveloperConfig(
val id: String,
val name: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
package com.sliderzxc.gradle.publishing.config

/**
* Data class representing the configuration for a library to be published.
*
* @property group The group ID of the library.
* @property version The version of the library.
* @property name The name of the library.
* @property description The description of the library.
* @property url The URL of the library.
* @property scmUrl The SCM URL of the library.
* @property releaseRepository The repository for releasing stable versions.
* @property snapshotRepository The repository for releasing snapshot versions.
* @property licenseName The name of the license.
* @property licenseUrl The URL of the license.
* @property signingKey The signing key for artifacts.
* @property signingPassword The password for the signing key.
*/
data class LibraryConfig(
val group: String,
val version: String,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package com.sliderzxc.gradle.publishing.config

/**
* Data class representing the combined configuration for publishing a library.
*
* @property libraryConfig The configuration for the library.
* @property developerConfig The configuration for the developer.
*/
data class PublishingConfig(
val libraryConfig: LibraryConfig,
val developerConfig: DeveloperConfig
Expand Down
14 changes: 14 additions & 0 deletions src/main/kotlin/com/sliderzxc/gradle/publishing/javadoc/JavaDoc.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,28 @@ import org.gradle.api.Task
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.create

/**
* Ensures the existence of the Javadoc JAR task in the project. If the task already exists, it is returned.
* Otherwise, a new Javadoc JAR task is created and returned.
*
* @return The Javadoc JAR task.
*/
internal fun Project.ensureJavadocJarTask(): Task {
return tasks.findByName(JAVADOC_JAR_TASK_NAME) ?: createJavadocJarTask()
}

/**
* Creates a new Javadoc JAR task in the project.
*
* @return The newly created Javadoc JAR task.
*/
private fun Project.createJavadocJarTask(): Task {
return tasks.create<Jar>(JAVADOC_JAR_TASK_NAME).apply {
archiveClassifier.set("javadoc")
}
}

/**
* The name of the Javadoc JAR task.
*/
private const val JAVADOC_JAR_TASK_NAME = "javadocJar"
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.register

/**
* Configures the publishing settings for an Android library using the Maven Publish plugin.
*
* @param config The publishing configuration.
*/
internal fun Project.setupAndroidLibraryPublishing(config: PublishingConfig) {
applyMavenPublishPlugin()
applySigningPlugin()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import org.gradle.api.Project
import org.gradle.kotlin.dsl.findByType
import kotlin.reflect.KClass

/**
* Checks if the project has an extension of the specified type.
*
* @param clazz The class reference of the extension type.
* @return `true` if the project has an extension of the specified type, `false` otherwise.
*/
internal inline fun Project.hasExtension(clazz: () -> KClass<*>): Boolean {
return try {
extensions.findByType(clazz()) != null
Expand Down

0 comments on commit a5da081

Please sign in to comment.