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

fix!: Rename package to match name inferred from git URL #678

Merged
merged 34 commits into from
Nov 9, 2022

Conversation

jbelkins
Copy link
Contributor

@jbelkins jbelkins commented Nov 3, 2022

Issue #

Fixes #680

Description of changes

Since the introduction of SPM, a package manifest has included a field for providing a "declared" name (i.e. set in the name property of the Package structure) that is used in other manifests to identify a package as a dependency.

In SE-0226, Swift package naming was altered to derive the name from the Git URL for the package. While the preferred way to identify a dependency is by the inferred name, Package retained the declared name field to provide backward compatibility with dependencies declared before this improvement. (Note that referring to a package by its declared name is now deprecated, but use of deprecated APIs in a package manifest does not throw warnings.)

The rationale for this change is that it allows the package manager to resolve what dependencies it needs for a specific target without resorting to downloading every dependency referenced in a manifest to see what name is declared in each dependency's own manifest. In our case, the name that is inferred from this package's URL is aws-sdk-swift (essentially the last path component with extensions dropped).

Most other Swift packages have moved to (or been created with) a declared package name that matches the inferred name. While latest Swift tools allow a manifest to identify a package by either name, consistent naming brings the following advantages:

  • Consumers who move to the inferred name will get the advantage of faster dependency resolution as promised by SE-0226.
  • Certain common tools, such as swift package edit with the --path extension (which is used by Swift-VSCode's GUI package management tools), break when the declared name and the inferred name do not match.

This will cause a breaking change but the update to requiring package manifests will be trivial; package manifests need only require this package by the new/inferred name. I do not expect our Git URL to change, so this name will be permanent unless SPM changes naming conventions again.

Tested with:

  • Corresponding name changes in smithy-swift and aws-crt-swift.
  • A successful release build (see link here.)
  • Successfully built/tested as a downstream by smithy-swift (se PR above).

Specific changes:

  • Declared package name updated to match the inferred name
  • codegen/Package.swift updated to use inferred naming
  • scripts/generatePackageSwift.swift updated to render manifest with inferred naming
  • Fix a few generated import statements which were importing by package name (which worked by coincidence until this name change)

New/existing dependencies impact assessment, if applicable

No new dependencies were added to this change.

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

@jbelkins jbelkins requested review from epau and ganeshnj November 3, 2022 22:33
Copy link
Contributor

@epau epau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm deferring to @ganeshnj though since this is a breaking change

@ganeshnj
Copy link
Contributor

ganeshnj commented Nov 4, 2022

When we do the release with this change, we must create a discussion with code snippet to show how to migrate from old package name to aws-sdk-swift.

@jbelkins
Copy link
Contributor Author

jbelkins commented Nov 4, 2022

When we do the release with this change, we must create a discussion with code snippet to show how to migrate from old package name to aws-sdk-swift.

You mean in the release notes for the release?

@jbelkins jbelkins merged commit 780a389 into main Nov 9, 2022
@jbelkins jbelkins deleted the jbe/package_rename branch November 9, 2022 14:42
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.

Rename packages to match names inferred from git URLs
3 participants