{"id":21981783,"url":"https://github.com/gmullerb/gradlegpluginbasecode","last_synced_at":"2025-06-10T22:03:58.509Z","repository":{"id":96572633,"uuid":"155069617","full_name":"gmullerb/gradlegpluginbasecode","owner":"gmullerb","description":"Base code from where to start developing a Gradle plugin in Groovy with little effort","archived":false,"fork":false,"pushed_at":"2018-11-05T17:21:33.000Z","size":61,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T01:19:11.442Z","etag":null,"topics":["base-code","best-practices","code-quality","code-style","codenarc","coding-standards","coding-style","gradle","gradle-api","gradle-plugin","gradle-plugin-development","groovy","groovy-plugin","jacoco","junit","plugin-development","publish-plugin","spy-project-factory","tdd","testing"],"latest_commit_sha":null,"homepage":null,"language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gmullerb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2018-10-28T12:39:24.000Z","updated_at":"2023-02-13T17:23:31.000Z","dependencies_parsed_at":"2023-04-22T21:37:47.358Z","dependency_job_id":null,"html_url":"https://github.com/gmullerb/gradlegpluginbasecode","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/gmullerb%2Fgradlegpluginbasecode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmullerb%2Fgradlegpluginbasecode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmullerb%2Fgradlegpluginbasecode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmullerb%2Fgradlegpluginbasecode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gmullerb","download_url":"https://codeload.github.com/gmullerb/gradlegpluginbasecode/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gmullerb%2Fgradlegpluginbasecode/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259159655,"owners_count":22814491,"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":["base-code","best-practices","code-quality","code-style","codenarc","coding-standards","coding-style","gradle","gradle-api","gradle-plugin","gradle-plugin-development","groovy","groovy-plugin","jacoco","junit","plugin-development","publish-plugin","spy-project-factory","tdd","testing"],"created_at":"2024-11-29T17:19:38.030Z","updated_at":"2025-06-10T22:03:58.481Z","avatar_url":"https://github.com/gmullerb.png","language":"Groovy","readme":"# Gradle Plugin's Base Code in Groovy\n\n[![license](https://img.shields.io/badge/license-UNLICENSE-green.svg)](/UNLICENSE.txt)\n\n**This project is build with the purpose of given a base code from where to start developing a Gradle plugin in Groovy with little effort.**\n\n[This project is unlicensed](/UNLICENSE.txt).\n\n## Goals\n\n* Base code for Gradle plugins development in Groovy with basic validations.\n\n## Features\n\n* Adds required plugins:\n  * **groovy**.\n  * **com.gradle.plugin-publish**.\n* Adds additional useful plugins:\n  * **all.shared.gradle.project-style-checker**.\n  * **jacoco**.\n* Configures basic important Gradle's tasks:\n  * `assemble`.\n  * `assessCommon`.\n  * `assessGradle`.\n  * `codenarcMain`.\n  * `codenarcTest`.\n  * `jacocoTestReport`.\n  * `jacocoTestCoverageVerification`.\n* Provides the basic folder structure.\n* Adds additional useful `md` files.\n\n## Extending/Developing\n\n### Prerequisites\n\n* [Java](http://www.oracle.com/technetwork/java/javase/downloads).\n* [Git](https://git-scm.com/downloads) (only if you are going to clone the project).\n\n### Getting it\n\nClone or download the project[1], in the desired folder execute:\n\n```sh\ngit clone https://github.com/gmullerb/gradlegpluginbasecode\n```\n\n\u003e [1] [Cloning a repository](https://help.github.com/articles/cloning-a-repository/)\n\n### Set up\n\n* **No need**, only download and run (It's Gradle! Yes!).\n\n### Folders structure\n\n```\n  /src\n    /main\n      /groovy\n    /test\n      /groovy\n```\n\n- `src/main/groovy`: Source code files.\n  - [SomeGradlePluginPlugin](src/main/groovy/all/shared/gradle/somePackage/SomeGradlePluginPlugin.groovy) is the entry point of the plugin.\n  - [SomeGradlePluginExtension](src/main/groovy/all/shared/gradle/somePackage/SomeGradlePluginExtension.groovy) extension of the plugin.\n- `src/test/groovy`: Test code files[1]:\n  - [SomeGradlePluginPluginTest](src/test/groovy/all/shared/gradle/somePackage/SomeGradlePluginPluginTest.groovy) some test for the plugin.\n\n\u003e [1] Tests are done with [JUnit](http://junit.org) and [Mockito](http://javadoc.io/page/org.mockito/mockito-core/latest/org/mockito/Mockito.html).\n\n### Customizing it\n\n1 . Rename `somepackage`/`SomeGradlePlugin`/`some-gradle-plugin` based on the plugin name:\n\n* `somepackage`:\n  * In folders.\n  * In package declaration in code files: `package all.shared.gradle.somepackage`:\n    * [SomeGradlePluginPlugin](src/main/groovy/all/shared/gradle/somepackage/SomeGradlePluginPlugin.groovy).\n    * [SomeGradlePluginExtension](src/main/groovy/all/shared/gradle/somepackage/SomeGradlePluginExtension.groovy).\n    * [SomeGradlePluginPluginTest](src/test/groovy/all/shared/gradle/somepackage/SomeGradlePluginPluginTest.groovy).\n* `SomeGradlePlugin`:\n  * Code files names:\n    * [SomeGradlePluginPlugin](src/main/groovy/all/shared/gradle/somepackage/SomeGradlePluginPlugin.groovy).\n    * [SomeGradlePluginExtension](src/main/groovy/all/shared/gradle/somepackage/SomeGradlePluginExtension.groovy).\n    * [SomeGradlePluginPluginTest](src/test/groovy/all/shared/gradle/somepackage/SomeGradlePluginPluginTest.groovy).\n  * Classes names:\n    * [`SomeGradlePluginPlugin`](src/main/groovy/all/shared/gradle/somepackage/SomeGradlePluginPlugin.groovy).\n    * [`SomeGradlePluginExtension`](src/main/groovy/all/shared/gradle/somepackage/SomeGradlePluginExtension.groovy).\n    * [`SomeGradlePluginPluginTest`](src/test/groovy/all/shared/gradle/somepackage/SomeGradlePluginPluginTest.groovy).\n* `some-gradle-plugin`:\n  * Plugin file name: [all.shared.gradle.some-gradle-plugin.properties](src/main/resources/META-INF/gradle-plugins/all.shared.gradle.some-gradle-plugin.properties).\n    * Change implementation class: `all.shared.gradle.somepackage.SomeGradlePluginPlugin`.\n  * [Gradle's settings file](settings.gradle):\n\n  ```gradle\n    rootProject.name = 'some-gradle-plugin'\n  ```\n\n  * [Gradle's build file](build.gradle) (if required):\n\n  ```gradle\n    apply plugin: 'all.shared.gradle.some-gradle-plugin'\n  ```\n\n  * Logs:\n    * Change the following messages:\n      * `'Added some-gradle-plugin extension'`.\n      * `'Couldn\\'t add some-gradle-plugin extension'`.\n    * In the following files:\n      * [`SomeGradlePluginPlugin`](src/main/groovy/all/shared/gradle/somepackage/SomeGradlePluginPlugin.groovy).\n      * [`SomeGradlePluginPluginTest`](src/test/groovy/all/shared/gradle/somepackage/SomeGradlePluginPluginTest.groovy).\n\n2 . Adjust the License according to requirements:\n\n* Add `License.txt` file (and remove `UNLICENSE.txt`).\n* Modify header on Code files and any other file that requires it:\n\n```gradle\n  //  Copyright (c) 2018 SomeDeveloper/SomeCompany.\n  //  Licensed under the SOME License, see LICENSE.txt\n```\n\n3 . Adjust plugin publishing information in [Gradle's build file](build.gradle):\n\n* site.\n* description.\n* tags.\n* id (can fix it here or [set it by command line](#Building-it))\n* title.\n\n```gradle\nfinal PLUGIN_SITE = 'plugin site'\n..\npluginBundle {\n  ..\n  description = 'plugin description'\n  tags = ['plugin tag 1', 'plugin tag 2']\n  plugins {\n    thePlugin {\n      id = project.hasProperty('PLUGIN_ID')\n        ? property('PLUGIN_ID')\n        : 'Set plugin id'\n      displayName = 'plugin title'\n    }\n  }\n}\n\n```\n\n4 . If the plugin is not going to be used in the same project that creates the plugin, then remove:\n\n* the `/buildSrc` folder.\n* the whole `apply plugin: 'all.shared.gradle.some-gradle-plugin'` block from [Gradle's build file](build.gradle).\n\nOptional . Run `gradlew`, this will run default task, should get `BUILD SUCCESSFUL` indicating every change went well.\n\n5 . Modify `README.md` file according to requirements.\n\n6 . Modify `CHANGELOG.md` file according to requirements.\n\n* Change title.\n* Clear logs.\n\n7 . Add additional required code and Source files.\n\n8 . Add additional required tests and Test files.\n\n* if `gradleTestKit()`  is not required, then remove it from [Gradle's build file](build.gradle).\n\n9 . Remove `.git` folder.\n\nFor actual use examples, see:\n\n* [code-common-tasks project](https://github.com/gmullerb/code-common-tasks).  \n* [base-style-config-wrapper project](https://github.com/gmullerb/base-style-config-wrapper).  \n* [file-lister project](https://github.com/gmullerb/file-lister).  \n* [project-style-checker project](https://github.com/gmullerb/project-style-checker).\n\n### Building it\n\n* To build it:\n  * `gradlew`: this will run default task, or\n  * `gradlew build`.\n\n* To assess files:\n  * `gradlew assessCommon`: will check common style of files.\n  * `gradlew assessGradle`: will check code style of Gradle's.\n  * `gradlew codenarcMain`: will check code style of Groovy's source files.\n  * `gradlew codenarcTest`: will check code style of Groovy's test files.\n  * `assemble` task depends on these four tasks.\n\n* To test code: `gradlew test`\n  * This will run jacoco code coverage [1].\n\n* To publish plugin: `./gradlew -PPLUGIN_ID=all.shared.gradle.some-gradle-plugin publishPlugins`\n  * `-PPLUGIN_ID` indicates the plugin id.\n\n* To get all the tasks for the project: `gradlew tasks --all`\n\n\u003e [1] May not get 100% since Groovy adds some extra code, that may not be tested.\n\n### Convention over Configuration\n\nAll `all.shared.gradle` plugins define:\n\n* _PluginName_**Plugin**: which contains the class implements `Plugin` interface.\n* _PluginName_**Extension**: which represent the extension of the plugin.\n* If Tasks are define, then their names will be _TaskName_**Task**.\n* If Actions are define, then their names will be _ActionName_**Action**.\n\nAll `all.shared.gradle` plugins have two **`static`** members:\n\n* `String EXTENSION_NAME`: This will have the name of the extension that the plugin add.\n  * if the plugin does not add an extension the this field will not exist.\n\n* `boolean complement(final Project project)`: will apply the plugin and return true if successful, false otherwise.\n  * this methods is **exactly equivalent to the instance `apply` method**, but without instantiate the class if not required.\n\nBoth may be useful when applying the plugin when creating custom plugins.\n\nAll `all.shared.gradle` plugins \"silently\" fail when the extension can not be added.\n\nDue to delays in the approval on [Gradle Plugin Repository](https://plugins.gradle.org/u/gmullerb)[1], is possible that the plugin is not available from there, consequently, always recommend to the plugin's user to add the following to `settings.gradle`:\n\n```gradle\n  pluginManagement {\n    repositories {\n        gradlePluginPortal()\n        maven {\n          url 'the plugin repository'\n        }\n    }\n  }\n```\n\ne.g. [2]:\n\n```gradle\n  pluginManagement {\n    repositories {\n        gradlePluginPortal()\n        maven {\n          url 'https://dl.bintray.com/gmullerb/all.shared.gradle'\n        }\n    }\n  }\n```\n\n\u003e [1] Due to new Gradle Plugin Repository policies, delays of several days, without answer, for approval of the plugin publication can happen.  \n\u003e [2] For an actual use example, see [basecode - settings.gradle](https://github.com/gmullerb/basecode/blob/master/settings.gradle).\n\n## Documentation\n\n* [`CHANGELOG.md`](CHANGELOG.md): add information of notable changes for each version here, chronologically ordered [1].\n\n\u003e [1] [Keep a Changelog](http://keepachangelog.com)\n\n## License\n\n[Unlicense](/UNLICENSE.txt)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmullerb%2Fgradlegpluginbasecode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgmullerb%2Fgradlegpluginbasecode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgmullerb%2Fgradlegpluginbasecode/lists"}