-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from kitakkun/refactor_buildscripts
Refactor buildscripts
- Loading branch information
Showing
16 changed files
with
167 additions
and
174 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
76 changes: 0 additions & 76 deletions
76
...vention/src/main/kotlin/com/kitakkun/backintime/convention/BackInTimePublicationPlugin.kt
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
...gic/convention/src/main/kotlin/com/kitakkun/backintime/convention/LintConventionPlugin.kt
This file was deleted.
Oops, something went wrong.
5 changes: 0 additions & 5 deletions
5
...ain/kotlin/com/kitakkun/backintime/convention/extension/BackInTimePublicationExtension.kt
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
...-logic/convention/src/main/kotlin/com/kitakkun/backintime/convention/extension/Project.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
rootProject.name = "gradle-conventions-settings" | ||
|
||
apply(from = "src/main/kotlin/settings-conventions.settings.gradle.kts") |
53 changes: 53 additions & 0 deletions
53
gradle-conventions-settings/src/main/kotlin/settings-conventions.settings.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import java.nio.file.Files | ||
import java.nio.file.Path | ||
|
||
/** | ||
* This buildscript can be applied with id "settings-conventions" in plugins block. | ||
* (note that you need to includeBuild before use it) | ||
* | ||
* This file is written referencing kotlinx-rpc project: | ||
* https://github.com/Kotlin/kotlinx-rpc/blob/main/gradle-conventions-settings/src/main/kotlin/settings-conventions.settings.gradle.kts | ||
*/ | ||
|
||
pluginManagement { | ||
repositories { | ||
mavenCentral() | ||
gradlePluginPortal() | ||
google() | ||
} | ||
} | ||
|
||
dependencyResolutionManagement { | ||
repositories { | ||
mavenCentral() | ||
gradlePluginPortal() | ||
google() | ||
} | ||
|
||
versionCatalogs { | ||
create("libs") { | ||
val globalRootPath = findGlobalRootPath(rootDir.toPath()) | ||
from(files("$globalRootPath/versions-root/libs.versions.toml")) | ||
System.getenv("KOTLIN_VERSION")?.let { version("kotlin", it) } | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* This plugin will be applied to all modules in the rootProject. | ||
* So, $rootProject doesn't always represents root directory for this repository. | ||
* We need to traverse directories until we find "versions-root" directory. | ||
*/ | ||
fun findGlobalRootPath(start: Path): Path { | ||
var path = start | ||
|
||
while ( | ||
Files.newDirectoryStream(path).use { it.toList() }.none { | ||
Files.isDirectory(it) && it.fileName.toString() == "versions-root" | ||
} | ||
) { | ||
path = path.parent ?: error("Unable to find root path for Kondition project.") | ||
} | ||
|
||
return path | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package util | ||
|
||
import org.gradle.api.Project | ||
import org.gradle.api.artifacts.VersionCatalogsExtension | ||
import org.gradle.kotlin.dsl.getByType | ||
|
||
val Project.libs get() = extensions.getByType<VersionCatalogsExtension>().named("libs") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
dependencies { | ||
implementation(":gradle-conventions-settings") | ||
compileOnly(libs.ktlint.gradle) | ||
compileOnly(libs.maven.publish) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
rootProject.name = "gradle-conventions" | ||
|
||
pluginManagement { | ||
includeBuild("../gradle-conventions-settings") | ||
} | ||
|
||
plugins { | ||
id("settings-conventions") | ||
} |
15 changes: 15 additions & 0 deletions
15
gradle-conventions/src/main/kotlin/backintime-lint.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import org.jlleitschuh.gradle.ktlint.KtlintExtension | ||
import org.jlleitschuh.gradle.ktlint.reporter.ReporterType | ||
import util.libs | ||
|
||
with(pluginManager) { | ||
apply("org.jlleitschuh.gradle.ktlint") | ||
} | ||
|
||
configure<KtlintExtension> { | ||
version.set(libs.findVersion("ktlint").get().requiredVersion) | ||
ignoreFailures.set(true) | ||
reporters { | ||
reporter(ReporterType.CHECKSTYLE) | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
gradle-conventions/src/main/kotlin/backintime-publication.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import com.vanniktech.maven.publish.MavenPublishBaseExtension | ||
import com.vanniktech.maven.publish.SonatypeHost | ||
|
||
open class BackInTimePublicationExtension { | ||
var artifactId: String = "" | ||
} | ||
|
||
extensions.create<BackInTimePublicationExtension>("backintimePublication") | ||
|
||
with(pluginManager) { | ||
apply("com.vanniktech.maven.publish") | ||
} | ||
|
||
afterEvaluate { | ||
val extension = extensions.getByType(BackInTimePublicationExtension::class.java) | ||
val artifactId = extension.artifactId | ||
if (artifactId.isBlank()) error("Artifact ID must be specified.") | ||
|
||
configure<MavenPublishBaseExtension> { | ||
coordinates(artifactId = artifactId) | ||
|
||
pom { | ||
name.set("back-in-time") | ||
description.set("Kondition ensure that your Kotlin code runs under some conditions are met. It inserts code to verify conditions for value parameters or variables at compile time.") | ||
inceptionYear.set("2024") | ||
url.set("https://github.com/kitakkun/back-in-time-plugin") | ||
licenses { | ||
license { | ||
name.set("The Apache License, Version 2.0") | ||
url.set("https://github.com/kitakkun/back-in-time-plugin/blob/master/LICENSE") | ||
distribution.set("repo") | ||
} | ||
developers { | ||
developer { | ||
id.set("kitakkun") | ||
name.set("kitakkun") | ||
url.set("https://github.com/kitakkun") | ||
} | ||
} | ||
scm { | ||
url.set("https://github.com/kitakkun/back-in-time-plugin") | ||
connection.set("scm:git:git://github.com/kitakkun/back-in-time-plugin.git") | ||
developerConnection.set("scm:git:ssh://[email protected]/kitakkun/back-in-time-plugin.git") | ||
} | ||
} | ||
} | ||
|
||
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) | ||
signAllPublications() | ||
|
||
// avoid failure when executing publishToMavenLocal | ||
tasks.withType(Sign::class).configureEach { | ||
onlyIf { | ||
!gradle.startParameter.taskNames.contains("publishToMavenLocal") | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters