Skip to content

Conversation

@kggilmer
Copy link
Contributor

@kggilmer kggilmer commented Aug 11, 2021

Issue # N/A

Description of changes

  • Cause AWS codegen to be published as a module.
  • Add docs for generating service clients, based on requests from internal Kotlin developers which wish to provide Kotlin clients for their services.
  • Remove references to maven local in sdk examples in prep for public launch
  • Add example to demonstrate client generation with Weather sample
  • Some misc version bumps

Additional Testing

Ian provided some steps I performed locally to verify expected behavior:

  • clean out your Maven local repository
  • ./gradlew publishToMavenLocal -PpublishGroupName=aws.sdk.kotlin
  • verify your Maven local repository only contains aws.sdk.kotlin artifacts
  • verify each POM contains the correct name, description, and group
  • clean out your Maven local repository
  • ./gradlew publishToMavenLocal -PpublishGroupName=software.amazon.smithy.kotlin
  • verify your Maven local repository only contains software.amazon.smithy.kotlin artifacts
  • verify each POM contains the correct name, description, and group

I needed to add the crt repo to my composite build in order to keep the crt artifacts from polluting the m2 repo during build. Once that was done, the results:

Building with group name aws.sdk.kotlin after deleting ~/.m2

/home/ANT.AMAZON.COM/kggilmer/.m2/repository/
└── aws
    └── sdk
        └── kotlin
            ├── auth
            │   ├── 0.4.0-SNAPSHOT
            │   │   ├── auth-0.4.0-SNAPSHOT.jar
            │   │   ├── auth-0.4.0-SNAPSHOT-javadoc.jar
            │   │   ├── auth-0.4.0-SNAPSHOT.module
            │   │   ├── auth-0.4.0-SNAPSHOT.pom
            │   │   ├── auth-0.4.0-SNAPSHOT-sources.jar
            │   │   └── maven-metadata-local.xml
            │   └── maven-metadata-local.xml
            ├── auth-jvm
            │   ├── 0.4.0-SNAPSHOT
            │   │   ├── auth-jvm-0.4.0-SNAPSHOT.jar
            │   │   ├── auth-jvm-0.4.0-SNAPSHOT-javadoc.jar
            │   │   ├── auth-jvm-0.4.0-SNAPSHOT.module
            │   │   ├── auth-jvm-0.4.0-SNAPSHOT.pom
            │   │   ├── auth-jvm-0.4.0-SNAPSHOT-sources.jar
            │   │   └── maven-metadata-local.xml
            │   └── maven-metadata-local.xml
            ├── aws-core
            │   ├── 0.4.0-SNAPSHOT
            │   │   ├── aws-core-0.4.0-SNAPSHOT.jar
            │   │   ├── aws-core-0.4.0-SNAPSHOT-javadoc.jar
            │   │   ├── aws-core-0.4.0-SNAPSHOT.module
            │   │   ├── aws-core-0.4.0-SNAPSHOT.pom
            │   │   ├── aws-core-0.4.0-SNAPSHOT-sources.jar
            │   │   └── maven-metadata-local.xml
            │   └── maven-metadata-local.xml
            ├── aws-core-jvm
            │   ├── 0.4.0-SNAPSHOT
            │   │   ├── aws-core-jvm-0.4.0-SNAPSHOT.jar
            │   │   ├── aws-core-jvm-0.4.0-SNAPSHOT-javadoc.jar
            │   │   ├── aws-core-jvm-0.4.0-SNAPSHOT.module
            │   │   ├── aws-core-jvm-0.4.0-SNAPSHOT.pom
            │   │   ├── aws-core-jvm-0.4.0-SNAPSHOT-sources.jar
            │   │   └── maven-metadata-local.xml
            │   └── maven-metadata-local.xml
            ├── aws-json-protocols
            │   ├── 0.4.0-SNAPSHOT
            │   │   ├── aws-json-protocols-0.4.0-SNAPSHOT.jar
            │   │   ├── aws-json-protocols-0.4.0-SNAPSHOT-javadoc.jar
            │   │   ├── aws-json-protocols-0.4.0-SNAPSHOT.module
            │   │   ├── aws-json-protocols-0.4.0-SNAPSHOT.pom
            │   │   ├── aws-json-protocols-0.4.0-SNAPSHOT-sources.jar
            │   │   └── maven-metadata-local.xml
            │   └── maven-metadata-local.xml
            ├── aws-json-protocols-jvm
            │   ├── 0.4.0-SNAPSHOT
            │   │   ├── aws-json-protocols-jvm-0.4.0-SNAPSHOT.jar
            │   │   ├── aws-json-protocols-jvm-0.4.0-SNAPSHOT-javadoc.jar
            │   │   ├── aws-json-protocols-jvm-0.4.0-SNAPSHOT.module
            │   │   ├── aws-json-protocols-jvm-0.4.0-SNAPSHOT.pom
            │   │   ├── aws-json-protocols-jvm-0.4.0-SNAPSHOT-sources.jar
            │   │   └── maven-metadata-local.xml
            │   └── maven-metadata-local.xml
            ├── aws-xml-protocols
            │   ├── 0.4.0-SNAPSHOT
            │   │   ├── aws-xml-protocols-0.4.0-SNAPSHOT.jar
            │   │   ├── aws-xml-protocols-0.4.0-SNAPSHOT-javadoc.jar
            │   │   ├── aws-xml-protocols-0.4.0-SNAPSHOT.module
            │   │   ├── aws-xml-protocols-0.4.0-SNAPSHOT.pom
            │   │   ├── aws-xml-protocols-0.4.0-SNAPSHOT-sources.jar
            │   │   └── maven-metadata-local.xml
            │   └── maven-metadata-local.xml
            ├── aws-xml-protocols-jvm
            │   ├── 0.4.0-SNAPSHOT
            │   │   ├── aws-xml-protocols-jvm-0.4.0-SNAPSHOT.jar
            │   │   ├── aws-xml-protocols-jvm-0.4.0-SNAPSHOT-javadoc.jar
            │   │   ├── aws-xml-protocols-jvm-0.4.0-SNAPSHOT.module
            │   │   ├── aws-xml-protocols-jvm-0.4.0-SNAPSHOT.pom
            │   │   ├── aws-xml-protocols-jvm-0.4.0-SNAPSHOT-sources.jar
            │   │   └── maven-metadata-local.xml
            │   └── maven-metadata-local.xml
            ├── crt-util
            │   ├── 0.4.0-SNAPSHOT
            │   │   ├── crt-util-0.4.0-SNAPSHOT.jar
            │   │   ├── crt-util-0.4.0-SNAPSHOT-javadoc.jar
            │   │   ├── crt-util-0.4.0-SNAPSHOT.module
            │   │   ├── crt-util-0.4.0-SNAPSHOT.pom
            │   │   ├── crt-util-0.4.0-SNAPSHOT-sources.jar
            │   │   └── maven-metadata-local.xml
            │   └── maven-metadata-local.xml
            ├── crt-util-jvm
            │   ├── 0.4.0-SNAPSHOT
            │   │   ├── crt-util-jvm-0.4.0-SNAPSHOT.jar
            │   │   ├── crt-util-jvm-0.4.0-SNAPSHOT-javadoc.jar
            │   │   ├── crt-util-jvm-0.4.0-SNAPSHOT.module
            │   │   ├── crt-util-jvm-0.4.0-SNAPSHOT.pom
            │   │   ├── crt-util-jvm-0.4.0-SNAPSHOT-sources.jar
            │   │   └── maven-metadata-local.xml
            │   └── maven-metadata-local.xml
            ├── http
            │   ├── 0.4.0-SNAPSHOT
            │   │   ├── http-0.4.0-SNAPSHOT.jar
            │   │   ├── http-0.4.0-SNAPSHOT-javadoc.jar
            │   │   ├── http-0.4.0-SNAPSHOT.module
            │   │   ├── http-0.4.0-SNAPSHOT.pom
            │   │   ├── http-0.4.0-SNAPSHOT-sources.jar
            │   │   └── maven-metadata-local.xml
            │   └── maven-metadata-local.xml
            ├── http-client-engine-crt
            │   ├── 0.4.0-SNAPSHOT
            │   │   ├── http-client-engine-crt-0.4.0-SNAPSHOT.jar
            │   │   ├── http-client-engine-crt-0.4.0-SNAPSHOT-javadoc.jar
            │   │   ├── http-client-engine-crt-0.4.0-SNAPSHOT.module
            │   │   ├── http-client-engine-crt-0.4.0-SNAPSHOT.pom
            │   │   ├── http-client-engine-crt-0.4.0-SNAPSHOT-sources.jar
            │   │   └── maven-metadata-local.xml
            │   └── maven-metadata-local.xml
            ├── http-client-engine-crt-jvm
            │   ├── 0.4.0-SNAPSHOT
            │   │   ├── http-client-engine-crt-jvm-0.4.0-SNAPSHOT.jar
            │   │   ├── http-client-engine-crt-jvm-0.4.0-SNAPSHOT-javadoc.jar
            │   │   ├── http-client-engine-crt-jvm-0.4.0-SNAPSHOT.module
            │   │   ├── http-client-engine-crt-jvm-0.4.0-SNAPSHOT.pom
            │   │   ├── http-client-engine-crt-jvm-0.4.0-SNAPSHOT-sources.jar
            │   │   └── maven-metadata-local.xml
            │   └── maven-metadata-local.xml
            ├── http-jvm
            │   ├── 0.4.0-SNAPSHOT
            │   │   ├── http-jvm-0.4.0-SNAPSHOT.jar
            │   │   ├── http-jvm-0.4.0-SNAPSHOT-javadoc.jar
            │   │   ├── http-jvm-0.4.0-SNAPSHOT.module
            │   │   ├── http-jvm-0.4.0-SNAPSHOT.pom
            │   │   ├── http-jvm-0.4.0-SNAPSHOT-sources.jar
            │   │   └── maven-metadata-local.xml
            │   └── maven-metadata-local.xml
            ├── protocols
            │   ├── 0.4.0-SNAPSHOT
            │   │   ├── maven-metadata-local.xml
            │   │   ├── protocols-0.4.0-SNAPSHOT.jar
            │   │   ├── protocols-0.4.0-SNAPSHOT-javadoc.jar
            │   │   ├── protocols-0.4.0-SNAPSHOT.module
            │   │   ├── protocols-0.4.0-SNAPSHOT.pom
            │   │   └── protocols-0.4.0-SNAPSHOT-sources.jar
            │   └── maven-metadata-local.xml
            ├── protocols-jvm
            │   ├── 0.4.0-SNAPSHOT
            │   │   ├── maven-metadata-local.xml
            │   │   ├── protocols-jvm-0.4.0-SNAPSHOT-javadoc.jar
            │   │   ├── protocols-jvm-0.4.0-SNAPSHOT.module
            │   │   ├── protocols-jvm-0.4.0-SNAPSHOT.pom
            │   │   └── protocols-jvm-0.4.0-SNAPSHOT-sources.jar
            │   └── maven-metadata-local.xml
            ├── regions
            │   ├── 0.4.0-SNAPSHOT
            │   │   ├── maven-metadata-local.xml
            │   │   ├── regions-0.4.0-SNAPSHOT.jar
            │   │   ├── regions-0.4.0-SNAPSHOT-javadoc.jar
            │   │   ├── regions-0.4.0-SNAPSHOT.module
            │   │   ├── regions-0.4.0-SNAPSHOT.pom
            │   │   └── regions-0.4.0-SNAPSHOT-sources.jar
            │   └── maven-metadata-local.xml
            ├── regions-jvm
            │   ├── 0.4.0-SNAPSHOT
            │   │   ├── maven-metadata-local.xml
            │   │   ├── regions-jvm-0.4.0-SNAPSHOT.jar
            │   │   ├── regions-jvm-0.4.0-SNAPSHOT-javadoc.jar
            │   │   ├── regions-jvm-0.4.0-SNAPSHOT.module
            │   │   ├── regions-jvm-0.4.0-SNAPSHOT.pom
            │   │   └── regions-jvm-0.4.0-SNAPSHOT-sources.jar
            │   └── maven-metadata-local.xml
            ├── testing
            │   ├── 0.4.0-SNAPSHOT
            │   │   ├── maven-metadata-local.xml
            │   │   ├── testing-0.4.0-SNAPSHOT.jar
            │   │   ├── testing-0.4.0-SNAPSHOT-javadoc.jar
            │   │   ├── testing-0.4.0-SNAPSHOT.module
            │   │   ├── testing-0.4.0-SNAPSHOT.pom
            │   │   └── testing-0.4.0-SNAPSHOT-sources.jar
            │   └── maven-metadata-local.xml
            └── testing-jvm
                ├── 0.4.0-SNAPSHOT
                │   ├── maven-metadata-local.xml
                │   ├── testing-jvm-0.4.0-SNAPSHOT.jar
                │   ├── testing-jvm-0.4.0-SNAPSHOT-javadoc.jar
                │   ├── testing-jvm-0.4.0-SNAPSHOT.module
                │   ├── testing-jvm-0.4.0-SNAPSHOT.pom
                │   └── testing-jvm-0.4.0-SNAPSHOT-sources.jar
                └── maven-metadata-local.xml

43 directories, 139 files

Building with group name software.amazon.smithy.kotlin after deleting ~/.m2

/home/ANT.AMAZON.COM/kggilmer/.m2/repository/
└── software
    └── amazon
        └── smithy
            └── kotlin
                └── smithy-aws-kotlin-codegen
                    ├── 0.4.0-SNAPSHOT
                    │   ├── maven-metadata-local.xml
                    │   ├── smithy-aws-kotlin-codegen-0.4.0-SNAPSHOT.jar
                    │   ├── smithy-aws-kotlin-codegen-0.4.0-SNAPSHOT-javadoc.jar
                    │   ├── smithy-aws-kotlin-codegen-0.4.0-SNAPSHOT.module
                    │   ├── smithy-aws-kotlin-codegen-0.4.0-SNAPSHOT.pom
                    │   └── smithy-aws-kotlin-codegen-0.4.0-SNAPSHOT-sources.jar
                    └── maven-metadata-local.xml

6 directories, 7 files

I did not verify every pop contained the expected group, but spot checked and didn't find any surprises.

Scope

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

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

@kggilmer kggilmer requested review from aajtodd and ianbotsf August 11, 2021 23:45
Copy link
Contributor

@ianbotsf ianbotsf left a comment

Choose a reason for hiding this comment

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

Correctness: This will likely break publishing to Maven because the new codegen artifacts go to software.amazon.smithy.kotlin instead of aws.sdk.kotlin like everything else in the project. You will probably have to gate the publishing of artifacts by group name similar smithy-kotlin#458.

@ianbotsf
Copy link
Contributor

Correctness: Apparently my list of test instructions were non-exhaustive. I checked this out locally and still ran into difficulty publishing to Nexus. I think the following changes are necessary in the root build.gradle.kts:

  • Add a check for publishGroupName existence to the if block surrounding nexusPublishing
  • Move the top-level group specification from the root of the file into the if block surrounding nexusPublishing
  • Set group to the value of the publishGroupName property

See smithy-kotlin/build.gradle.kts for an example.

@kggilmer
Copy link
Contributor Author

Updated based on your directive @ianbotsf . Ran the tests again and the same files were produced in the ~/.m2 directory as in the previous change.

Copy link
Contributor

@ianbotsf ianbotsf left a comment

Choose a reason for hiding this comment

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

Looks good to me!

```
5. Disable internal annotation guards:
```kotlin
kotlin.sourceSets.all {
Copy link
Contributor

Choose a reason for hiding this comment

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

this can be handled in the smithy-build.json

    ...
    "kotlin-codegen": {
        ...
        "build": {
             "optInAnnotations": [
                 "aws.smithy.kotlin.runtime.util.InternalApi",
                 "aws.sdk.kotlin.runtime.InternalSdkApi"
             ]
        }
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed, thanks

└── smithy-build.json
```

### 2. Updating the Generated Project to Build the Client
Copy link
Contributor

Choose a reason for hiding this comment

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

if you specify the build plugin setting to generate a "root" project you shouldn't need to update the generated build file:

    "build": {
        "rootProject": true
    }

This is how the protocol tests work, we generate a "full" independent gradle project with a settings.gradle.kts, etc. If you don't generate a full project we assume that the generated code is going to be a subproject and configured by a parent somewhere in the build.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed, thanks

Create code sample project with weather example
Update docs and dependencies
Comment on lines -10 to -15
maven {
name = "kotlinSdkLocal"
url = uri(TODO("set your local repository path"))
// e.g.
//url = uri("file:///tmp/aws-sdk-kotlin-repo/m2")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Do we want to leave mavenLocal() here for local building/testing using the example projects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, my assumption was that once we were public we wouldn't need this. What in particular will need a local dependency?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

discussed offline and added mavenLocal

@kggilmer kggilmer merged commit 4b998c6 into main Aug 23, 2021
@kggilmer kggilmer deleted the feat-smithy-client-generation branch August 23, 2021 23:06
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.

3 participants