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

Allow access to smithyCli configuration #130

Merged
merged 4 commits into from
Mar 15, 2024

Conversation

hpmellema
Copy link
Contributor

@hpmellema hpmellema commented Mar 14, 2024

Background

  • Makes the smithyCli configuration visible so a customer can explicitly set the CLI artifact without setting a smithy-model dependency in the runtimeClasspath configuration (typically through the implementation configuration.

While the CLI version can be resolved from a runtime dependency on smithy-model, users sometimes want to explicitly configure a CLI artifact to use without any runtime dependencies on the smithy-model package.

Currently the best way to do this is with a build script dependency:

val smithyVersion: String by project

buildscript {
    val smithyVersion: String by project

    repositories {
        mavenLocal()
        mavenCentral()
    }
    dependencies {
        "classpath"("software.amazon.smithy:smithy-cli:$smithyVersion")
    }
}

With this change a customer can set the cli artifact as:

dependencies {
    val smithyVersion: String by project

    smithyCli("software.amazon.smithy:smithy-cli:$smithyVersion")
}

Which results in the following resolved configurations:

smithyCli - Configuration for Smithy CLI and associated dependencies.
\--- software.amazon.smithy:smithy-cli:1.45.0
     +--- software.amazon.smithy:smithy-model:1.45.0
     |    \--- software.amazon.smithy:smithy-utils:1.45.0
     +--- software.amazon.smithy:smithy-build:1.45.0
     |    +--- software.amazon.smithy:smithy-utils:1.45.0
     |    \--- software.amazon.smithy:smithy-model:1.45.0 (*)
     +--- software.amazon.smithy:smithy-diff:1.45.0
     |    +--- software.amazon.smithy:smithy-utils:1.45.0
     |    \--- software.amazon.smithy:smithy-model:1.45.0 (*)
     \--- software.amazon.smithy:smithy-syntax:1.45.0
          +--- software.amazon.smithy:smithy-model:1.45.0 (*)
          \--- software.amazon.smithy:smithy-utils:1.45.0

runtimeClasspath - Runtime classpath of source set 'main'.
No dependencies

What happens when conflicting deps are set?

If the smithy cli dependency is set in the smithyCli configuration then we will not attempt to resolve the cli artifact version from the smithy-model dependency.

If conflicting dependencies are set then the higher version is used by default unless a customer sets up a custom resolution strategy. The smithyCli configuration extends the runtimeClasspath configuration (if available) so it will use the higher version set in the runtimeClasspath configuration but the reverse will not be true.

For example the following:

dependencies {
    smithyCli("software.amazon.smithy:smithy-cli:1.45.0")
    implementation("software.amazon.smithy:smithy-cli:1.43.0")
}

Will resolve to:

smithyCli - Configuration for Smithy CLI and associated dependencies.
+--- software.amazon.smithy:smithy-cli:1.43.0 -> 1.45.0
|    +--- software.amazon.smithy:smithy-model:1.45.0
|    |    \--- software.amazon.smithy:smithy-utils:1.45.0
|    +--- software.amazon.smithy:smithy-build:1.45.0
|    |    +--- software.amazon.smithy:smithy-utils:1.45.0
|    |    \--- software.amazon.smithy:smithy-model:1.45.0 (*)
|    +--- software.amazon.smithy:smithy-diff:1.45.0
|    |    +--- software.amazon.smithy:smithy-utils:1.45.0
|    |    \--- software.amazon.smithy:smithy-model:1.45.0 (*)
|    \--- software.amazon.smithy:smithy-syntax:1.45.0
|         +--- software.amazon.smithy:smithy-model:1.45.0 (*)
|         \--- software.amazon.smithy:smithy-utils:1.45.0
\--- software.amazon.smithy:smithy-cli:1.45.0 (*)

runtimeClasspath - Runtime classpath of source set 'main'.
\--- software.amazon.smithy:smithy-cli:1.43.0
     +--- software.amazon.smithy:smithy-model:1.43.0
     |    \--- software.amazon.smithy:smithy-utils:1.43.0
     +--- software.amazon.smithy:smithy-build:1.43.0
     |    +--- software.amazon.smithy:smithy-utils:1.43.0
     |    \--- software.amazon.smithy:smithy-model:1.43.0 (*)
     +--- software.amazon.smithy:smithy-diff:1.43.0
     |    +--- software.amazon.smithy:smithy-utils:1.43.0
     |    \--- software.amazon.smithy:smithy-model:1.43.0 (*)
     \--- software.amazon.smithy:smithy-syntax:1.43.0
          +--- software.amazon.smithy:smithy-model:1.43.0 (*)
          \--- software.amazon.smithy:smithy-utils:1.43.0

While the following:

For example the following: 

dependencies {
smithyCli("software.amazon.smithy:smithy-cli:1.45.0")
implementation("software.amazon.smithy:smithy-model:1.43.0")
}


Resolves to: 

smithyCli - Configuration for Smithy CLI and associated dependencies.
+--- software.amazon.smithy:smithy-model:1.43.0 -> 1.45.0
| --- software.amazon.smithy:smithy-utils:1.45.0
--- software.amazon.smithy:smithy-cli:1.45.0
+--- software.amazon.smithy:smithy-model:1.45.0 ()
+--- software.amazon.smithy:smithy-build:1.45.0
| +--- software.amazon.smithy:smithy-utils:1.45.0
| --- software.amazon.smithy:smithy-model:1.45.0 (
)
+--- software.amazon.smithy:smithy-diff:1.45.0
| +--- software.amazon.smithy:smithy-utils:1.45.0
| --- software.amazon.smithy:smithy-model:1.45.0 ()
--- software.amazon.smithy:smithy-syntax:1.45.0
+--- software.amazon.smithy:smithy-model:1.45.0 (
)
--- software.amazon.smithy:smithy-utils:1.45.0

runtimeClasspath - Runtime classpath of source set 'main'.
--- software.amazon.smithy:smithy-model:1.43.0
--- software.amazon.smithy:smithy-utils:1.43.0


#### Testing
* Added a new integration test to test this behavior.

---
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@hpmellema hpmellema marked this pull request as ready for review March 14, 2024 18:49
@hpmellema hpmellema requested a review from a team as a code owner March 14, 2024 18:49
@hpmellema hpmellema requested a review from sugmanue March 14, 2024 18:49
@hpmellema hpmellema merged commit 118fdeb into main Mar 15, 2024
4 checks passed
@hpmellema hpmellema deleted the allow-access-to-cli-configuration branch March 15, 2024 13:32
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

Successfully merging this pull request may close these issues.

None yet

2 participants