-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
76 additions
and
0 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,3 +1,9 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
dependencies { | ||
implementation(platform(project(":plugins-platform"))) | ||
|
||
implementation(project(":base-plugins")) | ||
} |
32 changes: 32 additions & 0 deletions
32
...le/plugins/java-base-plugins/src/main/kotlin/org.example.consistent-resolution.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,32 @@ | ||
plugins { | ||
id("java-base") | ||
} | ||
|
||
// Expose the ':app' project runtime classpath in every project | ||
val app = configurations.dependencyScope("app") { | ||
withDependencies { | ||
// Depend on ':app' and with this on all its (transitive) dependencies | ||
add(project.dependencies.create(project(":app"))) | ||
// Get our own version information from the platform project | ||
add(project.dependencies.create(project.dependencies.platform("org.example.product:platform"))) | ||
} | ||
} | ||
val appRuntimeClasspath = configurations.resolvable("appRuntimeClasspath") { | ||
description = "Runtime classpath of the complete application" | ||
extendsFrom(app.get()) | ||
attributes { | ||
// We want the runtime classpath represented by Usage.JAVA_RUNTIME | ||
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME)) | ||
} | ||
} | ||
|
||
// Every compile classpath and runtime classpath uses the versions of the | ||
sourceSets.all { | ||
configurations[compileClasspathConfigurationName].shouldResolveConsistentlyWith(appRuntimeClasspath.get()) | ||
configurations[runtimeClasspathConfigurationName].shouldResolveConsistentlyWith(appRuntimeClasspath.get()) | ||
// Source sets without production code (tests / fixtures) are allowed to have dependencies that are | ||
// not part of the consistent resolution result and might need additional version information | ||
if (this != sourceSets["main"]) { | ||
dependencies.add(implementationConfigurationName, dependencies.platform("org.example.product:platform")) | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
gradle/plugins/java-base-plugins/src/main/kotlin/org.example.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,38 @@ | ||
plugins { | ||
id("java") | ||
id("jacoco") // Record test coverage data during test execution | ||
id("org.example.base") | ||
id("org.example.consistent-resolution") | ||
} | ||
|
||
// Configure Java compilation on java {} extension or directly on 'JavaCompile' tasks | ||
java { | ||
toolchain.languageVersion.set(JavaLanguageVersion.of(17)) | ||
} | ||
tasks.withType<JavaCompile>().configureEach { | ||
options.encoding = "UTF-8" | ||
} | ||
|
||
// Configure details for *all* test executions directly on 'Test' task | ||
tasks.withType<Test>().configureEach { | ||
useJUnitPlatform() // Use JUnit 5 as test framework | ||
maxParallelForks = 4 | ||
|
||
testLogging.showStandardStreams = true | ||
|
||
maxHeapSize = "1g" | ||
systemProperty("file.encoding", "UTF-8") | ||
} | ||
|
||
// Configure common test runtime dependencies for *all* projects | ||
dependencies { | ||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") | ||
testRuntimeOnly("org.slf4j:slf4j-simple") | ||
} | ||
|
||
// Add a 'compileAll' task to run all of Java compilation in one go | ||
tasks.register("compileAll") { | ||
group = LifecycleBasePlugin.BUILD_GROUP | ||
description = "Compile all Java code (use to prime the build cache for CI pipeline)" | ||
dependsOn(tasks.withType<JavaCompile>()) | ||
} |