{"id":20604173,"url":"https://github.com/assertj/assertj-generator-gradle-plugin","last_synced_at":"2026-02-27T18:47:32.480Z","repository":{"id":68228554,"uuid":"92816640","full_name":"assertj/assertj-generator-gradle-plugin","owner":"assertj","description":"Gradle plugin for the AssertJ Generator","archived":false,"fork":false,"pushed_at":"2025-04-14T21:50:19.000Z","size":389,"stargazers_count":32,"open_issues_count":15,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-15T02:17:12.195Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/assertj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-05-30T09:22:04.000Z","updated_at":"2025-02-21T21:59:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"c9286511-dbc1-4474-862d-c59303551a31","html_url":"https://github.com/assertj/assertj-generator-gradle-plugin","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assertj%2Fassertj-generator-gradle-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assertj%2Fassertj-generator-gradle-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assertj%2Fassertj-generator-gradle-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/assertj%2Fassertj-generator-gradle-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/assertj","download_url":"https://codeload.github.com/assertj/assertj-generator-gradle-plugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248991561,"owners_count":21194894,"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":[],"created_at":"2024-11-16T09:21:19.417Z","updated_at":"2026-02-27T18:47:32.428Z","avatar_url":"https://github.com/assertj.png","language":"Kotlin","readme":"# AssertJ Generator Gradle Plugin\n\n![Build Status](https://img.shields.io/github/actions/workflow/status/assertj/assertj-generator-gradle-plugin/ci.yml)\n[![Gradle Plugin Portal](https://img.shields.io/gradle-plugin-portal/v/org.assertj.generator)](https://plugins.gradle.org/plugin/org.assertj.generator)\n[![Licence](https://img.shields.io/github/license/assertj/assertj-generator-gradle-plugin)](./LICENSE)\n\nThis is the source for the Gradle plugin for the\n[AssertJ Generator](http://joel-costigliola.github.io/assertj/assertj-assertions-generator.html). This plugin leverages\nexisting Gradle [SourceSet](https://docs.gradle.org/current/dsl/org.gradle.api.tasks.SourceSet.html) API to make it\neasier to integrate the AssertJ Generator into existing Gradle-based projects. The configurations available mimic those\nprovided by\nthe [AssertJ Generator Maven Plugin](http://joel-costigliola.github.io/assertj/assertj-assertions-generator-maven-plugin.html).\n\nThis plugin will automatically detect Kotlin, and Java sources. The plugin automatically configures the generation step\nfor each `SourceSet` (except `test`) in a Gradle project when applied.\n\n## Quick Start\n\nBelow is a minimal configuration that will cause _all_ classes defined in the `main` source set to have an `assertJ`\nassertion generated for it. All of these will be placed into the longest common package of the sources presented.\n\nThis plugin is built with Gradle 7.6.\n\n```groovy\nplugins {\n  id 'org.assertj.generator' version '1.1.0'\n}\n\n// add some classpath dependencies\nrepositories {\n  mavenCentral()\n}\n\ndependencies {\n  testCompile group: 'org.assertj', name: 'assertj-core', version: '3.24.2'\n  testCompile group: 'junit', name: 'junit', version: '4.12'\n}\n```\n\n## License\n\nThis plugin is licensed under the [Apache License](./LICENSE).\n\n## Configuration\n\nPrimary configuration of included/excluded files is done via the same mechanisms that are used for Gradle's `SourceSet`\nDSL. For explanation on how filters work, please review the\n[Java Plugin Tutorial for Gradle](https://docs.gradle.org/current/userguide/java_plugin.html#sec:changing_java_project_layout).\nThis plugin utilizes the filters to gather classes to run against the generator.\n\n### Parameters\n\nThe following sections outline the available parameters, linking to the appropriate generator docs when available.\n\nFor any unlisted parameters, please see the\n[javadoc for `AssertJGeneratorExtension`](./src/main/kotlin/org/assertj/generator/gradle/tasks/config/AssertJGeneratorExtension.kt)\nand open issues for unclear/missing documentation.\n\n#### skip - `boolean`\n\nDefault: `false`\n\nThe `skip` parameter provides a mechanism for quickly turning on/off `assertJ` generation. Unless overridden in the\nglobal scope, no code will be generated by default. When an `assertJ` block is defined in a local scope, this parameter\nis set to `false` for the source set.\n\n##### Example\n\nThe following example turns _off_ generation for `main`. All classes found within `main` will be ignored.\n\n```groovy\nsourceSets {\n  main {\n      assertJ { skip = true } // sets skip = true\n  }\n}\n```\n\nIf debugging a build, it may be useful to turn off generation for a `sourceSet`. To do this, inside the configuration\nblock, set `skip = true`.\n\n```groovy\nsourceSets {\n  brokenGeneration {\n    assertJ {\n      skip = true // no assertions will be generated for \"brokenGeneration\"\n    }\n  }\n}\n```\n\n#### outputDir - `File`\n\nDefault: `${buildDir}/generated-srcs/${sourceSet.name}-test/java`\n\nThe root directory where all generated files will be placed (within sub-folders for packages).\n\nChanging this parameter will place all generated files into the passed directory. Any relative path specified is\nrelative to the _build_ directory as any sources should not be checked into source control and destroyed with `clean`.\nHowever, in true Gradle tradition, this may use any absolute path.\n\nThe following example changes the output directory for the `main` `SourceSet` to be\n`${buildDir}/src-gen/main-test/java`.\n\n```groovy\nsourceSets {\n  main {\n    assertJ {\n      // default: ${buildDir}/generated-srcs/${sourceSet.name}-test/java\n      outputDir = file(\"src-gen/main-test/java\")\n    }\n  }\n}\n```\n\n#### templates - `Templates`\n\nDefault: Built-in templates\n\nTemplates can be configured to change the output of the generator. The templates to be replaced can be specified via\neither `String`s or `File`s.\n\nFor more information on template syntax, please see the\n[AssertJ Generator Templates Section](http://joel-costigliola.github.io/assertj/assertj-assertions-generator.html#generated-assertions-templates).\n\nThe names of templates mirror those from the AssertJ Documentation, but the actual names and nesting are listed\n[here](src/main/kotlin/org/assertj/generator/gradle/tasks/config/Templates.kt).\n\nThe following example replaces the whole number field with a custom template for only the `main` sourceSet, any others\nremain unaffected.\n\n```groovy\nsourceSets {\n  main {\n    assertJ {\n      templates {\n        methods {\n          wholeNumberPrimitive.template('public get${Property}() { }')\n        }\n      }\n    }\n  }\n}\n```\n\nThe following example changes the template to a `file()` template for the `main` source sets. The `file()` method\naccepts any parameter allowed by\n[`Project#file(...)`](https://docs.gradle.org/7.6.1/dsl/org.gradle.api.Project.html#org.gradle.api.Project:file(java.lang.Object)).\n\n```groovy\nsourceSets {\n  main {\n    assertJ {\n      templates {\n        // Set the template to file content: ./wholeNumberOverride.txt\n        methods {\n          wholeNumberPrimitive.file('wholeNumberOverride.txt')\n        }\n      }\n    }\n  }\n}\n```\n\n#### packages - `JavaPackageNamePatternFilterable`\n\nDefault: All packages\n\nPackage filters can be used to include, or exclude individual or groups of packages to be generated. These filters use a\nsimilar pattern to `include`/`exclude` with `SourceSet`.\n\n```groovy\nsourceSets {\n  main {\n    assertJ {\n      packages {\n        include \"org.example**\" // include *all* packages in `org.example`\n        exclude \"org.example.foo\" // exclude `org.example.foo` specifically\n     }\n    }\n  }\n}\n```\n\nSee [`PackageFilter` tests](src/test/kotlin/org/assertj/generator/gradle/parameter/PackageFilter.kt) for more\nexamples.\n\n#### classes - `JavaClassPatternFilterable`\n\nDefault: All classes\n\nClass filters can be used to include, or exclude individual patterns of fully-qualified class names to be generated.\nThese filters use a\nsimilar pattern to `include`/`exclude` with `SourceSet`.\n\n```groovy\nsourceSets {\n  main {\n    assertJ {\n      classes {\n        include \"org.example.**\" // include *all* classes under `org.example` including sub-packages\n        exclude \"org.example.Foo\" // exclude class `org.example.Foo` specifically\n      }\n    }\n  }\n}\n```\n\nSee [`ClassesFilter` tests](src/test/kotlin/org/assertj/generator/gradle/parameter/ClassesFilter.kt) for more\nexamples.\n\n#### entryPoints - `EntryPointsGeneratorOptions`\n\nDefault: Only generate \"standard\" assertion entrypoint\n\nEntry points are classes that provide mechanisms to get access to all of the generated AssertJ types.\nThe [AssertJ Generator - Entry Points](http://joel-costigliola.github.io/assertj/assertj-assertions-generator.html#generated-entry-points)\nexplains how these work and what is expected to be generated for each entry point. The following table shows a mapping\nvalue to entry point:\n\n| Value       | Enum Value   | Entry Point                                                                                                                     |\n|:------------|:-------------|:--------------------------------------------------------------------------------------------------------------------------------|\n| `bdd`       | `BDD`        | [BDD style](http://joel-costigliola.github.io/assertj/assertj-core-news.html#assertj-core-1.6.0-bdd-assertions-style)           |\n| `standard`  | `STANDARD`   | [Standard assertions style](http://joel-costigliola.github.io/assertj/assertj-assertions-generator.html#generated-entry-points) |\n| `junitSoft` | `JUNIT_SOFT` | [JUnit Soft](http://joel-costigliola.github.io/assertj/assertj-core-features-highlight.html#soft-assertions)                    |\n| `soft`      | `SOFT`       | [Soft](http://joel-costigliola.github.io/assertj/assertj-core-features-highlight.html#soft-assertions)                          |\n\n(This table is likely incomplete, please see\nthe [AssertJ Generator Docs](http://joel-costigliola.github.io/assertj/assertj-assertions-generator.html#generated-entry-points))\n\nBy default, only the `standard` style is turned on. To adjust this, simply set the values to `true` within the\n`entryPoints` closure.\n\n```groovy\nsourceSets {\n  main {\n    assertJ {\n      entryPoints {\n        standard = false // No more standard generation\n        bdd = true       // Turn on BDD\n        junitSoft = true // and JUnit Soft\n      }\n    }\n  }\n}\n```\n\nA useful trick to turn on _only_ a set of values is to just set the `entryPoints` to a collection of types:\n\n```groovy\nsourceSets {\n  main {\n    assertJ {\n      entryPoints = ['BDD', 'JUNIT_SOFT'] // turn on _only_ BDD and JUnit Soft\n    }\n  }\n}\n```\n\nOr within the `entryPoints` closure:\n\n```groovy\nsourceSets {\n  main {\n    assertJ {\n      entryPoints {\n        only 'BDD', 'JUNIT_SOFT' // turn on _only_ BDD and JUnit Soft\n      }\n    }\n  }\n}\n```\n\n## Task Provided\n\n* `generateAssertJ` - Generates all sources via the AssertJ Generator\n* Cleaning is done via the `clean` as the input/output semantics are handled by Gradle's incremental compilation\n  mechanics\n\n### Lifecycle\n\nThis plugin injects itself where it is needed for complete compilation.\n\n1. Java code that will be \"generated from\" is compiled\n2. These compiled classes and the source files \"classpath\" are used to generate the files\n3. These files are placed into the source compilation path for the `SourceSet`'s `compileJava` task\n\n## Alternatives\n\nThere exists several other alternative Gradle plugins that perform the same functionality as this one.\nCurrently, known:\n\n* [opengl-8080/assertjGen-gradle-plugin](https://github.com/opengl-8080/assertjGen-gradle-plugin) - built to wrap the\n  example provided by\n  @joel-costigiola, [here](https://github.com/joel-costigliola/assertj-assertions-generator/blob/master/src/main/scripts/build.gradle)\n  which does not allow for configuration. This plugin does _not_ tie the plugin to a specific version of the AssertJ\n  Generator\n* [fhermansson/assertj-generator-gradle-plugin](https://github.com/fhermansson/assertj-generator-gradle-plugin) - only\n  works on a single source-set and still just wraps package/class names as strings\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fassertj%2Fassertj-generator-gradle-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fassertj%2Fassertj-generator-gradle-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fassertj%2Fassertj-generator-gradle-plugin/lists"}