diff --git a/src/main/kotlin/Poms.kt b/src/main/kotlin/Poms.kt deleted file mode 100644 index 735964f..0000000 --- a/src/main/kotlin/Poms.kt +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2025 Kazimierz Pogoda / Xemantic - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.xemantic.gradle.conventions - -import org.gradle.api.publish.maven.MavenPom - -fun MavenPom.setUpGitHubPomDetails( - project: String, - gitHubProject: String, - xemantic: XemanticGradleExtension, -) { - name.set(project) - description.set(xemantic.description) - url.set("https://github.com/${xemantic.gitHubAccount}/$gitHubProject") - inceptionYear.set(xemantic.inceptionYear.toString()) - organization { - name.set(xemantic.vendor) - url.set(xemantic.vendorUrl) - } - licenses { - license { - name.set(xemantic.license?.id) - url.set(xemantic.license?.url) - distribution.set("repo") - } - } - scm { - url.set("https://github.com/${xemantic.gitHubAccount}/$gitHubProject") - connection.set("scm:git:git:github.com/${xemantic.gitHubAccount}/$gitHubProject.git") - developerConnection.set("scm:git:https://github.com/${xemantic.gitHubAccount}/$gitHubProject.git") - } - ciManagement { - system.set("GitHub") - url.set("https://github.com/${xemantic.gitHubAccount}/${gitHubProject}/actions") - } - issueManagement { - system.set("GitHub") - url.set("https://github.com/${xemantic.gitHubAccount}/${gitHubProject}/issues") - } -// developers { devSpec -> -// xemantic.developers.forEach { dev -> -// devSpec.developer { -// it.id.set(dev.id) -// it.name.set(dev.name) -// it.email.set(dev.email) -// } -// } -// } -} diff --git a/src/main/kotlin/UpdateVersionInReadme.kt b/src/main/kotlin/UpdateVersionInReadme.kt deleted file mode 100644 index 16fa8fa..0000000 --- a/src/main/kotlin/UpdateVersionInReadme.kt +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2025 Kazimierz Pogoda / Xemantic - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.xemantic.gradle.conventions - -import org.gradle.api.DefaultTask -import org.gradle.api.GradleException -import org.gradle.api.tasks.TaskAction -import java.io.File -import javax.inject.Inject - -abstract class UpdateVersionInReadme @Inject constructor( - log: ((String) -> Unit)? -) : DefaultTask() { - - private val log: ((String) -> Unit) = log ?: { - logger.lifecycle(it) - } - - @TaskAction - fun action() { - val projectGroup = project.group.toString() - val projectName = project.name - val projectVersion = project.version.toString() - - val readmeFile = File(project.rootDir, "README.md") - if (!readmeFile.exists()) { - throw GradleException( - "README.md file not found in the project root directory." - ) - } - - val oldContent = readmeFile.readText() - val regex = Regex("($projectGroup:$projectName:)\\d+(\\.\\d+)*(-\\w+)?") - - if (!regex.containsMatchIn(oldContent)) { - throw GradleException( - "No matching dependency reference found in README.md. " + - "Expected format: $projectGroup:$projectName:x.y.z" - ) - } - - val updatedContent = oldContent.replace(regex, "$1$projectVersion") - - if (oldContent != updatedContent) { - readmeFile.writeText(updatedContent) - log("Successfully updated version in README.md to $projectVersion") - } else { - log("No update needed. Version in README.md is already $projectVersion") - } - } - -} diff --git a/src/main/kotlin/Jars.kt b/src/main/kotlin/internal/Jars.kt similarity index 87% rename from src/main/kotlin/Jars.kt rename to src/main/kotlin/internal/Jars.kt index b1604d6..dadce69 100644 --- a/src/main/kotlin/Jars.kt +++ b/src/main/kotlin/internal/Jars.kt @@ -14,14 +14,16 @@ * limitations under the License. */ -package com.xemantic.gradle.conventions +package com.xemantic.gradle.conventions.internal +import com.xemantic.gradle.conventions.xemantic import org.gradle.api.Project import org.gradle.api.tasks.bundling.Jar /** - * Each JAR file has also a manifest, and the manifest can contain additional - * information related to the vendor and the build. + * Populates JAR manifest with Xemantic-specific and build specific attributes. + * + * @param project the gradle project. */ internal fun Jar.populateJarManifest( project: Project, diff --git a/src/main/kotlin/ReplaceGradleDependencyVersion.kt b/src/main/kotlin/internal/ReplaceGradleDependencyVersion.kt similarity index 76% rename from src/main/kotlin/ReplaceGradleDependencyVersion.kt rename to src/main/kotlin/internal/ReplaceGradleDependencyVersion.kt index ac7ec31..4f10b04 100644 --- a/src/main/kotlin/ReplaceGradleDependencyVersion.kt +++ b/src/main/kotlin/internal/ReplaceGradleDependencyVersion.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.xemantic.gradle.conventions +package com.xemantic.gradle.conventions.internal /** * Replaces the version of a Gradle dependency in a string. @@ -33,14 +33,13 @@ package com.xemantic.gradle.conventions * @param newVersion The new version to set for the artifact. * @return A new string with the updated version for the specified artifact. */ -fun String.replaceGradleDependencyVersion( +internal fun String.replaceGradleDependencyVersion( artifact: String, newVersion: String -): String { - val regex = """"$artifact(-[^:]*)?:([^":]+)(:([^"]+))?"""".toRegex() - return this.replace(regex) { matchResult -> - val (variant, _, _, classifier) = matchResult.destructured - val classifierPart = if (classifier.isNotEmpty()) ":$classifier" else "" - """"$artifact$variant:$newVersion$classifierPart"""" - } +): String = replace( + """"$artifact(-[^:]*)?:([^":]+)(:([^"]+))?"""".toRegex() +) { matchResult -> + val (variant, _, _, classifier) = matchResult.destructured + val classifierPart = if (classifier.isNotEmpty()) ":$classifier" else "" + """"$artifact$variant:$newVersion$classifierPart"""" } diff --git a/src/main/kotlin/Signing.kt b/src/main/kotlin/internal/Signing.kt similarity index 72% rename from src/main/kotlin/Signing.kt rename to src/main/kotlin/internal/Signing.kt index e0dc771..a06a587 100644 --- a/src/main/kotlin/Signing.kt +++ b/src/main/kotlin/internal/Signing.kt @@ -14,12 +14,19 @@ * limitations under the License. */ -package com.xemantic.gradle.conventions +package com.xemantic.gradle.conventions.internal +import com.xemantic.gradle.conventions.XemanticConfiguration import org.gradle.api.publish.PublishingExtension import org.gradle.plugins.signing.SigningExtension -public fun SigningExtension.xemanticSigning( +/** + * Configures signing of maven publications. + * + * @param xemantic the Xemantic configuration instance. + * @param publishing the publishing gradle extension to retrieve publication list from. + */ +internal fun SigningExtension.xemanticSigning( xemantic: XemanticConfiguration, publishing: PublishingExtension ) { diff --git a/src/main/kotlin/TestLogging.kt b/src/main/kotlin/internal/TestLogging.kt similarity index 93% rename from src/main/kotlin/TestLogging.kt rename to src/main/kotlin/internal/TestLogging.kt index 105770a..40b28c4 100644 --- a/src/main/kotlin/TestLogging.kt +++ b/src/main/kotlin/internal/TestLogging.kt @@ -14,7 +14,7 @@ * limitations under the License. */ -package com.xemantic.gradle.conventions +package com.xemantic.gradle.conventions.internal import org.gradle.api.tasks.testing.Test import org.gradle.api.tasks.testing.logging.TestExceptionFormat @@ -27,7 +27,7 @@ import org.gradle.api.tasks.testing.logging.TestLogEvent * convenient for digestion of not only a human, but also an AI agent performing the * build and the analysis of possible build failures. */ -fun Test.xemanticTestLogging() { +internal fun Test.xemanticTestLogging() { testLogging { events( TestLogEvent.SKIPPED,