Skip to content

Commit

Permalink
Use upcoming 'java-module-dependencies' features
Browse files Browse the repository at this point in the history
  • Loading branch information
jjohannes committed Jul 15, 2024
1 parent 61b683c commit 494cbf4
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 74 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ With that accidental complexity in the module setup is avoided.

### Learn more

- Explore this repository [commit-by-commit](https://github.com/jjohannes/java-module-system/commits/main/)
- Browse slides of my 2024 talk [Combining Java Modules and Gradle for elegant project structures](docs/java-modules-and-gradle-2024.pdf) which is based on this sample
- Browse slides of my 2023 talk [Modularizing Projects with the Java Module System and Gradle](docs/java-modules-and-gradle-2023.pdf) which gives more background on the modularity concepts in Java and Gradle
- Watch my YouTube playlist [Understanding Gradle – Java Modularity](https://www.youtube.com/playlist?list=PLWQK2ZdV4Yl092zlY7Dy1knCmi0jhTH3H) for even more information on modularity in Java and how it is handled in Gradle
Expand All @@ -30,6 +29,6 @@ With that accidental complexity in the module setup is avoided.
- Run `./gradlew assembleMacos-14`
- Run `./gradlew assembleUbuntu-22.04`

The example also builts on GitHub.
The example also builds on GitHub.
The result can be explored here:
https://github.com/jjohannes/java-module-system/actions
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
org.gradle.caching=true
org.gradle.configuration-cache=true
dependency.analysis.autoapply=false
# org.gradle.unsafe.isolated-projects=true
2 changes: 1 addition & 1 deletion gradle/plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies {
implementation("com.autonomousapps:dependency-analysis-gradle-plugin:1.32.0")
implementation("com.gradle:develocity-gradle-plugin:3.17.5")
implementation("org.gradlex:extra-java-module-info:1.8")
implementation("org.gradlex:java-module-dependencies:1.6.6")
implementation("org.gradlex:java-module-dependencies:1.7")
implementation("org.gradlex:java-module-packaging:0.1")
implementation("org.gradlex:java-module-testing:1.4")
implementation("org.gradlex:jvm-dependency-conflict-resolution:2.1.1")
Expand Down
25 changes: 25 additions & 0 deletions gradle/plugins/src/main/kotlin/build-system.settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import org.gradle.caching.http.HttpBuildCache
import org.gradle.kotlin.dsl.remote

plugins {
id("com.gradle.develocity")
id("org.gradlex.java-module-dependencies")
}

develocity {
buildScan {
termsOfUseUrl = "https://gradle.com/help/legal-terms-of-use"
termsOfUseAgree = "yes"
}
}

buildCache {
remote<HttpBuildCache> {
url = uri("https://cache.onepiece.software/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()
}
}
}
3 changes: 3 additions & 0 deletions gradle/plugins/src/main/kotlin/dependency-analysis.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
id("com.autonomousapps.dependency-analysis")
}
10 changes: 6 additions & 4 deletions gradle/plugins/src/main/kotlin/java-module.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import org.gradlex.javamodule.dependencies.tasks.ModuleDirectivesScopeCheck

plugins {
id("java")
id("org.gradlex.jvm-dependency-conflict-resolution")
id("org.gradlex.java-module-dependencies")
id("java-library")
id("org.gradlex.java-module-packaging")
id("org.gradlex.java-module-testing")
id("dependency-analysis")
id("metadata-patch")
}

version = providers.fileContents(isolated.rootProject.projectDirectory
Expand Down Expand Up @@ -59,5 +61,5 @@ tasks.withType<Test>().configureEach {
}

tasks.check {
dependsOn(tasks.checkAllModuleInfo)
dependsOn(tasks.withType<ModuleDirectivesScopeCheck>())
}

This file was deleted.

1 change: 1 addition & 0 deletions modules/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
application.mainClass = "app.App"
1 change: 0 additions & 1 deletion modules/app/main-class.txt

This file was deleted.

25 changes: 23 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,26 @@ pluginManagement {
includeBuild("gradle/plugins")
}
plugins {
id("opinionated-java-module-build-system")
}
id("build-system")
}
rootPlugins {
id("dependency-analysis")
}

javaModules {
// Location of own modules
directory("modules") {
plugin("java-module")
group = "org.example"
module("app") { plugin("application") }
}
// Versions of third party modules
versions("gradle/versions")
}

dependencyResolutionManagement {
//Locations of third party modules
repositories {
mavenCentral()
}
}

0 comments on commit 494cbf4

Please sign in to comment.