-
-
Notifications
You must be signed in to change notification settings - Fork 4
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 #224 from robstoll/chore/gradle-build-logic
switch to gradle build-logic
- Loading branch information
Showing
27 changed files
with
390 additions
and
57 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
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,6 @@ | ||
kotlin.code.style=official | ||
kotlin.js.generate.executable.default=false | ||
|
||
# com.github.vlsi.gradle-extensions prints only failing or slow test results | ||
slowTestLogThreshold=500 | ||
slowSuiteLogThreshold=5000 |
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 @@ | ||
import org.gradle.kotlin.dsl.support.expectedKotlinDslPluginsVersion | ||
|
||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
allprojects { | ||
group = "ch.tutteli.kbox.build-logic.convention" | ||
} | ||
|
||
dependencies { | ||
// We use precompiled script plugins (== plugins written as src/kotlin/build-logic.*.gradle.kts files, | ||
// and we need to declare dependency on org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin | ||
// in order to be able to specify tasks.validatePlugins | ||
// See https://github.com/gradle/gradle/issues/17016 regarding expectedKotlinDslPluginsVersion | ||
implementation("org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:$expectedKotlinDslPluginsVersion") | ||
} |
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,8 @@ | ||
dependencyResolutionManagement { | ||
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) | ||
repositories { | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
rootProject.name = "build-logic-conventions" |
8 changes: 8 additions & 0 deletions
8
...e/build-logic-conventions/src/main/kotlin/build-logic.kotlin-dsl-gradle-plugin.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,8 @@ | ||
plugins { | ||
id("org.gradle.kotlin.kotlin-dsl") // this is 'kotlin-dsl' without version | ||
} | ||
|
||
tasks.validatePlugins { | ||
failOnWarning.set(true) | ||
enableStricterValidation.set(true) | ||
} |
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 @@ | ||
plugins { | ||
id("build-logic.kotlin-dsl-gradle-plugin") | ||
} | ||
|
||
dependencies { | ||
api(projects.buildParameters) | ||
api(buildLibs.vlsi.crlf) | ||
api(buildLibs.vlsi.gradle) | ||
api(buildLibs.taskTree) | ||
} |
7 changes: 7 additions & 0 deletions
7
gradle/build-logic/basics/src/main/kotlin/build-logic.gradle-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,7 @@ | ||
plugins { | ||
// plugins we use in all gradle projects | ||
id("build-logic.build-params") | ||
id("com.github.vlsi.gradle-extensions") | ||
// enable to analyse task dependencies | ||
// id("com.dorongold.task-tree") | ||
} |
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 @@ | ||
import org.gradle.api.DomainObjectCollection | ||
import org.gradle.kotlin.dsl.withType | ||
|
||
// TODO check if already moved into own tegonal repo and fetch via gt | ||
// copied from com.github.vlsi.gradle.dsl.configureEach, using this instead so that we don't have to import | ||
inline fun <reified S : Any> DomainObjectCollection<in S>.configureEach(noinline configuration: S.() -> Unit) = | ||
withType().configureEach(configuration) |
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,47 @@ | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion | ||
|
||
plugins { | ||
id("build-logic.kotlin-dsl-gradle-plugin") | ||
alias(buildLibs.plugins.build.parameters) | ||
} | ||
|
||
buildParameters { | ||
pluginId("build-logic.build-params") | ||
|
||
// Other plugins can contribute parameters, so below list is not exhaustive, hence we disable the validation | ||
enableValidation.set(false) | ||
|
||
val defaultJdkVersion = 11 | ||
integer("defaultJdkVersion") { | ||
defaultValue.set(defaultJdkVersion) | ||
mandatory.set(true) | ||
description.set("Default jdk version for source and target compatibility") | ||
} | ||
|
||
group("kotlin") { | ||
string("version") { | ||
fromEnvironment() | ||
@Suppress("DEPRECATION" /* we support kotlin_1_4 on purpose */) | ||
defaultValue.set(KotlinVersion.KOTLIN_1_4.version) | ||
description.set("kotlin version used for apiVersion and languageVersion") | ||
} | ||
bool("werror") { | ||
defaultValue.set(true) | ||
description.set("Treat kotlinc warnings as errors") | ||
} | ||
} | ||
|
||
|
||
group("java") { | ||
integer("version") { | ||
fromEnvironment() | ||
defaultValue.set(defaultJdkVersion) | ||
description.set("Java version used for java.toolchain") | ||
} | ||
bool("werror") { | ||
defaultValue.set(true) | ||
description.set("Treat javac, javadoc, warnings as errors") | ||
} | ||
} | ||
|
||
} |
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 @@ | ||
plugins { | ||
`embedded-kotlin` apply false | ||
} | ||
|
||
allprojects { | ||
group = "ch.tutteli.kbox.build-logic" | ||
} |
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 { | ||
id("build-logic.kotlin-dsl-gradle-plugin") | ||
} | ||
|
||
dependencies { | ||
api(projects.basics) | ||
|
||
api(buildLibs.kotlin) | ||
api(buildLibs.bundles.dokka) | ||
api(buildLibs.tutteli.junitjacoco) | ||
api(buildLibs.tutteli.moduleinfo) | ||
} |
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 @@ | ||
import org.jetbrains.dokka.base.DokkaBase | ||
import org.jetbrains.dokka.base.DokkaBaseConfiguration | ||
import org.jetbrains.dokka.gradle.AbstractDokkaTask | ||
|
||
fun AbstractDokkaTask.configurePlugins() { | ||
pluginConfiguration<DokkaBase, DokkaBaseConfiguration> { | ||
footerMessage = "KBox © Copyright Robert Stoll <[email protected]>" | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
gradle/build-logic/dev/src/main/kotlin/build-logic.java.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,29 @@ | ||
plugins { | ||
id("java") | ||
id("build-logic.gradle-conventions") | ||
} | ||
|
||
java { | ||
toolchain { | ||
// reading JAVA_VERSION from env to enable jdk17 build in CI | ||
languageVersion.set(JavaLanguageVersion.of(buildParameters.java.version)) | ||
} | ||
consistentResolution { | ||
useCompileClasspathVersions() | ||
} | ||
} | ||
|
||
|
||
tasks.configureEach<JavaCompile> { | ||
inputs.property("java.version", System.getProperty("java.version")) | ||
inputs.property("java.vm.version", System.getProperty("java.vm.version")) | ||
sourceCompatibility = buildParameters.defaultJdkVersion.toString() | ||
targetCompatibility = buildParameters.defaultJdkVersion.toString() | ||
options.apply { | ||
encoding = "UTF-8" | ||
compilerArgs.add("-Xlint:deprecation") | ||
if (buildParameters.java.werror) { | ||
compilerArgs.add("-Werror") | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
gradle/build-logic/dev/src/main/kotlin/build-logic.junit-jacoco-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,9 @@ | ||
plugins { | ||
id("ch.tutteli.gradle.plugins.junitjacoco") | ||
} | ||
|
||
dependencies { | ||
// used to run the samples | ||
testImplementation("org.junit.jupiter:junit-jupiter-api") | ||
testImplementation("org.junit.jupiter:junit-jupiter-params") | ||
} |
19 changes: 19 additions & 0 deletions
19
gradle/build-logic/dev/src/main/kotlin/build-logic.kotlin-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,19 @@ | ||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask | ||
|
||
plugins { | ||
id("build-logic.gradle-conventions") | ||
} | ||
tasks.configureEach<KotlinCompilationTask<*>> { | ||
compilerOptions { | ||
freeCompilerArgs.add("-opt-in=kotlin.RequiresOptIn") | ||
// suppress warnings about kotlin 1.4 being deprecated | ||
freeCompilerArgs.add("-Xsuppress-version-warnings") | ||
// suppress warnings about expect/actual being an experimental feature | ||
freeCompilerArgs.add("-Xexpect-actual-classes") | ||
|
||
val kotlinVersion = KotlinVersion.fromVersion(buildParameters.kotlin.version) | ||
languageVersion.set(kotlinVersion) | ||
apiVersion.set(kotlinVersion) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
gradle/build-logic/dev/src/main/kotlin/build-logic.kotlin-jvm-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,17 @@ | ||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
id("build-logic.kotlin-conventions") | ||
id("build-logic.junit-jacoco-conventions") | ||
// this plugin sets inter alia toolchain and source/targetCompatibility | ||
// but also applies common plugins such as gradle-convention, build-params | ||
id("build-logic.java") | ||
id("ch.tutteli.gradle.plugins.kotlin.module.info") | ||
} | ||
|
||
tasks.configureEach<KotlinCompile> { | ||
compilerOptions{ | ||
jvmTarget.set(JvmTarget.fromTarget(buildParameters.defaultJdkVersion.toString())) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
gradle/build-logic/dev/src/main/kotlin/build-logic.kotlin-jvm.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,8 @@ | ||
plugins { | ||
kotlin("jvm") | ||
id("build-logic.kotlin-jvm-conventions") | ||
} | ||
|
||
dependencies { | ||
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") | ||
} |
38 changes: 38 additions & 0 deletions
38
gradle/build-logic/dev/src/main/kotlin/build-logic.kotlin-multiplatform.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,38 @@ | ||
plugins { | ||
kotlin("multiplatform") | ||
id("build-logic.kotlin-jvm-conventions") | ||
} | ||
|
||
|
||
kotlin { | ||
jvm { | ||
// for module-info.java | ||
withJava() | ||
} | ||
|
||
js(IR) { nodejs() } | ||
|
||
sourceSets { | ||
commonTest { | ||
dependencies { | ||
implementation(kotlin("test")) | ||
} | ||
} | ||
|
||
// necessary due to https://youtrack.jetbrains.com/issue/KT-65352/KMP-Gradle-impossible-to-set-language-apiVersion-for-common-to-1.4 | ||
all { | ||
languageSettings { | ||
languageVersion = buildParameters.kotlin.version | ||
apiVersion = buildParameters.kotlin.version | ||
} | ||
} | ||
} | ||
} | ||
|
||
// this is necessary due to some crazy kotlin plugin voodoo. If we define this in the rootProject itself, | ||
// then it does not work. | ||
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnPlugin> { | ||
rootProject.configure<org.jetbrains.kotlin.gradle.targets.js.yarn.YarnRootExtension> { | ||
lockFileDirectory = rootProject.projectDir.resolve("gradle") | ||
} | ||
} |
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 { | ||
id("build-logic.kotlin-dsl-gradle-plugin") | ||
} | ||
|
||
dependencies { | ||
api(projects.basics) | ||
api(projects.dev) | ||
|
||
api(buildLibs.bundles.dokka) | ||
api(buildLibs.tutteli.dokka) | ||
api(buildLibs.tutteli.publish) | ||
} |
Oops, something went wrong.