Skip to content

Commit

Permalink
feat(composite-build): add gradle composite build (#4710)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewFossAWS committed May 9, 2023
1 parent 5d01f58 commit e2ce8b4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,7 @@ codegen/*/bin
benchmark/size/raw

etc/
temp/
temp/

# Gradle composite build properties
codegen/local.properties
16 changes: 16 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,22 @@ lerna run build --scope [package name] --include-dependencies

You don't need to run this command if the dependency packages are not changed.

## Gradle Composite Build

The `aws-sdk-js-v3` repository uses Gradle as a build tool and has Gradle based dependencies such as `smithy` and `smithy-typescript`.
To improve development experience when making changes to the dependencies locally, we can
use the [Gradle composite build feature](https://docs.gradle.org/current/userguide/composite_builds.html),
which allows picking up any local changes from dependencies automatically and rebuilding them when `aws-sdk-js-v3` is rebuilt.

This also makes IDE integration more pleasant, as Intellij IDEA will open the included projects as modules when the Gradle build is imported.

In order to utilise this feature, create a file `local.properties` in the `codegen` directory with the following content:

```
smithy=/Volumes/workplace/smithy
smithy-typescript=/Volumes/workplace/smithy-typescript
```

## Build caching

Build caching is optionally available via Turborepo. See `turbo.json`.
Expand Down
17 changes: 17 additions & 0 deletions codegen/settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,25 @@
* permissions and limitations under the License.
*/

import java.io.FileInputStream
import java.nio.charset.StandardCharsets.UTF_8

rootProject.name = "codegen"
include(":smithy-aws-typescript-codegen")
include(":sdk-codegen")
include(":protocol-test-codegen")
include(":generic-client-test-codegen")

file(
java.nio.file.Paths.get(rootProject.projectDir.absolutePath, "local.properties"))
.takeIf { it.isFile }?.let { f ->
java.util.Properties().apply { load(java.io.InputStreamReader(FileInputStream(f), UTF_8)) }
}?.run {
listOf("smithy-typescript", "smithy")
.map { it to getProperty(it) }
.filterNot { it.second.isNullOrEmpty() }
.onEach { println("Found property `${it.first}`: ${it.second}") }
.map { file(it.second) }
.filter { it.isDirectory }
.forEach { includeBuild(it.absolutePath) }
}

0 comments on commit e2ce8b4

Please sign in to comment.