Skip to content

Commit

Permalink
Replace buildSrc by includedBuild and update project urls
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisCAD committed Nov 21, 2023
1 parent 15c36e7 commit 882f3c8
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 76 deletions.
5 changes: 0 additions & 5 deletions buildSrc/src/main/kotlin/Property.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
gradlePluginPortal()
}

fun plugin(id: String, version: String) = "$id:$id.gradle.plugin:$version"

dependencies {
Expand Down
7 changes: 7 additions & 0 deletions convention-plugins/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dependencyResolutionManagement {
@Suppress("UnstableApiUsage")
repositories {
mavenCentral()
gradlePluginPortal()
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import org.gradle.api.Project

fun Project.propertyOrEnv(key: String): String {
internal fun Project.propertyOrEnv(key: String): String {
return findProperty(key) as String?
?: System.getenv(key)
?: error("Didn't find any value for the key \"$key\" in Project properties or environment variables.")
}

fun Project.propertyOrEnvOrNull(key: String): String? {
internal fun Project.propertyOrEnvOrNull(key: String): String? {
return findProperty(key) as String? ?: System.getenv(key)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ plugins {
dependencies {
compileOnly(gradleKotlinDsl())
}

gradlePlugin {
vcsUrl = Publishing.gitUrl
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,55 @@ import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.tasks.TaskContainer
import org.gradle.api.tasks.TaskProvider
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.assign
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.register

object Publishing {
const val gitUrl = "https://github.com/LouisCAD/LibPublishingHelpers.git"
const val siteUrl = "https://github.com/LouisCAD/LibPublishingHelpers"
internal object Publishing {
const val gitUrl = "https://github.com/Splitties/LibPublishingHelpers.git"
const val siteUrl = "https://github.com/Splitties/LibPublishingHelpers"
const val libraryDesc = "Tools for semi-auto library publishing (and other chores). Designed for Kotlin scripts."
}

fun TaskContainer.emptyJavadocJar(): TaskProvider<Jar> {
internal fun TaskContainer.emptyJavadocJar(): TaskProvider<Jar> {
val taskName = "javadocJar"
return try {
named(name = taskName)
} catch (e: UnknownTaskException) {
register(name = taskName) { archiveClassifier by "javadoc" }
register(name = taskName) { archiveClassifier = "javadoc" }
}
}

fun MavenPublication.setupPom(
internal fun MavenPublication.setupPom(
gitUrl: String = Publishing.gitUrl,
siteUrl: String = Publishing.siteUrl,
libraryDesc: String = Publishing.libraryDesc
) = pom {
if (name.isPresent.not()) {
name by artifactId
name = artifactId
}
description by libraryDesc
url by siteUrl
description = libraryDesc
url = siteUrl
licenses {
license {
name by "The Apache Software License, Version 2.0"
url by "https://www.apache.org/licenses/LICENSE-2.0.txt"
name = "The Apache Software License, Version 2.0"
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id by "louiscad"
name by "Louis CAD"
email by "[email protected]"
id = "louiscad"
name = "Louis CAD"
email = "[email protected]"
}
}
scm {
connection by gitUrl
developerConnection by gitUrl
url by siteUrl
connection = gitUrl
developerConnection = gitUrl
url = siteUrl
}
if (gitUrl.startsWith("https://github.com")) issueManagement {
system by "GitHub"
url by gitUrl.replace(".git", "/issues")
system = "GitHub"
url = gitUrl.replace(".git", "/issues")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import propertyOrEnv
import propertyOrEnvOrNull

context (Project)
fun SigningExtension.trySignAll() {
internal fun SigningExtension.trySignAll() {
useInMemoryPgpKeys(
propertyOrEnvOrNull("GPG_key_id"), // If using a sub-key.
propertyOrEnvOrNull("GPG_key_id"), // If targeting a sub-key from an exported primary key.
propertyOrEnvOrNull("GPG_private_key") ?: return,
propertyOrEnv("GPG_private_password")
)
Expand Down
5 changes: 2 additions & 3 deletions gradle-plugins/settings-include-dsl/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
plugins {
`gradle-plugin`
id("gradle-plugin")
`kotlin-dsl`
}

group = "org.splitties.gradle"

gradlePlugin {
website = "https://github.com/LouisCAD/LibPublishingHelpers/tree/main/gradle-plugins/settings-include-dsl"
vcsUrl = "https://github.com/LouisCAD/LibPublishingHelpers.git"
website = "https://github.com/Splitties/LibPublishingHelpers/tree/main/gradle-plugins/settings-include-dsl"
plugins {
create(project.name) {
id = "org.splitties.settings-include-dsl"
Expand Down
5 changes: 2 additions & 3 deletions gradle-plugins/version-sync/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
plugins {
`gradle-plugin`
id("gradle-plugin")
`kotlin-dsl`
}

group = "org.splitties.gradle"

gradlePlugin {
website = "https://github.com/LouisCAD/LibPublishingHelpers/tree/main/gradle-plugins/version-sync"
vcsUrl = "https://github.com/LouisCAD/LibPublishingHelpers.git"
website = "https://github.com/Splitties/LibPublishingHelpers/tree/main/gradle-plugins/version-sync"
plugins {
create(project.name) {
id = "org.splitties.version-sync"
Expand Down
2 changes: 1 addition & 1 deletion lib-publishing-helpers/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
`kotlin-jvm-lib`
id("kotlin-jvm-lib")
}

group = "com.louiscad.incubator"
49 changes: 13 additions & 36 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
rootProject.name = "LibPublishingHelpers"

dependencyResolutionManagement {
pluginManagement {
includeBuild("convention-plugins")
repositories {
gradlePluginPortal()
mavenCentral()
}
}

val versionOfThisProject: String = file("version.txt").bufferedReader().use { it.readLine() }
plugins {
id("org.splitties.settings-include-dsl") version "0.2.6"
id("org.splitties.version-sync") version "0.2.6"
}

gradle.beforeProject {
version = versionOfThisProject
rootProject.name = "LibPublishingHelpers"

dependencyResolutionManagement {
repositories {
mavenCentral()
}
}

include {
Expand All @@ -19,33 +26,3 @@ include {
"version-sync"()
}
}

//region include DSL
class ModuleParentScope(
private val name: String,
private val parent: ModuleParentScope? = null
) {

operator fun String.invoke(block: (ModuleParentScope.() -> Unit)? = null) {
check(startsWith(':').not())
val moduleName = ":$this"
val projectName = "$parentalPath$moduleName"
include(projectName)
block?.let { buildNode ->
ModuleParentScope(
name = moduleName,
parent = this@ModuleParentScope
).buildNode()
}
}

private val parentalPath: String =
generateSequence(this) { it.parent }
.map { it.name }.toList().reversed().joinToString("")

}

inline fun include(block: ModuleParentScope.() -> Unit) {
ModuleParentScope("").block()
}
//endregion

0 comments on commit 882f3c8

Please sign in to comment.