-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Reduce complexity in dependencies setup #15169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jjohannes
wants to merge
36
commits into
main
Choose a base branch
from
reduce-complexity-in-dependencies-setup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+415
−960
Open
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
adeca40
Fix: remove hard dependencies from platform
jjohannes dd2ff00
Build: turn on dependency definition in module-info (test-support)
jjohannes eb3af41
Build: turn on dependency definition in module-info (jablib)
jjohannes 47163bd
Build: add dependency analysis tasks
jjohannes e2346e2
Build: add missing mapping
jjohannes 5f97142
Build: remove duplication
jjohannes 7b0ac43
Build: add back com.fasterxml.aalto
jjohannes 72558de
Merge branch 'main' into reduce-complexity-in-dependencies-setup
koppor 699b291
Build: cleanup some patch rules
jjohannes f908266
Build: address dependency analysis results
jjohannes 196e4e9
Build: add missing dependency
jjohannes a2dcb13
Build: remove use of 'kotlin.ranges.IntRange'
jjohannes 8cd99f0
Build: activate consistent resolution for target specific resolution
jjohannes d0895a6
Build: open 'com.sun.javafx.beans' for testing
jjohannes 9d099ac
ci: update TestLens
jjohannes 8898165
tmp: disable tests for overview
jjohannes 4a37f2a
fix: off-by-one-error
jjohannes cef941a
build: handle jdk-jsobject issue centrally by metadata rule
jjohannes 88ae458
build: remove redundant dependencies from 'jabkit'
jjohannes e52d235
build: central mockitoAgent setup
jjohannes c5e7745
build: refine patch rules
jjohannes 06e1a7b
build: remove redundant dependencies from jabgui
jjohannes bb74507
build: use default config for patch rules where possible
jjohannes c3b0fda
build: target specific classpaths need the TARGET_JVM_VERSION_ATTRIBUTE
jjohannes ff15f28
build: remove redundant dependencies from jabls
jjohannes a3f953d
build: remove redundant dependencies from jabls-cli
jjohannes 3d0a587
build: remove redundant dependencies from jabsrv
jjohannes 689bf25
build: remove redundant dependencies from jabsrv-cli
jjohannes 589e47a
build: use default config in more patch rules
jjohannes 6c6869f
build: clarifying comments
jjohannes d93fa85
build: define dependency check in separate file
jjohannes 5e1d114
ci: add pipeline step to check dependency scopes
jjohannes 18dd9df
tmp: reactivate tests
jjohannes fa884e4
tmp: align mockito agent version
jjohannes 43e2f69
build: remove redundant module name definition
jjohannes 4cd72a8
build: consistently use '='
jjohannes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
55 changes: 55 additions & 0 deletions
55
build-logic/src/main/kotlin/JDKjsobjectDependencyMetadataRule.kt
This file contains hidden or 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,55 @@ | ||
| import org.gradle.api.artifacts.* | ||
| import org.gradle.api.attributes.java.TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE | ||
| import org.gradle.api.model.ObjectFactory | ||
| import org.gradle.kotlin.dsl.named | ||
| import org.gradle.nativeplatform.MachineArchitecture.ARCHITECTURE_ATTRIBUTE | ||
| import org.gradle.nativeplatform.OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE | ||
| import javax.inject.Inject | ||
|
|
||
| // Based on: https://github.com/gradlex-org/jvm-dependency-conflict-resolution/blob/main/src/main/java/org/gradlex/jvm/dependency/conflict/resolution/rules/AddTargetPlatformVariantsMetadataRule.java | ||
| @CacheableRule | ||
| abstract class JDKjsobjectDependencyMetadataRule @Inject constructor( | ||
| private val classifier: String, | ||
| private val operatingSystem: String, | ||
| private val architecture: String, | ||
| private val minJavaVersion: Int | ||
| ) : ComponentMetadataRule { | ||
|
|
||
| @get:Inject | ||
| protected abstract val objects: ObjectFactory | ||
|
|
||
| override fun execute(context: ComponentMetadataContext) { | ||
| val details = context.details | ||
| addTargetPlatformVariant(details, "Compile", "compile") | ||
| addTargetPlatformVariant(details, "Runtime", "runtime") | ||
| } | ||
|
|
||
| private fun addTargetPlatformVariant(details: ComponentMetadataDetails, nameSuffix: String, baseVariant: String) { | ||
| val name = details.id.name | ||
| val version = details.id.version | ||
|
|
||
| details.addVariant(classifier + nameSuffix + minJavaVersion, baseVariant) { | ||
| configureAttributes() | ||
| withFiles { | ||
| removeAllFiles() | ||
| addFile("$name-$version-$classifier.jar") | ||
| } | ||
| // depending on the JDK version, 'jsobject' is pulled in as extra dependency or not | ||
| withDependencies { | ||
| if (minJavaVersion >= 26) { | ||
| add("org.openjfx:jdk-jsobject") | ||
| } else { | ||
| removeIf { it.name == "jdk-jsobject" } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private fun VariantMetadata.configureAttributes() { | ||
| attributes { | ||
| attributes.attribute(OPERATING_SYSTEM_ATTRIBUTE, objects.named(operatingSystem)) | ||
| attributes.attribute(ARCHITECTURE_ATTRIBUTE, objects.named(architecture)) | ||
| attributes.attribute(TARGET_JVM_VERSION_ATTRIBUTE, minJavaVersion) | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is solving the jsobject "issue" in a way @koppor and I talked about when this came up on slack. In theory, JavaFx could publish metadata that allows Gradle to automatically make a better decission.
This rule class is adding this metadata, which allows us to remove the copy-paste solution from individual build Gradle files.