{"id":13770275,"url":"https://github.com/smithy-lang/smithy-gradle-plugin","last_synced_at":"2025-10-07T23:46:03.718Z","repository":{"id":37534413,"uuid":"183308735","full_name":"smithy-lang/smithy-gradle-plugin","owner":"smithy-lang","description":"Smithy plugin for Gradle","archived":false,"fork":false,"pushed_at":"2025-06-27T12:12:37.000Z","size":619,"stargazers_count":34,"open_issues_count":2,"forks_count":22,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-10-01T00:33:52.628Z","etag":null,"topics":["build-tool","gradle","gradle-plugin","smithy"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smithy-lang.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-24T21:22:02.000Z","updated_at":"2025-08-29T15:32:46.000Z","dependencies_parsed_at":"2023-07-28T17:18:07.590Z","dependency_job_id":"9f40cf77-7726-4e65-b2ef-abe7a1ca305c","html_url":"https://github.com/smithy-lang/smithy-gradle-plugin","commit_stats":null,"previous_names":["smithy-lang/smithy-gradle-plugin","awslabs/smithy-gradle-plugin"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/smithy-lang/smithy-gradle-plugin","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smithy-lang%2Fsmithy-gradle-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smithy-lang%2Fsmithy-gradle-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smithy-lang%2Fsmithy-gradle-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smithy-lang%2Fsmithy-gradle-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smithy-lang","download_url":"https://codeload.github.com/smithy-lang/smithy-gradle-plugin/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smithy-lang%2Fsmithy-gradle-plugin/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278866937,"owners_count":26059670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["build-tool","gradle","gradle-plugin","smithy"],"created_at":"2024-08-03T17:00:35.841Z","updated_at":"2025-10-07T23:46:03.701Z","avatar_url":"https://github.com/smithy-lang.png","language":"Java","funding_links":[],"categories":["Build tools"],"sub_categories":[],"readme":"# Smithy Gradle Plugins\n[![Build Status](https://github.com/awslabs/smithy-gradle-plugin/workflows/ci/badge.svg)](https://github.com/awslabs/smithy-gradle-plugin/actions/workflows/ci.yml)\n\nThis project provides plugins to integrate [Smithy](https://smithy.io/) with [Gradle](https://gradle.org/). \nThese plugins can build artifacts from Smithy models, generate JARs that contain Smithy models found in Java projects, \nand generate JARs that contain filtered projections of Smithy models.\n\n- [`smithy-base` plugin](#smithy-base-plugin):  This plugin configures the basic source sets and configurations for a Smithy project. It also creates \n  the base `smithyBuild` task for the project that builds the Smithy models in the project.\n- [`smithy-jar` plugin](#smithy-jar-plugin): Adds built Smithy files to an existing `jar` task such as that created by the Java or Kotlin plugins. \n  The `smithy-jar` plugin also adds build metadata and tags to the JAR's MANIFEST. The `smithy-jar` plugin applies the `smithy-base` plugin when it is applied.\n- [`smithy-trait-package`](#smithy-trait-package-plugin): Configures a Java project for a custom trait definition. This plugin can be used in conjunction \n  with the [`trait-codegen`](https://github.com/smithy-lang/smithy/tree/main/smithy-trait-codegen) smithy build plugin to generate Java representations \n  of traits from Smithy IDL trait definitions. \n  The `smithy-trait-package` plugin applies both the `java-library` and `smithy-jar` plugins.\n\n## Examples\nStandalone examples are available for each of the provided plugins and can be found in the [examples](./examples) \ndirectory. In addition to serving as documentation, these examples are run as an integration tests for the plugins.\n\nThese examples can be copied into your workspace using the `smithy init` command line tool as follows:\n\n```console\nsmithy init -t \u003cEXAMPLE_NAME\u003e -o \u003cOUTPUT_DIRECTORY\u003e --url https://github.com/smithy-lang/smithy-gradle-plugin\n```\n\nYou can list all examples available in this repository as follows: \n```consoles\nsmithy init --list --url https://github.com/smithy-lang/smithy-gradle-plugin\n```\n\n**Note**: If you do not have the Smithy CLI installed, follow the [installation guide](https://smithy.io/2.0/guides/smithy-cli/cli_installation.html) \nto install it now.\n\n## Guide\nA detailed guide can be found here: https://smithy.io/2.0/guides/gradle-plugin/\n\n## Querying models in your project\nAll the Smithy Gradle plugins above will add a `select` task to your Gradle project. This task will execute the \nSmithy CLI `select` command, allowing you to queries a model using a [selector](https://smithy.io/2.0/spec/selectors.html#selectors).\n\nFor example, to query all trait definitions in your project you could use the `select` task as follows:\n```console\ngradle select --selector '[trait|trait]'\n```\n\nor with the Gradle wrapper:\n```console\n./gradlew select --selector '[trait|trait]'\n```\n\n## Plugins\n### Smithy Base Plugin\nThe `smithy-base` plugin is a capability plugin primarily intended to be applied by other Smithy gradle plugins such as \ncodegen plugins and the `smithy-jar` plugin.\n\nThis plugin sets up the `smithy` source set extension and the required `smithyCli` and \n`smithyBuild` configurations. The `smithy-base` plugin will also create a `smithyBuild` task \nto build the models for the main component of the project if a `main` sourceSet is configured \nfor the project.\n\n**Note**: The `smithy-base` plugin does not create any sourceSets on its own and will not set up\na `smithyBuild` task unless another plugin sets up a `main` sourceSet.\n\n\n#### Usage\nThis plugin can be applied to a project as follows:\n```kotlin \n// build.gradle.kts\nplugins {\n    id(\"software.amazon.smithy.gradle.smithy-base\").version(\"1.3.0\")\n}\n```\nHowever, no tasks will be created unless.\nSee the [examples](./examples/base-plugin) directory for examples of using this plugin.\n\n### Smithy Jar Plugin\nThe `smithy-jar` plugin will build Smithy models for a project and add Smithy models to an\nexisting `jar` task within the project. \n\nThis plugin is primarily intended for the following use cases: \n- Including Smithy models alongside custom trait definitions in Java or another language.\n- Packaging common Smithy models or validators into a JAR for consumption by other Smithy projects\n- Including Smithy models in Smithy build plugin packages\n\n#### Usage\nThe `smithy-jar` plugin must be used with another plugin that creates a `jar` task. For example, \n\n```kotlin \n// build.gradle.kts\nplugins {\n    id(\"java-library\") // creates jar task\n    id(\"software.amazon.smithy.gradle.smithy-jar\").version(\"1.3.0\")\n}\n```\n\nSee the [examples](./examples/jar-plugin) directory for examples of using this plugin.\n\n### Smithy Trait Package Plugin\nThe `smithy-trait-package` plugin will configure a Java project for a custom Smithy trait. The `java-library` and `smithy-jar`\nplugins are automatically applied and any traits generated with the `trait-codegen` build plugin will be added to the \nrelevant sourceSets.\n\nThis plugin should be used to: \n- Create a package containing any combination of hand-written and code-generated custom trait definitions.\n- Create a trait package with [custom validators](https://smithy.io/2.0/guides/model-linters.html#writing-custom-validators).\n\n#### Usage\nThe `smithy-trait-package` plugin can be applied on its own to easily configure a trait package. \n\n```kotlin \n// build.gradle.kts\nplugins {\n    id(\"software.amazon.smithy.gradle.smithy-trait-package\").version(\"1.3.0\")\n}\n```\n\n*Note*: To use the `trait-codegen` Smithy build plugin to generate Java trait definitions with this Gradle plugin,\nusers must still apply the plugin in their `smithy-build.json`.\n\n*Note*: The `smithy-trait-package` plugin does not automatically apply any publishing plugins. If you wish to publish your\ntrait to Maven or another package repository you will need to add and configure a publishing plugin. We recommend using\nthe [jreleaser](https://jreleaser.org/) Gradle plugin to publish your package.\n\nSee the [examples](./examples/trait-package-plugin) directory for examples of using this plugin.\n\n## Configuration\n### Customizing source directories  \nSmithy gradle plugins assumes Smithy model files (`*.smithy`) are organized in a similar way as Java source files, in sourceSets.\nThe `smithy-base` plugin adds a new sources block named `smithy` to every sourceSet. By default, this source block will include \nSmithy models in `model/`,`src/$sourceSetName/smithy` and`src/$sourceSetName/resources/META-INF/smithy`. New source directories can \nbe added to a `smithy` sources block as follows:\n\n```kotlin\n// build.gradle.kts\nsourceSets {\n    main {\n        smithy {\n            srcDir(\"includes/\")\n        }\n    }\n}\n```\n\n### Customize output directory\nBy default, Smithy build artifacts will be placed in the project build directory\nin a `smithyprojections/` directory. There are two ways to override the output directory. \nThe first method is to set the `outputDirectory` property in the `smithy-build.json` config \nfor your Smithy project. For example:\n\n```json \n# smithy-build.json\n{\n    \"outputDirectory\": \"build/output\",\n    ...\n} \n```\n\nThe output directory can also be set explicitly configured for the plugin: \n```kotlin\n// build.gradle.kts\nsmithy {\n    outputDirectory.set(file(\"path/to/output\"))\n}\n```\n\n\n**Note**: Setting the output directory on the plugin extension will override any \n`outputDirectory` property set in the `smithy-build` config.\n\n\n### Smithy Build Dependencies\nThe `smithy-base` plugin adds a `smithyBuild` configuration that can be used to \nspecify dependencies that will only be used for calling smithy build but will \nnot be included in any generated JARs. \n\n```kotlin \n// build.gradle.kts\ndependencies {\n    smithyBuild(\"com.example.software:build-only:1.0.0\")\n}\n```\n\n\n### Set `smithy-build` configs to use\nBy default, the plugin will look for a file called `smithy-build.json` at the \nproject's root and will use that as the [`smithy-build`](https://smithy.io/2.0/guides/building-models/build-config.html)\nconfig for your project. If no `smithy-build.json` file is found then a default \nempty build config is used to build the project.\n\nAlternatively, you can explicitly configure one or more `smithy-build` configs to use \nfor your project as follows:\n\n```kotlin\n// build.gradle.kts\nsmithy { \n    smithyBuildConfigs.set(files(\"smithy-build-config.json\"))\n}\n```\n\n### Set Smithy Tags to add to a JAR\nWhen the `smithy-jar` plugin is applied to a project it can add a number of Smithy \ntags to the MANIFEST of a generated JAR. These tags can be used by downstream consumers\nto filter which models to include in projections. Tags can be configured for the plugin \nas follows: \n\n```kotlin \n// build.gradle.kts \nsmithy {\n    tags.addAll(\"tag1\", \"anotherTag\", \"anotherTag2\")\n}\n```\n\n### Fork a new process when executing Smithy CLI commands\nBy default, Smithy CLI commands are run in the same process as Gradle, but inside a thread with a custom class loader. \nThis should work in most cases, but there is an option to run inside a process if necessary. To run Smithy CLI commands\nin a process set the `fork` configuration option to `true`: \n\n```kotlin \n// build.gradle.kts\nsmithy {\n    fork.set(true)\n}\n```\n\n\n### Disable Smithy Formatter\nBy default, the `smithy format` CLI command is executed on all source directories. \nThis opinionated formatter follows the best practices recommended by the Smithy team. \nIt is possible to disable the formatter by setting the `format` setting on the plugin \nextension to `false`: \n\n```kotlin\n// build.gradle.kts \nsmithy {\n    format.set(false)\n}\n```\n\n## Documentation\n\nSee https://smithy.io/2.0/guides/gradle-plugin/index.html\n\n\n## License\n\nThis library is licensed under the Apache 2.0 License. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmithy-lang%2Fsmithy-gradle-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmithy-lang%2Fsmithy-gradle-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmithy-lang%2Fsmithy-gradle-plugin/lists"}