-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract more stuff to a 'base' plugin
- Loading branch information
Showing
22 changed files
with
130 additions
and
153 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
buildSrc/src/main/kotlin/faker-base-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,98 @@ | ||
import gradle.kotlin.dsl.accessors._617ff5292df7551646490c1442241820.assemble | ||
import gradle.kotlin.dsl.accessors._617ff5292df7551646490c1442241820.jar | ||
import gradle.kotlin.dsl.accessors._617ff5292df7551646490c1442241820.sourceSets | ||
import gradle.kotlin.dsl.accessors._617ff5292df7551646490c1442241820.test | ||
import org.gradle.api.tasks.SourceSetContainer | ||
import org.gradle.api.tasks.testing.Test | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.creating | ||
import org.gradle.kotlin.dsl.get | ||
import org.gradle.kotlin.dsl.getValue | ||
import org.gradle.kotlin.dsl.invoke | ||
import org.gradle.kotlin.dsl.withType | ||
import org.jetbrains.dokka.gradle.DokkaTask | ||
|
||
/** | ||
* Plugin for base build setup of faker modules with kotlin | ||
*/ | ||
|
||
plugins { | ||
base | ||
kotlin("jvm") | ||
id("org.jetbrains.dokka") | ||
} | ||
|
||
configurations { | ||
create("integrationImplementation") { extendsFrom(configurations.getByName("testImplementation")) } | ||
create("integrationRuntimeOnly") { | ||
if (isShadow) { | ||
extendsFrom( | ||
configurations.getByName("testRuntimeOnly"), | ||
configurations.getByName("shadow"), | ||
) | ||
} else { | ||
extendsFrom(configurations.getByName("testRuntimeOnly")) | ||
} | ||
} | ||
} | ||
|
||
// configure sourceSets as extension since it's not available here as `sourceSets` is an extension on `Project` | ||
// https://docs.gradle.org/current/userguide/kotlin_dsl.html#project_extensions_and_conventions | ||
configure<SourceSetContainer> { | ||
create("integration") { | ||
resources.srcDir("src/integration/resources") | ||
compileClasspath += main.get().compileClasspath + test.get().compileClasspath | ||
runtimeClasspath += main.get().runtimeClasspath + test.get().runtimeClasspath | ||
} | ||
main { | ||
resources { | ||
this.srcDir("build/generated/src/main/resources") | ||
} | ||
} | ||
} | ||
|
||
val integrationTest by tasks.creating(Test::class) { | ||
testClassesDirs = sourceSets["integration"].output.classesDirs | ||
classpath = sourceSets["integration"].runtimeClasspath | ||
dependsOn(tasks.test) | ||
} | ||
|
||
tasks.withType<Jar> { | ||
archiveBaseName.set(fullName) | ||
|
||
manifest { | ||
attributes( | ||
mapOf( | ||
"Implementation-Title" to fullName, | ||
"Implementation-Version" to project.version, | ||
/* | ||
* We can't add this here because this resolves the configuration, | ||
* after which it effectively becomes read-only and we'll get an error | ||
* Cannot change dependencies of dependency configuration ':core:implementation' after it has been included in dependency resolution | ||
* if we try to add more dependencies in the module's build.gradle file directly | ||
*/ | ||
// "Class-Path" to project.configurations.compileClasspath.get().joinToString(" ") { it.name } | ||
) | ||
) | ||
} | ||
} | ||
|
||
tasks { | ||
assemble { | ||
dependsOn(jar) | ||
} | ||
} | ||
|
||
tasks { | ||
jar { | ||
dependsOn(integrationTest) | ||
} | ||
assemble { | ||
dependsOn(integrationTest) | ||
} | ||
} | ||
|
||
tasks.withType<DokkaTask>().configureEach { | ||
onlyIf("Not dev") { !isDev.get() } | ||
onlyIf("Release or snapshot") { isRelease.get() || isSnapshot.get() } | ||
} |
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,82 +1,13 @@ | ||
import org.jetbrains.dokka.gradle.DokkaTask | ||
/** | ||
* Plugin for :extension:* modules | ||
*/ | ||
|
||
plugins { | ||
base | ||
kotlin("jvm") | ||
id("org.jetbrains.dokka") | ||
id("faker-base-conventions") | ||
id("faker-pub-conventions") | ||
} | ||
|
||
configurations { | ||
create("integrationImplementation") { extendsFrom(configurations.getByName("testImplementation")) } | ||
create("integrationRuntimeOnly") { | ||
extendsFrom( | ||
configurations.getByName("testRuntimeOnly"), | ||
) | ||
} | ||
} | ||
|
||
// configure sourceSets as extension since it's not available here as `sourceSets` is an extension on `Project` | ||
// https://docs.gradle.org/current/userguide/kotlin_dsl.html#project_extensions_and_conventions | ||
configure<SourceSetContainer> { | ||
create("integration") { | ||
resources.srcDir("src/integration/resources") | ||
compileClasspath += main.get().compileClasspath + test.get().compileClasspath | ||
runtimeClasspath += main.get().runtimeClasspath + test.get().runtimeClasspath | ||
} | ||
main { | ||
resources { | ||
this.srcDir("build/generated/src/main/resources") | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
val implementation by configurations | ||
implementation(libs.bundles.kotlin) | ||
} | ||
|
||
val integrationTest by tasks.creating(Test::class) { | ||
testClassesDirs = sourceSets["integration"].output.classesDirs | ||
classpath = sourceSets["integration"].runtimeClasspath | ||
dependsOn(tasks.test) | ||
} | ||
|
||
tasks.withType<Jar> { | ||
archiveBaseName.set(fullName) | ||
|
||
manifest { | ||
attributes( | ||
mapOf( | ||
"Implementation-Title" to fullName, | ||
"Implementation-Version" to project.version, | ||
/* | ||
* We can't add this here because this resolves the configuration, | ||
* after which it effectively becomes read-only and we'll get an error | ||
* Cannot change dependencies of dependency configuration ':core:implementation' after it has been included in dependency resolution | ||
* if we try to add more dependencies in the module's build.gradle file directly | ||
*/ | ||
// "Class-Path" to project.configurations.compileClasspath.get().joinToString(" ") { it.name } | ||
) | ||
) | ||
} | ||
|
||
dependsOn(integrationTest) | ||
} | ||
|
||
artifacts { | ||
archives(sourcesJar) | ||
archives(dokkaJavadocJar) | ||
} | ||
|
||
tasks { | ||
assemble { | ||
dependsOn(integrationTest) | ||
dependsOn(jar) | ||
} | ||
} | ||
|
||
tasks.withType<DokkaTask>().configureEach { | ||
onlyIf("Not dev") { !isDev.get() } | ||
onlyIf("Release or snapshot") { isRelease.get() || isSnapshot.get() } | ||
} |
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
5 changes: 5 additions & 0 deletions
5
buildSrc/src/main/kotlin/faker-provider-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
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,4 +1,3 @@ | ||
plugins { | ||
`faker-lib-conventions` | ||
`faker-provider-conventions` | ||
} |
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,4 +1,3 @@ | ||
plugins { | ||
`faker-lib-conventions` | ||
`faker-provider-conventions` | ||
} |
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,4 +1,3 @@ | ||
plugins { | ||
`faker-lib-conventions` | ||
`faker-provider-conventions` | ||
} |
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,4 +1,3 @@ | ||
plugins { | ||
`faker-lib-conventions` | ||
`faker-provider-conventions` | ||
} |
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,4 +1,3 @@ | ||
plugins { | ||
`faker-lib-conventions` | ||
`faker-provider-conventions` | ||
} |
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,4 +1,3 @@ | ||
plugins { | ||
`faker-lib-conventions` | ||
`faker-provider-conventions` | ||
} |
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,4 +1,3 @@ | ||
plugins { | ||
`faker-lib-conventions` | ||
`faker-provider-conventions` | ||
} |
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,4 +1,3 @@ | ||
plugins { | ||
`faker-lib-conventions` | ||
`faker-provider-conventions` | ||
} |
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,4 +1,3 @@ | ||
plugins { | ||
`faker-lib-conventions` | ||
`faker-provider-conventions` | ||
} |
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,4 +1,3 @@ | ||
plugins { | ||
`faker-lib-conventions` | ||
`faker-provider-conventions` | ||
} |
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,4 +1,3 @@ | ||
plugins { | ||
`faker-lib-conventions` | ||
`faker-provider-conventions` | ||
} |
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,4 +1,3 @@ | ||
plugins { | ||
`faker-lib-conventions` | ||
`faker-provider-conventions` | ||
} |
Oops, something went wrong.