From 1bdc5c4b6241db55f75470ec94c6f64daa0dfb10 Mon Sep 17 00:00:00 2001 From: Danilo Pianini Date: Mon, 2 Dec 2024 18:02:40 +0100 Subject: [PATCH] chore(deps)!: update plugin kotlin-qa to v0.75.0, use SCREAMING_SNAKE_CASE for `MAVEN_CENTRAL_NAME`, `MAVEN_CENTRAL_URL`, and `MAVEN_CENTRAL_NEXUS_URL` --- build.gradle.kts | 24 +-- gradle/libs.versions.toml | 2 +- .../gradle/mavencentral/DokkaHelper.kt | 12 +- .../mavencentral/InitializeNexusClient.kt | 56 +++---- .../mavencentral/NexusStatefulOperation.kt | 5 +- .../gradle/mavencentral/ProjectExtensions.kt | 150 ++++++++++-------- .../gradle/mavencentral/PublishOnCentral.kt | 35 ++-- .../mavencentral/PublishOnCentralExtension.kt | 53 ++++--- .../gradle/mavencentral/Repository.kt | 13 +- .../gradle/mavencentral/SourceJar.kt | 5 +- 10 files changed, 194 insertions(+), 161 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a22eec30..fe838cf9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,6 +17,7 @@ gitSemVer { } group = "org.danilopianini" + inner class ProjectInfo { val longName = "Gradle Publish On Maven Central Plugin" val projectDetails = "A Plugin for easily publishing artifacts on Maven Central" @@ -130,20 +131,21 @@ if (System.getenv("CI") == true.toString()) { } } -val registerCredentials = tasks.register("registerGradlePluginPortalCredentials") { - doLast { - listOf("gradle.publish.key", "gradle.publish.secret").forEach { - if (!(project.hasProperty(it) or System.getenv().containsKey(it))) { - val bashName = it.uppercase().replace(".", "_") - System.getProperties().setProperty( - it, - System.getenv(bashName) - ?: error("Property $it is unset and environment variable $bashName unavailable"), - ) +val registerCredentials = + tasks.register("registerGradlePluginPortalCredentials") { + doLast { + listOf("gradle.publish.key", "gradle.publish.secret").forEach { + if (!(project.hasProperty(it) or System.getenv().containsKey(it))) { + val bashName = it.uppercase().replace(".", "_") + System.getProperties().setProperty( + it, + System.getenv(bashName) + ?: error("Property $it is unset and environment variable $bashName unavailable"), + ) + } } } } -} tasks.publishPlugins { dependsOn(registerCredentials) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index acd5a893..7a31ebc6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -22,7 +22,7 @@ dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" } gitSemVer = "org.danilopianini.git-sensitive-semantic-versioning:3.1.7" gradlePluginPublish = "com.gradle.plugin-publish:1.3.0" kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } -kotlin-qa = "org.danilopianini.gradle-kotlin-qa:0.70.2" +kotlin-qa = "org.danilopianini.gradle-kotlin-qa:0.75.0" multiJvmTesting = "org.danilopianini.multi-jvm-test-plugin:1.3.2" nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version.ref = "nexus-publish" } publishOnCentral = "org.danilopianini.publish-on-central:5.1.11" diff --git a/src/main/kotlin/org/danilopianini/gradle/mavencentral/DokkaHelper.kt b/src/main/kotlin/org/danilopianini/gradle/mavencentral/DokkaHelper.kt index d63ab140..31fc2d8f 100644 --- a/src/main/kotlin/org/danilopianini/gradle/mavencentral/DokkaHelper.kt +++ b/src/main/kotlin/org/danilopianini/gradle/mavencentral/DokkaHelper.kt @@ -35,8 +35,10 @@ internal fun Project.dokkaTasksFor(docStyle: DocStyle): TaskCollection * If a task is of type `DokkaTask` (cf. [isDokkaTask]), then retrieves the value of its `outputDirectory` * property, if any. */ -internal val Task.dokkaOutputDirectory: Any get() = when { - isDokkaTask -> property("outputDirectory") - ?: error("$name has no property 'outputDirectory': Dokka version incompatible with publish-on-central?") - else -> error("$name is not of type $DOKKA_TASK_CLASS_NAME") -} +internal val Task.dokkaOutputDirectory: Any get() = + when { + isDokkaTask -> + property("outputDirectory") + ?: error("$name has no property 'outputDirectory': Dokka version incompatible with publish-on-central?") + else -> error("$name is not of type $DOKKA_TASK_CLASS_NAME") + } diff --git a/src/main/kotlin/org/danilopianini/gradle/mavencentral/InitializeNexusClient.kt b/src/main/kotlin/org/danilopianini/gradle/mavencentral/InitializeNexusClient.kt index 54df6cef..22377338 100644 --- a/src/main/kotlin/org/danilopianini/gradle/mavencentral/InitializeNexusClient.kt +++ b/src/main/kotlin/org/danilopianini/gradle/mavencentral/InitializeNexusClient.kt @@ -9,32 +9,34 @@ import javax.inject.Inject /** * A task that creates a Nexus Client operating at the [Repository] [repoToConfigure] with URL [nexusUrl]. */ -open class InitializeNexusClient @Inject constructor( - @Input - val repoToConfigure: Repository, - @Input - val nexusUrl: String, -) : DefaultTask() { +open class InitializeNexusClient + @Inject + constructor( + @Input + val repoToConfigure: Repository, + @Input + val nexusUrl: String, + ) : DefaultTask() { + /** + * The Nexus Client, accessible only **after** the execution of the task. + */ + @Internal + lateinit var nexusClient: NexusStatefulOperation - /** - * The Nexus Client, accessible only **after** the execution of the task. - */ - @Internal - lateinit var nexusClient: NexusStatefulOperation - - /** - * Initializes the Nexus Client. - */ - @TaskAction - fun initializeClient() { - nexusClient = NexusStatefulOperation( - project = project, - nexusUrl = nexusUrl, - group = project.group.toString(), - user = repoToConfigure.user, - password = repoToConfigure.password, - timeOut = repoToConfigure.nexusTimeOut, - connectionTimeOut = repoToConfigure.nexusConnectTimeOut, - ) + /** + * Initializes the Nexus Client. + */ + @TaskAction + fun initializeClient() { + nexusClient = + NexusStatefulOperation( + project = project, + nexusUrl = nexusUrl, + group = project.group.toString(), + user = repoToConfigure.user, + password = repoToConfigure.password, + timeOut = repoToConfigure.nexusTimeOut, + connectionTimeOut = repoToConfigure.nexusConnectTimeOut, + ) + } } -} diff --git a/src/main/kotlin/org/danilopianini/gradle/mavencentral/NexusStatefulOperation.kt b/src/main/kotlin/org/danilopianini/gradle/mavencentral/NexusStatefulOperation.kt index 7c817ad4..84e045a0 100644 --- a/src/main/kotlin/org/danilopianini/gradle/mavencentral/NexusStatefulOperation.kt +++ b/src/main/kotlin/org/danilopianini/gradle/mavencentral/NexusStatefulOperation.kt @@ -27,7 +27,6 @@ data class NexusStatefulOperation( private val connectionTimeOut: Duration, private val group: String, ) { - /** * Repository description. */ @@ -83,7 +82,7 @@ data class NexusStatefulOperation( private val transitioner by lazy { StagingRepositoryTransitioner( client, - BasicActionRetrier(Int.MAX_VALUE, Duration.ofSeconds(retryInterval)) { it.transitioning }, + BasicActionRetrier(Int.MAX_VALUE, Duration.ofSeconds(RETRY_INTERVAL)) { it.transitioning }, ) } @@ -129,6 +128,6 @@ data class NexusStatefulOperation( } private companion object { - private const val retryInterval: Long = 10 + private const val RETRY_INTERVAL: Long = 10 } } diff --git a/src/main/kotlin/org/danilopianini/gradle/mavencentral/ProjectExtensions.kt b/src/main/kotlin/org/danilopianini/gradle/mavencentral/ProjectExtensions.kt index 12345871..7db9d10e 100644 --- a/src/main/kotlin/org/danilopianini/gradle/mavencentral/ProjectExtensions.kt +++ b/src/main/kotlin/org/danilopianini/gradle/mavencentral/ProjectExtensions.kt @@ -25,7 +25,6 @@ import java.net.URI import kotlin.reflect.KClass internal object ProjectExtensions { - /** * The id of the Kotlin/JS plugin. */ @@ -105,86 +104,97 @@ internal object ProjectExtensions { } } - private fun Project.configureNexusRepository(repoToConfigure: Repository, nexusUrl: String) { + private fun Project.configureNexusRepository( + repoToConfigure: Repository, + nexusUrl: String, + ) { val repoName = repoToConfigure.name - val nexusClient = rootProject.registerTaskIfNeeded( - "createNexusClientFor$repoName", - InitializeNexusClient::class, - repoToConfigure, - nexusUrl, - ) as InitializeNexusClient + val nexusClient = + rootProject.registerTaskIfNeeded( + "createNexusClientFor$repoName", + InitializeNexusClient::class, + repoToConfigure, + nexusUrl, + ) as InitializeNexusClient /* * Creates a new staging repository on the Nexus server, or fetches an existing one if the repoId is known. */ - val createStagingRepository = rootProject.registerTaskIfNeeded( - "createStagingRepositoryOn$repoName", - ) { - val stagingRepoIdsFileName = "staging-repo-ids.properties" - val stagingRepoIdsFile = rootProject.layout.buildDirectory.map { it.asFile.resolve(stagingRepoIdsFileName) } - outputs.file(stagingRepoIdsFile) - dependsOn(nexusClient) - doLast { - rootProject.warnIfCredentialsAreMissing(repoToConfigure) - nexusClient.nexusClient.repoUrl // triggers the initialization of a repository - val repoId = nexusClient.nexusClient.repoId - // Write the staging repository ID to build/staging-repo-ids.properties file - stagingRepoIdsFile.get().appendText("$repoName=$repoId" + System.lineSeparator()) - logger.lifecycle("Append repo name {} to file {}", repoId, stagingRepoIdsFile.get().path) + val createStagingRepository = + rootProject.registerTaskIfNeeded( + "createStagingRepositoryOn$repoName", + ) { + val stagingRepoIdsFileName = "staging-repo-ids.properties" + val stagingRepoIdsFile = + rootProject.layout.buildDirectory.map { it.asFile.resolve(stagingRepoIdsFileName) } + outputs.file(stagingRepoIdsFile) + dependsOn(nexusClient) + doLast { + rootProject.warnIfCredentialsAreMissing(repoToConfigure) + nexusClient.nexusClient.repoUrl // triggers the initialization of a repository + val repoId = nexusClient.nexusClient.repoId + // Write the staging repository ID to build/staging-repo-ids.properties file + stagingRepoIdsFile.get().appendText("$repoName=$repoId" + System.lineSeparator()) + logger.lifecycle("Append repo name {} to file {}", repoId, stagingRepoIdsFile.get().path) + } + group = PublishingPlugin.PUBLISH_TASK_GROUP + description = "Creates a new Nexus staging repository on $repoName." } - group = PublishingPlugin.PUBLISH_TASK_GROUP - description = "Creates a new Nexus staging repository on $repoName." - } /* * Collector of all upload tasks. Actual uploads are defined at the bottom. * Requires the creation of the staging repository. */ - val uploadAllPublications = tasks.register("uploadAllPublicationsTo${repoName}Nexus") { - it.dependsOn(createStagingRepository) - it.group = PublishingPlugin.PUBLISH_TASK_GROUP - it.description = "Uploads all publications to a staging repository on $repoName." - } + val uploadAllPublications = + tasks.register("uploadAllPublicationsTo${repoName}Nexus") { + it.dependsOn(createStagingRepository) + it.group = PublishingPlugin.PUBLISH_TASK_GROUP + it.description = "Uploads all publications to a staging repository on $repoName." + } /* * Closes the staging repository. If it's closed already, skips the operation. * Runs after all uploads. Requires the creation of the staging repository. */ - val closeStagingRepository = rootProject.registerTaskIfNeeded("closeStagingRepositoryOn$repoName") { - doLast { - with(nexusClient.nexusClient) { - when (client.getStagingRepositoryStateById(repoId).state) { - CLOSED -> logger.warn("The staging repository is already closed. Skipping.") - else -> close() + val closeStagingRepository = + rootProject.registerTaskIfNeeded("closeStagingRepositoryOn$repoName") { + doLast { + with(nexusClient.nexusClient) { + when (client.getStagingRepositoryStateById(repoId).state) { + CLOSED -> logger.warn("The staging repository is already closed. Skipping.") + else -> close() + } } } + dependsOn(createStagingRepository) + mustRunAfter(uploadAllPublications) + group = PublishingPlugin.PUBLISH_TASK_GROUP + description = "Closes the Nexus repository on $repoName." } - dependsOn(createStagingRepository) - mustRunAfter(uploadAllPublications) - group = PublishingPlugin.PUBLISH_TASK_GROUP - description = "Closes the Nexus repository on $repoName." - } /* * Releases the staging repository. Requires closing. */ - val release = rootProject.registerTaskIfNeeded("releaseStagingRepositoryOn${repoToConfigure.name}") { - doLast { nexusClient.nexusClient.release() } - dependsOn(closeStagingRepository) - group = PublishingPlugin.PUBLISH_TASK_GROUP - description = "Releases the Nexus repo on ${repoToConfigure.name}. " + - "Mutually exclusive with dropStagingRepositoryOn${repoToConfigure.name}." - } + val release = + rootProject.registerTaskIfNeeded("releaseStagingRepositoryOn${repoToConfigure.name}") { + doLast { nexusClient.nexusClient.release() } + dependsOn(closeStagingRepository) + group = PublishingPlugin.PUBLISH_TASK_GROUP + description = "Releases the Nexus repo on ${repoToConfigure.name}. " + + "Mutually exclusive with dropStagingRepositoryOn${repoToConfigure.name}." + } /* * Drops the staging repository. * Requires the creation of the staging repository. * It must run after all uploads. * If closing is requested as well, drop must run after it. */ - val drop = rootProject.registerTaskIfNeeded("dropStagingRepositoryOn${repoToConfigure.name}") { - doLast { nexusClient.nexusClient.drop() } - dependsOn(createStagingRepository) - mustRunAfter(uploadAllPublications) - mustRunAfter(closeStagingRepository) - group = PublishingPlugin.PUBLISH_TASK_GROUP - description = "Drops the Nexus repo on ${repoToConfigure.name}. Incompatible with releasing the same repo." - } + val drop = + rootProject.registerTaskIfNeeded("dropStagingRepositoryOn${repoToConfigure.name}") { + doLast { nexusClient.nexusClient.drop() } + dependsOn(createStagingRepository) + mustRunAfter(uploadAllPublications) + mustRunAfter(closeStagingRepository) + group = PublishingPlugin.PUBLISH_TASK_GROUP + description = + "Drops the Nexus repo on ${repoToConfigure.name}. Incompatible with releasing the same repo." + } /* * Checks that only release or drop are selected for execution, as they are mutually exclusive. */ @@ -198,14 +208,15 @@ internal object ProjectExtensions { project.tasks.register( "upload${publicationName}To${repoToConfigure.name}Nexus", ).configure { uploadTask -> - uploadTask.repository = project.repositories.maven { repo -> - repo.name = repoToConfigure.name - repo.url = project.uri(repoToConfigure.url) - repo.credentials { - it.username = repoToConfigure.user.orNull - it.password = repoToConfigure.password.orNull + uploadTask.repository = + project.repositories.maven { repo -> + repo.name = repoToConfigure.name + repo.url = project.uri(repoToConfigure.url) + repo.credentials { + it.username = repoToConfigure.user.orNull + it.password = repoToConfigure.password.orNull + } } - } uploadTask.publication = publication publication.signingTasks(project).forEach { uploadTask.dependsOn(it) } tasks.withType().forEach { uploadTask.mustRunAfter(it) } @@ -247,12 +258,13 @@ internal object ProjectExtensions { name: String, vararg parameters: Any = emptyArray(), configuration: DefaultTask.() -> Unit = { }, - ): Task = registerTaskIfNeeded( - name = name, - type = DefaultTask::class, - parameters = parameters, - configuration = configuration, - ) + ): Task = + registerTaskIfNeeded( + name = name, + type = DefaultTask::class, + parameters = parameters, + configuration = configuration, + ) private fun Project.warnIfCredentialsAreMissing(repository: Repository) { if (repository.user.orNull == null) { diff --git a/src/main/kotlin/org/danilopianini/gradle/mavencentral/PublishOnCentral.kt b/src/main/kotlin/org/danilopianini/gradle/mavencentral/PublishOnCentral.kt index 78899396..1a57ab95 100644 --- a/src/main/kotlin/org/danilopianini/gradle/mavencentral/PublishOnCentral.kt +++ b/src/main/kotlin/org/danilopianini/gradle/mavencentral/PublishOnCentral.kt @@ -28,15 +28,18 @@ import org.gradle.plugins.signing.SigningPlugin * A Plugin configuring the project for publishing on Maven Central. */ class PublishOnCentral : Plugin { - private companion object { /** * The name of the publication to be created. */ - private const val publicationName = "OSSRH" + private const val PUBLICATION_NAME = "OSSRH" } - private fun addSourcesArtifactIfNeeded(project: Project, publication: MavenPublication, sourcesJarTask: Task) { + private fun addSourcesArtifactIfNeeded( + project: Project, + publication: MavenPublication, + sourcesJarTask: Task, + ) { if (sourcesJarTask is SourceJar) { if (project.jsSourcesJar == null) { publication.artifact(sourcesJarTask) @@ -69,7 +72,11 @@ class PublishOnCentral : Plugin { } } - private fun addJavadocArtifactIfNeeded(project: Project, publication: MavenPublication, javadocJarTask: Task) { + private fun addJavadocArtifactIfNeeded( + project: Project, + publication: MavenPublication, + javadocJarTask: Task, + ) { if (javadocJarTask is JavadocJar) { publication.artifact(javadocJarTask) project.logger.info( @@ -92,7 +99,7 @@ class PublishOnCentral : Plugin { } project.components.configureEach { component -> publications { publications -> - val name = "${component.name}$publicationName" + val name = "${component.name}$PUBLICATION_NAME" if (publications.none { it.name == name }) { publications.create(name, MavenPublication::class.java) { publication -> createdPublications += publication @@ -130,9 +137,10 @@ class PublishOnCentral : Plugin { } project.plugins.withType().configureEach { _ -> project.tasks.withType().configureEach { javadocJar -> - val javadocTask = checkNotNull(project.tasks.findByName("javadoc") as? Javadoc) { - "Java plugin applied but no Javadoc task existing!" - } + val javadocTask = + checkNotNull(project.tasks.findByName("javadoc") as? Javadoc) { + "Java plugin applied but no Javadoc task existing!" + } javadocJar.dependsOn(javadocTask) javadocJar.from(javadocTask.destinationDir) } @@ -143,11 +151,12 @@ class PublishOnCentral : Plugin { project.tasks.withType(JavadocJar::class.java).configureEach { javadocJar -> val message = "configure ${javadocJar.name} task to depend on Dokka task" project.logger.info("Lazily $message") - val dokkaTask = extension.docStyle.map { docStyle -> - project.dokkaTasksFor(docStyle).firstOrNull() - ?.also { project.logger.info("Actually $message ${it.name}") } - ?: error("Dokka plugin applied but no task exists for style $docStyle!") - } + val dokkaTask = + extension.docStyle.map { docStyle -> + project.dokkaTasksFor(docStyle).firstOrNull() + ?.also { project.logger.info("Actually $message ${it.name}") } + ?: error("Dokka plugin applied but no task exists for style $docStyle!") + } javadocJar.dependsOn(dokkaTask) javadocJar.from(dokkaTask.map { it.dokkaOutputDirectory }) } diff --git a/src/main/kotlin/org/danilopianini/gradle/mavencentral/PublishOnCentralExtension.kt b/src/main/kotlin/org/danilopianini/gradle/mavencentral/PublishOnCentralExtension.kt index a8b51a00..828aaabd 100644 --- a/src/main/kotlin/org/danilopianini/gradle/mavencentral/PublishOnCentralExtension.kt +++ b/src/main/kotlin/org/danilopianini/gradle/mavencentral/PublishOnCentralExtension.kt @@ -13,7 +13,6 @@ import java.time.Duration * The extension in charge of configuring the publish-on-central plugin on the target [project]. */ open class PublishOnCentralExtension(val project: Project) { - /** * Whether the plugin should consider all MavenPublications as potentially deliverable on Maven Central, * and should thus configure them appropriately. @@ -25,25 +24,28 @@ open class PublishOnCentralExtension(val project: Project) { /** * Easier access to the default Maven Central configuration. */ - val mavenCentral: Repository = Repository( - Repository.mavenCentralName, - url = project.propertyWithDefaultProvider { Repository.mavenCentralURL }, - user = project.propertyWithDefaultProvider { - System.getenv("MAVEN_CENTRAL_USERNAME") - ?: project.properties["mavenCentralUsername"]?.toString() - ?: project.properties["sonatypeUsername"]?.toString() - ?: project.properties["ossrhUsername"]?.toString() - }, - password = project.propertyWithDefaultProvider { - System.getenv("MAVEN_CENTRAL_PASSWORD") - ?: project.properties["mavenCentralPassword"]?.toString() - ?: project.properties["sonatypePassword"]?.toString() - ?: project.properties["ossrhPassword"]?.toString() - }, - nexusUrl = Repository.mavenCentralNexusUrl, - nexusTimeOut = @Suppress("MagicNumber") Duration.ofMinutes(5), - nexusConnectTimeOut = Duration.ofMinutes(3), - ) + val mavenCentral: Repository = + Repository( + Repository.MAVEN_CENTRAL_NAME, + url = project.propertyWithDefaultProvider { Repository.MAVEN_CENTRAL_URL }, + user = + project.propertyWithDefaultProvider { + System.getenv("MAVEN_CENTRAL_USERNAME") + ?: project.properties["mavenCentralUsername"]?.toString() + ?: project.properties["sonatypeUsername"]?.toString() + ?: project.properties["ossrhUsername"]?.toString() + }, + password = + project.propertyWithDefaultProvider { + System.getenv("MAVEN_CENTRAL_PASSWORD") + ?: project.properties["mavenCentralPassword"]?.toString() + ?: project.properties["sonatypePassword"]?.toString() + ?: project.properties["ossrhPassword"]?.toString() + }, + nexusUrl = Repository.MAVEN_CENTRAL_NEXUS_URL, + nexusTimeOut = @Suppress("MagicNumber") Duration.ofMinutes(5), + nexusConnectTimeOut = Duration.ofMinutes(3), + ) /** * The full project name. @@ -79,14 +81,16 @@ open class PublishOnCentralExtension(val project: Project) { /** * The SCM connection of the project. */ - val scmConnection: Property = project.objects.property() - .convention(repoOwner.map { "scm:git:https://github.com/$it/${project.name}" }) + val scmConnection: Property = + project.objects.property() + .convention(repoOwner.map { "scm:git:https://github.com/$it/${project.name}" }) /** * The URL of the project. */ - val projectUrl: Property = project.objects.property() - .convention(repoOwner.map { "https://github.com/$it/${project.name}" }) + val projectUrl: Property = + project.objects.property() + .convention(repoOwner.map { "https://github.com/$it/${project.name}" }) /** * The style of `javadoc` artifacts being published on Maven repositories. @@ -120,7 +124,6 @@ open class PublishOnCentralExtension(val project: Project) { } private companion object { - private val extractName = Regex(""".*://(?:\w+\.)*(\w+)\.\w+(?:/.*)?""") private fun repositoryNameFromURL(url: String) = extractName.find(url)?.destructured?.component1() ?: "unknown" diff --git a/src/main/kotlin/org/danilopianini/gradle/mavencentral/Repository.kt b/src/main/kotlin/org/danilopianini/gradle/mavencentral/Repository.kt index 6819f1e0..dcfc0f67 100644 --- a/src/main/kotlin/org/danilopianini/gradle/mavencentral/Repository.kt +++ b/src/main/kotlin/org/danilopianini/gradle/mavencentral/Repository.kt @@ -21,7 +21,6 @@ data class Repository( val nexusTimeOut: Duration = Duration.ofMinutes(1), val nexusConnectTimeOut: Duration = Duration.ofMinutes(1), ) { - /** * Same as [name], but capitalized. */ @@ -33,26 +32,28 @@ data class Repository( * Constants and utility functions. */ companion object { - /** * The default name of the Maven Central repository. */ - const val mavenCentralName = "MavenCentral" + const val MAVEN_CENTRAL_NAME = "MavenCentral" /** * The default URL of Maven Central. */ - const val mavenCentralURL = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" + const val MAVEN_CENTRAL_URL = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/" /** * The Sonatype Nexus instance URL of Maven Central. */ - const val mavenCentralNexusUrl = "https://s01.oss.sonatype.org/service/local/" + const val MAVEN_CENTRAL_NEXUS_URL = "https://s01.oss.sonatype.org/service/local/" /** * Creates a named [Repository] from a [project] and a [name]. */ - fun fromProject(project: Project, name: String): Repository = + fun fromProject( + project: Project, + name: String, + ): Repository = Repository( name = name, url = project.objects.property(), diff --git a/src/main/kotlin/org/danilopianini/gradle/mavencentral/SourceJar.kt b/src/main/kotlin/org/danilopianini/gradle/mavencentral/SourceJar.kt index 833cb09c..fb0ce3e6 100644 --- a/src/main/kotlin/org/danilopianini/gradle/mavencentral/SourceJar.kt +++ b/src/main/kotlin/org/danilopianini/gradle/mavencentral/SourceJar.kt @@ -19,7 +19,10 @@ open class SourceJar : JarWithClassifier("sources") { * In case the source set does not exist, if [failOnMissingName] is set, the task throws [IllegalStateException]. */ @JvmOverloads - fun sourceSet(name: String, failOnMissingName: Boolean = true) { + fun sourceSet( + name: String, + failOnMissingName: Boolean = true, + ) { val sourceSets = project.properties["sourceSets"] as? SourceSetContainer if (sourceSets != null) { val sourceSet = sourceSets.findByName(name)