{"id":19656709,"url":"https://github.com/daggerok/gradle-kotlin-dsl-plugin-buildsrc","last_synced_at":"2025-04-28T18:32:53.961Z","repository":{"id":151041713,"uuid":"173207494","full_name":"daggerok/gradle-kotlin-dsl-plugin-buildSrc","owner":"daggerok","description":"Simple internal (located inside buildSrc folder) Gradle plugin example, written in Kotlin using Gradle Kotlin DSL","archived":false,"fork":false,"pushed_at":"2019-03-01T01:20:00.000Z","size":351,"stargazers_count":6,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T10:23:11.705Z","etag":null,"topics":["gradle-kotlin-dsl","gradle-plugin","gradle-plugin-kotlin"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daggerok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-01T00:18:47.000Z","updated_at":"2023-06-23T07:29:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"d04fa0bb-0da7-498c-81ed-0ec1314ce5a7","html_url":"https://github.com/daggerok/gradle-kotlin-dsl-plugin-buildSrc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daggerok%2Fgradle-kotlin-dsl-plugin-buildSrc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daggerok%2Fgradle-kotlin-dsl-plugin-buildSrc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daggerok%2Fgradle-kotlin-dsl-plugin-buildSrc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daggerok%2Fgradle-kotlin-dsl-plugin-buildSrc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daggerok","download_url":"https://codeload.github.com/daggerok/gradle-kotlin-dsl-plugin-buildSrc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251366138,"owners_count":21578080,"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","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":["gradle-kotlin-dsl","gradle-plugin","gradle-plugin-kotlin"],"created_at":"2024-11-11T15:28:40.734Z","updated_at":"2025-04-28T18:32:53.943Z","avatar_url":"https://github.com/daggerok.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gradle-kotlin-dsl-plugin-buildSrc\nSimple internal (located in `buildSrc`) Gradle plugin example, written in Kotlin using Gradle Kotlin DSL\n\n- Travis CI [![Build Status](https://travis-ci.org/daggerok/gradle-kotlin-dsl-plugin-buildSrc.svg?branch=master)](https://travis-ci.org/daggerok/gradle-kotlin-dsl-plugin-buildSrc)\n- GitHub [Pages](https://daggerok.github.io/gradle-kotlin-dsl-plugin-buildSrc/) documentation\n- GitHub [daggerok/gradle-kotlin-dsl-plugin-buildSrc](https://github.com/daggerok/gradle-kotlin-dsl-plugin-buildSrc) repository \n\n## generate a project\n\n```bash\ngradle init --type=basic --dsl=kotlin --project-name=gradle-kotlin-dsl-plugin-buildSrc\n```\n\n## create buildSrc\n\n```bash\nmkdir -p buildSrc/src/main/kotlin/com/github/daggerok/plugin\n```\n\n## configure plugin\n\ncreate `buildSrc/build.gradle.kts` file:\n\n```kotlin\nplugins {\n  `kotlin-dsl`\n}\n\nrepositories { // required by kotlin-dsl plugin dependencies\n  jcenter()\n}\n\ngradlePlugin {\n  plugins {\n    register(\"hello-plugin\") {\n      id = \"hello\"\n      implementationClass = \"com.github.daggerok.plugin.HelloPlugin\"\n    }\n  }\n}\n\nconfigure\u003cKotlinDslPluginOptions\u003e {\n  experimentalWarning.set(false)\n}\n```\n\n## plugin implementation\n\n### prepare structure for your configuration extension\n\ncreate `./buildSrc/src/main/kotlin/com/github/daggerok/plugin/HelloPlugin.kt` file:\n\n```kotlin\nopen class HelloExtension {\n  var greeting: String = \"Hello\"\n  var name: String = \"buddy\"\n}\n```\n\n### prepare plugin\n\n```kotlin\nclass HelloPlugin : Plugin\u003cProject\u003e {\n  override fun apply(project: Project): Unit = project.run {\n    val hello = project.extensions.create\u003cHelloExtension\u003e(\"HelloExtension\")\n    project.extensions.add(\"hello\", hello)\n    tasks.register(\"hello\") {\n      doLast {\n        println(\"${hello.greeting.capitalize()}, ${hello.name.capitalize()}!\")\n      }\n    }\n  }\n}\n```\n\n## plugin usage\n\n```kotlin\nplugins {\n  hello\n}\n\nhello {\n  greeting = \"hola\"\n  name = \"pablo\"\n}\n```\n\n```bash\n./gradlew hello\n# output\nHola, Pablo!\n```\n\n## resources\n\n- [Writing Custom Plugins](https://docs.gradle.org/current/userguide/custom_plugins.html)\n- [Gradle Kotlin DSL samples](https://github.com/gradle/kotlin-dsl/tree/master/samples)\n- [Gradle Kotlin DSL Primer](https://docs.gradle.org/current/userguide/kotlin_dsl.html#sec:kotlin-dsl_plugin)\n- [Gradle Tutorials](https://gradle.org/guides/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaggerok%2Fgradle-kotlin-dsl-plugin-buildsrc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaggerok%2Fgradle-kotlin-dsl-plugin-buildsrc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaggerok%2Fgradle-kotlin-dsl-plugin-buildsrc/lists"}