-
Notifications
You must be signed in to change notification settings - Fork 819
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: split /build.gradle.kts to build-logic/ plugins
- Loading branch information
Showing
53 changed files
with
1,171 additions
and
979 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 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 @@ | ||
/*/build/ |
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,24 @@ | ||
import org.gradle.kotlin.dsl.support.expectedKotlinDslPluginsVersion | ||
|
||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
group = "org.postgresql.build-logic" | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
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 | ||
// to make it work. | ||
// See https://github.com/gradle/gradle/issues/17016 regarding expectedKotlinDslPluginsVersion | ||
implementation("org.gradle.kotlin.kotlin-dsl:org.gradle.kotlin.kotlin-dsl.gradle.plugin:$expectedKotlinDslPluginsVersion") | ||
} | ||
|
||
kotlinDslPluginOptions { | ||
jvmTarget.set("1.8") | ||
} |
18 changes: 18 additions & 0 deletions
18
...gic-commons/gradle-plugin/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,18 @@ | ||
plugins { | ||
id("java-library") | ||
id("org.gradle.kotlin.kotlin-dsl") // this is 'kotlin-dsl' without version | ||
} | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_1_8 | ||
targetCompatibility = JavaVersion.VERSION_1_8 | ||
} | ||
|
||
tasks.validatePlugins { | ||
failOnWarning.set(true) | ||
enableStricterValidation.set(true) | ||
} | ||
|
||
kotlinDslPluginOptions { | ||
jvmTarget.set("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,9 @@ | ||
dependencyResolutionManagement { | ||
repositories { | ||
gradlePluginPortal() | ||
} | ||
} | ||
|
||
rootProject.name = "build-logic-commons" | ||
|
||
include("gradle-plugin") |
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 @@ | ||
/*/build/ |
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,27 @@ | ||
# Build logic for pgjdbc | ||
|
||
This is a subset of extra plugins for factoring out | ||
the common patterns from the common build logic. | ||
|
||
The recommended approach is to use build composition, so every build script | ||
should list all its prerequisites in the top-most `plugins { ... }` block. | ||
|
||
The use of `allprojects` and `subprojects` is an anti-pattern as it makes it hard to identify | ||
the configuration for a given project. | ||
|
||
Let us consider an example (see `/pgjdbc/build.gradle.kts`): | ||
|
||
```kotlin | ||
plugins { | ||
id("build-logic.java-published-library") | ||
id("build-logic.test-junit5") | ||
} | ||
|
||
... | ||
``` | ||
|
||
It means that we deal with a Java library that will be published to Central, | ||
and which uses JUnit 5 for testing. | ||
|
||
If you want to see what the logic does, you could open `build-logic.java-published-library.gradle.kts` | ||
and `buildlogic.test-junit5.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 { | ||
id("build-logic.kotlin-dsl-gradle-plugin") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":build-parameters")) | ||
} |
10 changes: 10 additions & 0 deletions
10
build-logic/basics/src/main/kotlin/build-logic.repositories.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,10 @@ | ||
plugins { | ||
id("build-logic.build-params") | ||
} | ||
|
||
repositories { | ||
if (buildParameters.enableMavenLocal) { | ||
mavenLocal() | ||
} | ||
mavenCentral() | ||
} |
7 changes: 7 additions & 0 deletions
7
build-logic/basics/src/main/kotlin/build-logic.reproducible-builds.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 @@ | ||
tasks.withType<AbstractArchiveTask>().configureEach { | ||
// Ensure builds are reproducible | ||
isPreserveFileTimestamps = false | ||
isReproducibleFileOrder = true | ||
dirMode = "775".toInt(8) | ||
fileMode = "664".toInt(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,64 @@ | ||
plugins { | ||
id("org.gradlex.build-parameters") version "1.4.1" | ||
id("com.github.vlsi.gradle-extensions") version "1.86" | ||
id("build-logic.kotlin-dsl-gradle-plugin") | ||
} | ||
|
||
buildParameters { | ||
// Other plugins can contribute parameters, so below list is not exhaustive | ||
enableValidation.set(false) | ||
pluginId("build-logic.build-params") | ||
bool("enableMavenLocal") { | ||
defaultValue.set(true) | ||
description.set("Add mavenLocal() to repositories") | ||
} | ||
bool("coverage") { | ||
defaultValue.set(false) | ||
description.set("Collect test coverage") | ||
} | ||
bool("spotbugs") { | ||
defaultValue.set(false) | ||
description.set("Run SpotBugs verifications") | ||
} | ||
bool("enableCheckerframework") { | ||
defaultValue.set(false) | ||
description.set("Run CheckerFramework (nullness) verifications") | ||
} | ||
bool("enableErrorprone") { | ||
defaultValue.set(false) | ||
description.set("Run ErrorProne verifications") | ||
} | ||
bool("skipCheckstyle") { | ||
defaultValue.set(false) | ||
description.set("Skip Checkstyle verifications") | ||
} | ||
bool("skipAutostyle") { | ||
defaultValue.set(false) | ||
description.set("Skip AutoStyle verifications") | ||
} | ||
bool("skipForbiddenApis") { | ||
defaultValue.set(false) | ||
description.set("Skip forbidden-apis verifications") | ||
} | ||
bool("skipJavadoc") { | ||
defaultValue.set(false) | ||
description.set("Skip javadoc generation") | ||
} | ||
bool("failOnJavadocWarning") { | ||
defaultValue.set(true) | ||
description.set("Fail build on javadoc warnings") | ||
} | ||
bool("enableGradleMetadata") { | ||
defaultValue.set(false) | ||
description.set("Generate and publish Gradle Module Metadata") | ||
} | ||
// Note: it does not work in tr_TR locale due to https://github.com/gradlex-org/build-parameters/issues/87 | ||
string("includeTestTags") { | ||
defaultValue.set("") | ||
description.set("Lists tags to include in test execution. For instance -PincludeTestTags=!org.postgresql.test.SlowTests, or or -PincludeTestTags=!org.postgresql.test.Replication") | ||
} | ||
bool("useGpgCmd") { | ||
defaultValue.set(false) | ||
description.set("By default use Java implementation to sign artifacts. When useGpgCmd=true, then gpg command line tool is used for signing artifacts") | ||
} | ||
} |
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 { | ||
`embedded-kotlin` apply false | ||
} |
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("build-logic.kotlin-dsl-gradle-plugin") | ||
} | ||
|
||
dependencies { | ||
implementation("com.igormaznitsa:jcp:7.0.2") | ||
implementation("com.github.vlsi.gradle-extensions:com.github.vlsi.gradle-extensions.gradle.plugin:1.86") | ||
} |
27 changes: 27 additions & 0 deletions
27
...ava-comment-preprocessor/src/main/kotlin/build-logic.java-comment-preprocessor.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,27 @@ | ||
import com.github.vlsi.gradle.dsl.configureEach | ||
import com.github.vlsi.gradle.properties.dsl.props | ||
|
||
plugins { | ||
id("com.github.vlsi.gradle-extensions") | ||
} | ||
|
||
tasks.configureEach<buildlogic.JavaCommentPreprocessorTask> { | ||
variables.apply { | ||
val jdbcSpec = props.string("jdbc.specification.version") | ||
put("mvn.project.property.postgresql.jdbc.spec", "JDBC$jdbcSpec") | ||
put("jdbc.specification.version", jdbcSpec) | ||
} | ||
|
||
val re = Regex("^(\\d+)\\.(\\d+)(?:\\.(\\d+))?.*") | ||
|
||
val version = project.version.toString() | ||
val matchResult = re.find(version) ?: throw GradleException("Unable to parse major.minor.patch version parts from project.version '$version'") | ||
val (major, minor, patch) = matchResult.destructured | ||
|
||
variables.apply { | ||
put("version", version) | ||
put("version.major", major) | ||
put("version.minor", minor) | ||
put("version.patch", patch.ifBlank { "0" }) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
plugins { | ||
id("build-logic.kotlin-dsl-gradle-plugin") | ||
} | ||
|
||
dependencies { | ||
implementation(project(":build-parameters")) | ||
implementation(project(":verification")) | ||
implementation("com.github.vlsi.crlf:com.github.vlsi.crlf.gradle.plugin:1.86") | ||
implementation("com.github.vlsi.gradle-extensions:com.github.vlsi.gradle-extensions.gradle.plugin:1.86") | ||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin") | ||
implementation("com.igormaznitsa:jcp:7.0.2") | ||
implementation("org.jetbrains.dokka:org.jetbrains.dokka.gradle.plugin:$embeddedKotlinVersion") | ||
implementation("com.github.autostyle:com.github.autostyle.gradle.plugin:3.2") | ||
implementation("net.ltgt.errorprone:net.ltgt.errorprone.gradle.plugin:3.0.1") | ||
implementation("com.github.vlsi.jandex:com.github.vlsi.jandex.gradle.plugin:1.86") | ||
implementation("de.thetaphi.forbiddenapis:de.thetaphi.forbiddenapis.gradle.plugin:3.3") | ||
} |
18 changes: 18 additions & 0 deletions
18
build-logic/jvm/src/main/kotlin/build-logic.dokka-javadoc.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,18 @@ | ||
plugins { | ||
id("java-base") | ||
id("org.jetbrains.dokka") | ||
} | ||
|
||
java { | ||
// Workaround https://github.com/gradle/gradle/issues/21933, so it adds javadocElements configuration | ||
withJavadocJar() | ||
} | ||
|
||
val dokkaJar by tasks.registering(Jar::class) { | ||
group = LifecycleBasePlugin.BUILD_GROUP | ||
description = "Assembles a jar archive containing javadoc" | ||
from(tasks.dokkaJavadoc) | ||
archiveClassifier.set("javadoc") | ||
} | ||
|
||
configurations[JavaPlugin.JAVADOC_ELEMENTS_CONFIGURATION_NAME].outgoing.artifact(dokkaJar) |
4 changes: 4 additions & 0 deletions
4
build-logic/jvm/src/main/kotlin/build-logic.java-library.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,4 @@ | ||
plugins { | ||
id("build-logic.java") | ||
id("java-library") | ||
} |
Oops, something went wrong.