-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor the project into "gradle-common"
Major tasks done: 1. separate some more opinionated plugins into "architecture-common-gradle-plugins" 1. add a "common-gradle-dependencies" subproject to organize dependencies and their versions, which should probably be extracted into a separate project in the future 1. continue adapting for the "kotlin-common" project
- Loading branch information
Showing
35 changed files
with
365 additions
and
184 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +1,8 @@ | ||
# Huanshankeji Kotlin Common Gradle plugin | ||
Huanshankeji's Gradle plugin for common projects in Kotlin | ||
# Huanshankeji Gradle Common (in and for Kotlin) | ||
|
||
Huanshankeji's Gradle common code in Kotlin, mainly for common projects in Kotlin | ||
|
||
## Notices | ||
|
||
1. IntelliJ IDEA doesn't work well with applying plugins to script plugins in project sources. If a script plugin's code | ||
does not resolve, try restarting IntelliJ IDEA. |
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,68 @@ | ||
plugins { | ||
id("plugin-conventions") | ||
} | ||
|
||
repositories { | ||
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":kotlin-common-gradle-plugins")) | ||
//api(project(":common-gradle-dependencies")) | ||
implementation(project(":common-gradle-dependencies")) | ||
|
||
implementation("org.jetbrains.compose:compose-gradle-plugin:1.2.0-alpha01-dev686") | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
val `package` = group as String | ||
fun scriptConventionsPlugin(shortName: String, displayNameAndDescription: String) = | ||
scriptPlugin(`package`, shortName, displayNameAndDescription) | ||
|
||
scriptConventionsPlugin( | ||
"kotlin-jvm-common-app-conventions", | ||
"Kotlin/JVM common app conventions" | ||
) | ||
scriptConventionsPlugin( | ||
"kotlin-jvm-application-app-conventions", | ||
"Kotlin/JVM application app conventions" | ||
) | ||
scriptConventionsPlugin( | ||
"kotlin-jvm-library-app-conventions", | ||
"Kotlin/JVM library app conventions" | ||
) | ||
|
||
scriptConventionsPlugin( | ||
"kotlin-multiplatform-app-conventions", | ||
"Kotlin Multiplatform app conventions" | ||
) | ||
scriptConventionsPlugin( | ||
"kotlin-multiplatform-js-browser-app-conventions", | ||
"Kotlin Multiplatform app conventions with the JS browser target" | ||
) | ||
scriptConventionsPlugin( | ||
"kotlin-multiplatform-jvm-and-js-browser-app-conventions", | ||
"Kotlin Multiplatform app conventions with the JVM target and the JS browser target" | ||
) | ||
|
||
scriptConventionsPlugin( | ||
"default-web-frontend-conventions", | ||
"Default web frontend conventions for our projects with Compose for Web and kotlinx.html HTML generation" | ||
) | ||
/* TODO | ||
scriptConventionsPlugin( | ||
"default-material-web-frontend-conventions", | ||
"Default web frontend conventions for our projects with Compose for Web, kotlinx.html HTML generation, and Material Design" | ||
) | ||
*/ | ||
|
||
val name = "generate-kotlin-js-browser-webroot-for-vertx-web" | ||
create(name) { | ||
id = "$`package`.$name" | ||
implementationClass = "$`package`.GenerateKotlinJsBrowserWebrootForVertxWebPlugin" | ||
displayName = "Generate Kotlin/JS browser webroot for Vert.x Web" | ||
description = "Generate webroot from a Kotlin/JS subproject with browser target for Vert.x Web" | ||
} | ||
} | ||
} |
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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
36 changes: 36 additions & 0 deletions
36
...dle-plugins/src/main/kotlin/com/huanshankeji/kotlin-jvm-common-app-conventions.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,36 @@ | ||
package com.huanshankeji | ||
|
||
plugins { | ||
id("com.huanshankeji.kotlin-jvm-common-conventions") | ||
} | ||
|
||
dependencies { | ||
implementation(platform(kotlin("bom"))) | ||
|
||
testImplementation(kotlin("test")) | ||
testImplementation("org.junit.jupiter:junit-jupiter-api:${DefaultVersions.junitJupiter}") | ||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") | ||
|
||
implementation(CommonDependencies.Kotlinx.Coroutines.core()) | ||
testImplementation(CommonDependencies.Kotlinx.Coroutines.test()) | ||
} | ||
|
||
tasks.test { | ||
// Use junit platform for unit tests. | ||
useJUnitPlatform() | ||
} | ||
|
||
/* | ||
java { | ||
sourceCompatibility = JavaVersion.VERSION_11 | ||
targetCompatibility = JavaVersion.VERSION_11 | ||
} | ||
tasks.withType<KotlinCompile> { | ||
kotlinOptions.jvmTarget = "11" | ||
} | ||
*/ | ||
|
||
kotlin.sourceSets.all { | ||
languageSettings.defaultOptIns() | ||
} |
4 changes: 1 addition & 3 deletions
4
...kotlin-jvm-library-conventions.gradle.kts → ...in-jvm-library-app-conventions.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
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
File renamed without changes.
File renamed without changes.
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,12 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
gradlePluginPortal() | ||
} | ||
|
||
dependencies { | ||
implementation("org.gradle.kotlin:gradle-kotlin-dsl-plugins:2.1.7") // It seems this version has to be used for Gradle 7.4.2. | ||
implementation("com.gradle.publish:plugin-publish-plugin:1.0.0-rc-2") | ||
} |
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,10 @@ | ||
import org.gradle.api.NamedDomainObjectContainer | ||
import org.gradle.plugin.devel.PluginDeclaration | ||
|
||
fun NamedDomainObjectContainer<PluginDeclaration>.scriptPlugin( | ||
`package`: String, shortName: String, displayNameAndDescription: String | ||
) = | ||
getByName("$`package`.$shortName") { | ||
displayName = displayNameAndDescription | ||
description = displayNameAndDescription | ||
} |
16 changes: 16 additions & 0 deletions
16
buildSrc/src/main/kotlin/build-dependency-library-conventions.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,16 @@ | ||
// Maybe it's better to use Maven publish and Maven repositories (Maven Central) | ||
plugins { | ||
kotlin("jvm") | ||
id("com.gradle.plugin-publish") | ||
} | ||
|
||
repositories { | ||
gradlePluginPortal() | ||
} | ||
|
||
group = "com.huanshankeji" | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} |
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,17 @@ | ||
plugins { | ||
id("build-dependency-library-conventions") | ||
id("org.gradle.kotlin.kotlin-dsl") | ||
} | ||
|
||
dependencies { | ||
// Not specifying version can cause build issues when added to a project's buildscript dependencies. | ||
implementation(kotlin("gradle-plugin", "1.6.21")) | ||
} | ||
|
||
version = "0.1.1-SNAPSHOT" | ||
|
||
pluginBundle { | ||
website = "https://github.com/huanshankeji/gradle-plugin" | ||
vcsUrl = "https://github.com/huanshankeji/gradle-plugin.git" | ||
tags = listOf("kotlin", "multiplatform") | ||
} |
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,5 @@ | ||
plugins { | ||
id("build-dependency-library-conventions") | ||
} | ||
|
||
version = "0.1.0-20220520-dev" |
101 changes: 101 additions & 0 deletions
101
common-gradle-dependencies/src/main/kotlin/com/huanshankeji/CommonDependencies.kt
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,101 @@ | ||
package com.huanshankeji | ||
|
||
// some but not all default dependencies | ||
object CommonDependencies { | ||
object KotlinCommon { | ||
val defaultVersion = DefaultVersions.kotlinCommon | ||
fun module(module: String, version: String = defaultVersion) = | ||
"com.huanshankeji:kotlin-common-$module:$version" | ||
|
||
fun core(version: String = defaultVersion) = module("core", version) | ||
fun net(version: String = defaultVersion) = module("net", version) | ||
fun web(version: String = defaultVersion) = module("web", version) | ||
fun arrow(version: String = defaultVersion) = module("arrow", version) | ||
fun coroutines(version: String = defaultVersion) = module("coroutines", version) | ||
fun exposed(version: String = defaultVersion) = module("exposed", version) | ||
|
||
object Ktor { | ||
fun module(module: String, version: String = defaultVersion) = | ||
KotlinCommon.module("ktor-$module", version) | ||
|
||
fun client(version: String = defaultVersion) = module("client", version) | ||
} | ||
|
||
fun serialization(version: String = defaultVersion) = module("serialization", version) | ||
fun vertx(version: String = defaultVersion) = module("vertx", version) | ||
} | ||
|
||
object Kotlinx { | ||
object Coroutines { | ||
val defaultVersion = DefaultVersions.kotlinxCoroutines | ||
fun module(module: String, version: String = defaultVersion) = | ||
kotlinx("coroutines-$module", version) | ||
|
||
fun core(version: String = defaultVersion) = module("core", version) | ||
fun test(version: String = defaultVersion) = module("test", version) | ||
} | ||
|
||
object Html { | ||
val defaultVersion = DefaultVersions.kotlinxHtml | ||
fun module(module: String, version: String = defaultVersion) = | ||
"org.jetbrains.kotlinx:kotlinx-html-$module:$version" | ||
} | ||
|
||
object Serialization { | ||
val defaultVersion = DefaultVersions.kotlinxSerialization | ||
fun module(module: String, version: String = defaultVersion) = | ||
kotlinx("serialization-$module", version) | ||
|
||
fun core(version: String = defaultVersion) = module("core", version) | ||
fun protobuf(version: String = defaultVersion) = module("protobuf", version) | ||
fun json(version: String = defaultVersion) = module("json", version) | ||
} | ||
} | ||
|
||
|
||
// official libraries from JetBrains | ||
|
||
object Exposed { | ||
val defaultVersion = DefaultVersions.exposed | ||
fun module(module: String, version: String = defaultVersion) = | ||
"org.jetbrains.exposed:exposed-$module:$version" | ||
|
||
fun core(version: String = defaultVersion) = | ||
module("core", version) | ||
} | ||
|
||
object Ktor { | ||
val defaultVersion = DefaultVersions.ktor | ||
fun module(module: String, version: String = defaultVersion) = | ||
"io.ktor:ktor-$module:$version" | ||
|
||
object Client { | ||
fun module(module: String, version: String = defaultVersion) = | ||
Ktor.module("client-$module", version) | ||
|
||
fun core(version: String = defaultVersion) = | ||
module("core", version) | ||
} | ||
} | ||
|
||
|
||
// others | ||
|
||
object Vertx { | ||
val defaultVersion = DefaultVersions.vertx | ||
fun stackDepchain(version: String = defaultVersion) = | ||
"io.vertx:vertx-stack-depchain:$version" | ||
|
||
fun module(module: String) = | ||
"io.vertx:vertx-$module" | ||
} | ||
|
||
object Arrow { | ||
val defaultVersion = DefaultVersions.arrow | ||
fun module(module: String, version: String = defaultVersion) = | ||
"io.arrow-kt:arrow-$module:$version" | ||
|
||
fun core(version: String = defaultVersion) = | ||
module("core", version) | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
common-gradle-dependencies/src/main/kotlin/com/huanshankeji/DefaultVersions.kt
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,20 @@ | ||
package com.huanshankeji | ||
|
||
object DefaultVersions { | ||
val kotlin = "1.6.21" | ||
|
||
val kotlinCommon = "0.1.0-SNAPSHOT" // TODO | ||
|
||
val exposed = "0.38.2" | ||
val kotlinxCoroutines = "1.6.1" | ||
val kotlinxHtml = "0.7.5" | ||
val kotlinxSerialization = "1.3.3" | ||
val ktor = "1.6.8" | ||
|
||
val arrow = "1.1.2" | ||
val junitJupiter = "5.8.2" | ||
val kotest = "5.2.3" | ||
val postgreSql = "42.3.5" | ||
val slf4j = "1.7.36" | ||
val vertx = "4.2.7" // TODO: 4.3.0 | ||
} |
File renamed without changes.
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 @@ | ||
kotlin.mpp.stability.nowarn=true |
Oops, something went wrong.