-
Notifications
You must be signed in to change notification settings - Fork 18
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
18 changed files
with
322 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# https://onepiece.software/j/modules | ||
|
||
# jakarta.activation=com.sun.activation:jakarta.activation |
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,16 @@ | ||
plugins { `kotlin-dsl`} | ||
|
||
repositories.maven("https://plugins.gradle.org/m2") | ||
repositories.maven("https://gradle.onepiece.software:1443/releases") | ||
|
||
dependencies { | ||
implementation("com.autonomousapps:dependency-analysis-gradle-plugin:1.28.0") | ||
implementation("com.gradle:gradle-enterprise-gradle-plugin:3.16.1") | ||
implementation("io.fuchs.gradle.classpath-collision-detector:classpath-collision-detector:0.3") | ||
implementation("org.gradle.toolchains:foojay-resolver:0.7.0") | ||
implementation("org.gradlex:extra-java-module-info:1.7") | ||
implementation("org.gradlex:java-ecosystem-capabilities:1.4") | ||
implementation("org.gradlex:java-module-dependencies:1.5.1") | ||
implementation("org.gradlex:java-module-packaging:0.0.2") | ||
implementation("org.gradlex:java-module-testing:1.3.1") | ||
} |
8 changes: 8 additions & 0 deletions
8
gradle/plugins/src/main/kotlin/org.example.gradlebuild.feature-main.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("java") | ||
} | ||
|
||
tasks.named<JavaCompile>("compileJava") { | ||
options.forkOptions.jvmArgs = listOf() | ||
options.compilerArgs = listOf() | ||
} |
11 changes: 11 additions & 0 deletions
11
gradle/plugins/src/main/kotlin/org.example.gradlebuild.feature-mock-api.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,11 @@ | ||
plugins { | ||
id("java") | ||
} | ||
|
||
val feature = sourceSets.create("mockApi") | ||
java.registerFeature("mockApi") { usingSourceSet(feature) } | ||
|
||
tasks.named<JavaCompile>("compileMockApiJava") { | ||
options.forkOptions.jvmArgs = listOf() | ||
options.compilerArgs = listOf() | ||
} |
8 changes: 8 additions & 0 deletions
8
gradle/plugins/src/main/kotlin/org.example.gradlebuild.feature-test-fixtures.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("java-test-fixtures") | ||
} | ||
|
||
tasks.named<JavaCompile>("compileTestFixturesJava") { | ||
options.forkOptions.jvmArgs = listOf() | ||
options.compilerArgs = listOf() | ||
} |
20 changes: 20 additions & 0 deletions
20
gradle/plugins/src/main/kotlin/org.example.gradlebuild.java-application-module.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,20 @@ | ||
plugins { | ||
id("application") | ||
id("io.fuchs.gradle.classpath-collision-detector") | ||
id("org.example.gradlebuild.java-base") | ||
id("org.example.gradlebuild.java-module-building") | ||
id("org.example.gradlebuild.java-module-testing") | ||
} | ||
|
||
javaModulePackaging { | ||
applicationName = "Gradle Project Setup HowTo" | ||
applicationDescription = "How to structure a growing Gradle project with smart dependency management?" | ||
vendor = "Jendrik Johannes (onepiece.Software)" | ||
copyright = "Copyright 2024, Jendrik Johannes" | ||
} | ||
|
||
application { | ||
applicationDefaultJvmArgs = listOf() | ||
} | ||
|
||
tasks.withType<JavaExec>().configureEach { args() } |
7 changes: 7 additions & 0 deletions
7
gradle/plugins/src/main/kotlin/org.example.gradlebuild.java-base.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("org.example.gradlebuild.patch-metadata") | ||
id("org.example.gradlebuild.patch-non-modules") | ||
} | ||
|
||
group = "org.example" | ||
version ="1.0" |
7 changes: 7 additions & 0 deletions
7
gradle/plugins/src/main/kotlin/org.example.gradlebuild.java-library-module.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("java-library") | ||
id("org.example.gradlebuild.java-base") | ||
id("org.example.gradlebuild.java-module-building") | ||
id("org.example.gradlebuild.java-module-testing") | ||
id("org.example.gradlebuild.java-module-publishing") | ||
} |
56 changes: 56 additions & 0 deletions
56
gradle/plugins/src/main/kotlin/org.example.gradlebuild.java-module-building.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,56 @@ | ||
plugins { | ||
id("java") | ||
id("org.gradlex.java-module-dependencies") | ||
id("org.gradlex.java-module-packaging") | ||
id("org.example.gradlebuild.feature-main") | ||
id("org.example.gradlebuild.test-suite-test") | ||
} | ||
|
||
javaModulePackaging { | ||
target("macos") { | ||
operatingSystem = "macos" | ||
architecture = "x86-64" | ||
} | ||
target("ubuntu") { | ||
operatingSystem = "linux" | ||
architecture = "x86-64" | ||
} | ||
target("windows") { | ||
operatingSystem = "windows" | ||
architecture = "x86-64" | ||
} | ||
} | ||
|
||
val fullJavaVersion = "17.0.6" | ||
val majorJavaVersion = fullJavaVersion.substring(0, fullJavaVersion.indexOf(".")) | ||
java.toolchain.languageVersion = JavaLanguageVersion.of(majorJavaVersion) | ||
|
||
val allModuleProjects = rootProject.subprojects.map { it.path }.filter { it != ":platform" }.toTypedArray() | ||
val mainRuntimeClasspath = javaModuleDependencies.versionsFromPlatformAndConsistentResolution(":platform", *allModuleProjects) | ||
configurations["javaModulesMergeJars"].shouldResolveConsistentlyWith(mainRuntimeClasspath) | ||
|
||
tasks.withType<JavaCompile>().configureEach { | ||
inputs.property("fullJavaVersion", fullJavaVersion) | ||
options.isFork = true | ||
options.encoding = "UTF-8" | ||
options.javaModuleVersion = project.version as String | ||
doFirst { | ||
this as JavaCompile | ||
val trackedVersion = inputs.properties["fullJavaVersion"] as String | ||
val usedVersion = javaCompiler.get().metadata.javaRuntimeVersion | ||
if (!usedVersion.startsWith(trackedVersion)) { | ||
throw RuntimeException("Selected JDK version $usedVersion does not fit defined JDK version $trackedVersion") | ||
} | ||
} | ||
} | ||
|
||
tasks.withType<AbstractArchiveTask>().configureEach { | ||
isPreserveFileTimestamps = false | ||
isReproducibleFileOrder = true | ||
fileMode = 436 // 0664 | ||
dirMode = 509 // 0775 | ||
} | ||
|
||
tasks.withType<Javadoc>().configureEach { | ||
options.encoding = "UTF-8" | ||
} |
18 changes: 18 additions & 0 deletions
18
gradle/plugins/src/main/kotlin/org.example.gradlebuild.java-module-publishing.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") | ||
id("maven-publish") | ||
} | ||
|
||
java.withSourcesJar() | ||
|
||
java.withJavadocJar() | ||
|
||
publishing.publications.create<MavenPublication>("module") { | ||
from(components["java"]) | ||
versionMapping { | ||
allVariants { fromResolutionResult() } | ||
} | ||
} | ||
|
||
publishing.repositories { | ||
} |
10 changes: 10 additions & 0 deletions
10
gradle/plugins/src/main/kotlin/org.example.gradlebuild.java-module-testing.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("java") | ||
id("org.gradlex.java-module-testing") | ||
} | ||
|
||
tasks.check { | ||
dependsOn(tasks.withType<io.fuchs.gradle.collisiondetector.DetectCollisionsTask>()) | ||
dependsOn(tasks.withType<org.gradlex.javamodule.dependencies.tasks.ModuleDirectivesOrderingCheck>()) | ||
dependsOn(tasks.withType<org.gradlex.javamodule.dependencies.tasks.ModuleDirectivesScopeCheck>()) | ||
} |
28 changes: 28 additions & 0 deletions
28
gradle/plugins/src/main/kotlin/org.example.gradlebuild.patch-metadata.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,28 @@ | ||
plugins { | ||
id("org.gradlex.java-ecosystem-capabilities") | ||
} | ||
|
||
dependencies.components { | ||
withModule<org.gradlex.javaecosystem.capabilities.BomComponentMetadataRule>("org.apache.poi:poi") { params(listOf("org.apache.poi:poi-excelant", "org.apache.poi:poi-ooxml", "org.apache.poi:poi-scratchpad")) } | ||
withModule<org.gradlex.javaecosystem.capabilities.BomComponentMetadataRule>("org.slf4j:slf4j-parent") { params(listOf("org.slf4j:slf4j-api", "org.slf4j:slf4j-simple", "org.slf4j:slf4j-nop", "org.slf4j:slf4j-jdk14", "org.slf4j:slf4j-log4j12", "org.slf4j:slf4j-reload4j", "org.slf4j:slf4j-jcl", "org.slf4j:slf4j-android", "org.slf4j:slf4j-ext", "org.slf4j:jcl-over-slf4j", "org.slf4j:log4j-over-slf4j", "org.slf4j:jul-to-slf4j", "org.slf4j:osgi-over-slf4j")) } | ||
withModule<org.gradlex.javaecosystem.capabilities.BomMemberComponentMetadataRule>("org.apache.poi:poi-excelant") { params("org.apache.poi:poi") } | ||
withModule<org.gradlex.javaecosystem.capabilities.BomMemberComponentMetadataRule>("org.apache.poi:poi-ooxml") { params("org.apache.poi:poi") } | ||
withModule<org.gradlex.javaecosystem.capabilities.BomMemberComponentMetadataRule>("org.apache.poi:poi-scratchpad") { params("org.apache.poi:poi") } | ||
withModule<org.gradlex.javaecosystem.capabilities.BomMemberComponentMetadataRule>("org.slf4j:slf4j-api") { params("org.slf4j:slf4j-parent") } | ||
withModule<org.gradlex.javaecosystem.capabilities.BomMemberComponentMetadataRule>("org.slf4j:slf4j-simple") { params("org.slf4j:slf4j-parent") } | ||
withModule<org.gradlex.javaecosystem.capabilities.BomMemberComponentMetadataRule>("org.slf4j:slf4j-nop") { params("org.slf4j:slf4j-parent") } | ||
withModule<org.gradlex.javaecosystem.capabilities.BomMemberComponentMetadataRule>("org.slf4j:slf4j-jdk14") { params("org.slf4j:slf4j-parent") } | ||
withModule<org.gradlex.javaecosystem.capabilities.BomMemberComponentMetadataRule>("org.slf4j:slf4j-log4j12") { params("org.slf4j:slf4j-parent") } | ||
withModule<org.gradlex.javaecosystem.capabilities.BomMemberComponentMetadataRule>("org.slf4j:slf4j-reload4j") { params("org.slf4j:slf4j-parent") } | ||
withModule<org.gradlex.javaecosystem.capabilities.BomMemberComponentMetadataRule>("org.slf4j:slf4j-jcl") { params("org.slf4j:slf4j-parent") } | ||
withModule<org.gradlex.javaecosystem.capabilities.BomMemberComponentMetadataRule>("org.slf4j:slf4j-android") { params("org.slf4j:slf4j-parent") } | ||
withModule<org.gradlex.javaecosystem.capabilities.BomMemberComponentMetadataRule>("org.slf4j:slf4j-ext") { params("org.slf4j:slf4j-parent") } | ||
withModule<org.gradlex.javaecosystem.capabilities.BomMemberComponentMetadataRule>("org.slf4j:jcl-over-slf4j") { params("org.slf4j:slf4j-parent") } | ||
withModule<org.gradlex.javaecosystem.capabilities.BomMemberComponentMetadataRule>("org.slf4j:log4j-over-slf4j") { params("org.slf4j:slf4j-parent") } | ||
withModule<org.gradlex.javaecosystem.capabilities.BomMemberComponentMetadataRule>("org.slf4j:jul-to-slf4j") { params("org.slf4j:slf4j-parent") } | ||
withModule<org.gradlex.javaecosystem.capabilities.BomMemberComponentMetadataRule>("org.slf4j:osgi-over-slf4j") { params("org.slf4j:slf4j-parent") } | ||
withModule<org.gradlex.javaecosystem.capabilities.RemoveDependenciesMetadataRule>("com.google.guava:guava") { params(listOf("com.google.guava:failureaccess", "com.google.guava:listenablefuture", "com.google.code.findbugs:jsr305", "org.checkerframework:checker-qual", "com.google.errorprone:error_prone_annotations", "com.google.j2objc:j2objc-annotations")) } | ||
} | ||
|
||
configurations.all { | ||
} |
43 changes: 43 additions & 0 deletions
43
gradle/plugins/src/main/kotlin/org.example.gradlebuild.patch-non-modules.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,43 @@ | ||
plugins { | ||
id("org.gradlex.extra-java-module-info") | ||
} | ||
|
||
extraJavaModuleInfo { | ||
failOnAutomaticModules = true | ||
module("org.apache.commons:commons-collections4", "org.apache.commons.collections4") { | ||
exportAllPackages() | ||
requireAllDefinedDependencies() | ||
} | ||
module("org.apache.velocity:velocity-engine-core", "velocity.engine.core") { | ||
exportAllPackages() | ||
requireAllDefinedDependencies() | ||
} | ||
module("org.apache.commons:commons-lang3", "org.apache.commons.lang3") { | ||
exportAllPackages() | ||
requireAllDefinedDependencies() | ||
} | ||
module("com.google.code.findbugs:jsr305", "javax.annotations.jsr305") { | ||
exportAllPackages() | ||
requireAllDefinedDependencies() | ||
} | ||
module("org.apache.commons:commons-math3", "commons.math3") { | ||
exportAllPackages() | ||
requireAllDefinedDependencies() | ||
} | ||
module("com.zaxxer:SparseBitSet", "SparseBitSet") { | ||
exportAllPackages() | ||
requireAllDefinedDependencies() | ||
} | ||
module("commons-codec:commons-codec", "org.apache.commons.codec") { | ||
exportAllPackages() | ||
requireAllDefinedDependencies() | ||
} | ||
module("com.google.guava:guava", "com.google.common") { | ||
exportAllPackages() | ||
requireAllDefinedDependencies() | ||
} | ||
module("com.github.virtuald:curvesapi", "com.github.virtuald.curvesapi") { | ||
exportAllPackages() | ||
requireAllDefinedDependencies() | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
gradle/plugins/src/main/kotlin/org.example.gradlebuild.platform.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,5 @@ | ||
plugins { | ||
id("java-platform") | ||
id("org.gradlex.java-module-versions") | ||
id("org.example.gradlebuild.java-base") | ||
} |
5 changes: 5 additions & 0 deletions
5
gradle/plugins/src/main/kotlin/org.example.gradlebuild.root.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,5 @@ | ||
plugins { | ||
id("com.autonomousapps.dependency-analysis") | ||
} | ||
|
||
defaultTasks("tasks") |
34 changes: 34 additions & 0 deletions
34
gradle/plugins/src/main/kotlin/org.example.gradlebuild.settings.settings.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,34 @@ | ||
plugins { | ||
id("com.gradle.enterprise") | ||
id("org.gradle.toolchains.foojay-resolver-convention") | ||
} | ||
|
||
dependencyResolutionManagement { | ||
repositories.maven("https://repo1.maven.org/maven2") { | ||
name = "mavenCentral" | ||
if (providers.gradleProperty("mavenCentralUsername").isPresent()) { credentials(PasswordCredentials::class) } | ||
} | ||
} | ||
|
||
rootProject.name = "gradle-project-setup-howto" | ||
includeBuild(".") | ||
include("platform") | ||
project(":platform").projectDir = layout.rootDirectory.dir("gradle/platform").asFile | ||
|
||
layout.rootDirectory.asFile.listFiles()?.filter { File(it, "build.gradle.kts").exists() }?.forEach { | ||
include(it.name) | ||
} | ||
buildCache.remote<HttpBuildCache> { | ||
url = uri("https://gradle.onepiece.software:5071/cache/") | ||
if (providers.environmentVariable("CI").getOrElse("false").toBoolean()) { | ||
isPush = true | ||
credentials.username = providers.environmentVariable("BUILD_CACHE_USER").get() | ||
credentials.password = providers.environmentVariable("BUILD_CACHE_PWD").get() | ||
} | ||
} | ||
|
||
gradleEnterprise.buildScan { | ||
termsOfServiceUrl = "https://gradle.com/terms-of-service" | ||
termsOfServiceAgree = "yes" | ||
publishAlways() | ||
} |
26 changes: 26 additions & 0 deletions
26
gradle/plugins/src/main/kotlin/org.example.gradlebuild.test-suite-end-to-end-test.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,26 @@ | ||
plugins { | ||
id("java") | ||
} | ||
|
||
if (!tasks.names.contains("checkEndToEnd")) { | ||
tasks.register("checkEndToEnd") { | ||
group = "verification" | ||
description = "Runs checks in the checkEndToEnd lifecycle" | ||
} | ||
tasks.build { dependsOn("checkEndToEnd") } | ||
} | ||
|
||
testing.suites.create<JvmTestSuite>("endToEndTest") { | ||
targets.all { | ||
tasks.named("checkEndToEnd") { dependsOn(testTask) } | ||
testTask { | ||
jvmArgs = listOf() | ||
maxParallelForks = 8 | ||
} | ||
} | ||
} | ||
|
||
tasks.named<JavaCompile>("compileEndToEndTestJava") { | ||
options.forkOptions.jvmArgs = listOf() | ||
options.compilerArgs = listOf() | ||
} |
17 changes: 17 additions & 0 deletions
17
gradle/plugins/src/main/kotlin/org.example.gradlebuild.test-suite-test.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 @@ | ||
plugins { | ||
id("java") | ||
} | ||
|
||
testing.suites.named<JvmTestSuite>("test") { | ||
targets.all { | ||
testTask { | ||
jvmArgs = listOf() | ||
maxParallelForks = 8 | ||
} | ||
} | ||
} | ||
|
||
tasks.named<JavaCompile>("compileTestJava") { | ||
options.forkOptions.jvmArgs = listOf() | ||
options.compilerArgs = listOf() | ||
} |