Skip to content
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

Add 'org.hiero.gradle.feature.publish-dependency-constraints' convention plugin #41

Open
jjohannes opened this issue Dec 15, 2024 · 1 comment
Assignees
Milestone

Comments

@jjohannes
Copy link
Contributor

jjohannes commented Dec 15, 2024

This feature allows users to to publish versions constraints for modules that are not direct dependencies. The versions are still defined in the hiero-dependency-versions platform project.

The plugin looks like this:

configurations.create("publishDependencyConstraint") {
    extendsFrom(configurations.internal.get())
    dependencies.all {
        val constraint = this
        project.dependencies.constraints.add("api", incoming.resolutionResult.rootComponent.map {
            (it.dependencies.single {
                it is ResolvedDependencyResult
                    && it.selected.moduleVersion?.group == constraint.group
                    && it.selected.moduleVersion?.name == constraint.name
            } as ResolvedDependencyResult).selected.moduleVersion.toString()
        })
    }
}

Modules using the plugin can then do:

dependencies {
    publishDependencyConstraint("io.grpc:grpc-netty")
    publishDependencyConstraint("io.grpc:grpc-netty-shaded")
    publishDependencyConstraint("io.grpc:grpc-okhttp")
}

This has a similar effect as versionMapping { allVariants { fromResolutionResult() } } already has for dependencies.

@jjohannes jjohannes added this to the v0.2.0 milestone Dec 15, 2024
@jjohannes jjohannes self-assigned this Dec 15, 2024
@jjohannes
Copy link
Contributor Author

Once this is released, use it in https://github.com/hashgraph/hedera-sdk-java
See: hashgraph/hedera-sdk-java#2143

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant