Skip to content
This repository was archived by the owner on Aug 19, 2020. It is now read-only.

Commit a44b938

Browse files
committed
Introduce composite-build-logic sample
With two included builds for build logic: - gradle/shared - gradle/plugins And a variety of dependencies including both the outer build and the plugins included build using the shared included build Signed-off-by: Paul Merlin <[email protected]>
1 parent d65d569 commit a44b938

File tree

15 files changed

+426
-0
lines changed

15 files changed

+426
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
composite-build-logic
2+
=====================
3+
4+
Demonstrates how to use [Composite Builds](https://docs.gradle.org/current/userguide/composite_builds.html)
5+
for build logic.
6+
7+
The build in the [`build-logic`](./build-logic) directory publishes a Gradle Plugin.
8+
The build in this directory includes the `build-logic` build and uses the Gradle Plugin for its build logic.
9+
10+
Run with:
11+
12+
./gradlew sample
13+
14+
See [settings.gradle.kts](./settings.gradle.kts) to see how to include builds and do dependency substitution.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import shared.*
2+
3+
plugins {
4+
id("plugins.sample-plugin")
5+
}
6+
7+
tasks {
8+
sample {
9+
message.set("Hello included build logic!")
10+
}
11+
}
12+
13+
dependencies {
14+
implementation(DependencyVersions.javax.measure.ri.notation)
15+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import shared.*
2+
3+
plugins {
4+
`kotlin-dsl`
5+
}
6+
7+
buildscript {
8+
dependencies {
9+
classpath("composite-build-logic:shared:latest-integration")
10+
}
11+
}
12+
13+
group = "org.gradle.kotlin.dsl.samples.composite-build-logic"
14+
version = "1.0"
15+
16+
repositories {
17+
jcenter()
18+
}
19+
20+
dependencies {
21+
implementation(DependencyVersions.javax.measure.ri.notation)
22+
implementation("composite-build-logic:shared:latest-integration")
23+
}

samples/composite-build-logic/gradle/plugins/settings.gradle.kts

Whitespace-only changes.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package plugins
2+
3+
import org.gradle.api.*
4+
import org.gradle.api.tasks.*
5+
import org.gradle.kotlin.dsl.*
6+
7+
8+
open class SampleTask : DefaultTask() {
9+
10+
@Input
11+
val message = project.objects.property<String>()
12+
13+
@TaskAction
14+
fun sample() {
15+
logger.lifecycle(message.get())
16+
}
17+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package plugins
2+
3+
import shared.*
4+
5+
plugins {
6+
`java-library`
7+
}
8+
9+
dependencies {
10+
"api"(DependencyVersions.javax.measure.api.notation)
11+
}
12+
13+
repositories {
14+
jcenter()
15+
}
16+
17+
tasks.register<SampleTask>("sample") {
18+
message.set("SampleTask executed!")
19+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
group = "org.gradle.kotlin.dsl.samples.composite-build-logic"
6+
version = "1.0"
7+
8+
repositories {
9+
jcenter()
10+
}

samples/composite-build-logic/gradle/shared/settings.gradle.kts

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package shared
2+
3+
object DependencyVersions {
4+
5+
object javax {
6+
object measure {
7+
val api = DependencyVersion("javax.measure", "unit-api", "1.0")
8+
val ri = DependencyVersion("tec.units", "unit-ri", "1.0.3")
9+
}
10+
}
11+
}
12+
13+
data class DependencyVersion(val group: String, val name: String, val version: String) {
14+
val notation: String
15+
get() = "$group:$name:$version"
16+
}
51.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)