11# AssertJ Generator Gradle Plugin
22
3- [ ![ Linux Build Status] ( https://travis-ci.org/assertj/assertj-generator-gradle-plugin.svg?branch=master )] ( https://travis-ci.org/assertj/assertj-generator-gradle-plugin )
4- [ ![ Windows status] ( https://ci.appveyor.com/api/projects/status/ia2ki6wprow9ysnl/branch/master?svg=true )] ( https://ci.appveyor.com/project/Nava2/assertj-generator-gradle-plugin/branch/master )
5-
6- [ Gradle Plugin Portal] ( https://plugins.gradle.org/plugin/org.assertj.generator.gradle.plugin )
3+ ![ Build Status] ( https://img.shields.io/github/actions/workflow/status/assertj/assertj-generator-gradle-plugin/ci.yml )
4+ [ ![ Gradle Plugin Portal] ( https://img.shields.io/gradle-plugin-portal/v/org.assertj.generator )] ( https://plugins.gradle.org/plugin/org.assertj.generator.gradle.plugin )
75
86This is the source for the Gradle plugin for the
97[ AssertJ Generator] ( http://joel-costigliola.github.io/assertj/assertj-assertions-generator.html ) . This plugin leverages
@@ -17,16 +15,16 @@ the [AssertJ Generator Maven Plugin](http://joel-costigliola.github.io/assertj/a
1715Below is a minimal configuration that will cause _ all_ classes defined in the ` main ` source set to have an ` AssertJ `
1816assertion generated for it. All of these will be placed into the highest package in use.
1917
20- This plugin requires Gradle 4.0 .
18+ This plugin is built with Gradle 7.6 .
2119
22- ``` gradle
20+ ``` groovy
2321plugins {
2422 id 'org.assertj.generator' version '0.0.6b'
2523}
2624
2725sourceSets {
2826 main {
29- // must specify assertJ block to have it applied
27+ // Configurations are per source-set
3028 assertJ { }
3129 }
3230}
@@ -60,19 +58,6 @@ The plugin version is tied to the version of
6058the [ AssertJ Generator] ( http://joel-costigliola.github.io/assertj/assertj-assertions-generator.html ) .
6159The version of the generator used will always match the plugin's version.
6260
63- ### Scope: Local vs. Global
64-
65- This plugin allows the generation configuration to appear in two places:
66-
67- * "global" ` assertJ {} ` block -- outside ` sourceSets `
68- * Locally within a ` sourceSet ` in an ` assertJ {} ` block (e.g. within ` main{} ` )
69-
70- All "locally" defined parameters override those set in the "global" scope.
71-
72- Each of these provide the same configuration parameters except:
73-
74- * Globally, files and patterns can not be manipulated -- this must be done at the local scope
75-
7661### Parameters
7762
7863The following sections outline the available parameters, linking to the appropriate generator docs when available.
@@ -81,23 +66,22 @@ For any unlisted parameters, please see the
8166[ javadoc for ` AssertJGeneratorOptions ` ] ( ./src/main/groovy/org/assertj/generator/gradle/tasks/AssertJGeneratorOptions.groovy )
8267and open issues for unclear/missing documentation.
8368
84- #### P: skip - ` boolean `
69+ #### skip - ` boolean `
8570
86- Default: ` true `
71+ Default: ` false `
8772
8873The ` skip ` parameter provides a mechanism for quickly turning on/off ` assertJ ` generation. Unless overridden in the
8974global scope, no code will be generated by default. When an ` assertJ ` block is defined in a local scope, this parameter
9075is set to ` false ` for the source set.
9176
9277##### Example
9378
94- The following example turns on generation for _ only_ ` main ` All classes found within ` main ` and ` test ` will have an
95- Assertion generated. This is the recommended way to turn on generation for source sets.
79+ The following example turns _ off_ generation for ` main ` . All classes found within ` main ` will be ignored.
9680
97- ``` gradle
81+ ``` groovy
9882sourceSets {
9983 main {
100- assertJ { } // sets skip = false for the "main" sourceSet
84+ assertJ { skip = true } // sets skip = true
10185 }
10286 test { }
10387}
@@ -106,12 +90,8 @@ sourceSets {
10690If debugging a build, it may be useful to turn off generation for a ` sourceSet ` . To do this, inside the configuration
10791block, set ` skip = true ` .
10892
109- ``` gradle
93+ ``` groovy
11094sourceSets {
111- main {
112- assertJ { } // sets skip = false for the "main" sourceSet
113- }
114-
11595 brokenGeneration {
11696 assertJ {
11797 skip = true // no assertions will be generated for
@@ -124,7 +104,7 @@ sourceSets {
124104}
125105```
126106
127- #### P: outputDir - ` File `
107+ #### outputDir - ` File `
128108
129109Default: ` ${buildDir}/generated-srcs/${sourceSet.name}-test/java `
130110
@@ -138,19 +118,19 @@ The following example changes the output directory for _all_ source sets to be
138118` ${buildDir}/src-gen/${sourceSet.testName}/java/ ` . The same change could be applied to a local
139119scope.
140120
141- ``` gradle
121+ ``` groovy
142122sourceSets {
143123 main {
144124 // turn on assertJ generation
145125 assertJ {
146- // default: generated-srcs/${SOURCE_SET_NAME_TAG} /java
126+ // default: ${buildDir}/ generated-srcs/${sourceSet.name}-test /java
147127 outputDir = file("src-gen/main-test/java")
148128 }
149129 }
150130}
151131```
152132
153- #### P: templates - ` Templates `
133+ #### templates - ` Templates `
154134
155135Default: Built-in templates
156136
@@ -164,12 +144,12 @@ For more information on template syntax, please see the
164144[ AssertJ Generator Templates Section] ( http://joel-costigliola.github.io/assertj/assertj-assertions-generator.html#generated-assertions-templates ) .
165145
166146The names of templates mirror those from the AssertJ Documentation, but the actual names and nesting are listed
167- [ here] ( src/main/groovy /org/assertj/generator/gradle/tasks/config/Templates.groovy ) .
147+ [ here] ( src/main/kotlin /org/assertj/generator/gradle/tasks/config/Templates.kt ) .
168148
169149The following example replaces the whole number field with a custom template for only the ` main ` sourceSet, any others
170150remain unaffected.
171151
172- ``` gradle
152+ ``` groovy
173153sourceSets {
174154 main {
175155 assertJ {
@@ -183,9 +163,11 @@ sourceSets {
183163}
184164```
185165
186- The following example changes the template to a ` file() ` template for the ` main ` source sets.
166+ The following example changes the template to a ` file() ` template for the ` main ` source sets. The ` file() ` method
167+ accepts any parameter allowed by
168+ [ ` Project#file(...) ` ] ( https://docs.gradle.org/current/dsl/org.gradle.api.Project.html#org.gradle.api.Project:file(java.lang.Object) ) .
187169
188- ``` gradle
170+ ``` groovy
189171sourceSets {
190172 main {
191173 assertJ {
@@ -202,7 +184,7 @@ sourceSets {
202184
203185We can root all files under a directory by using a file from the scoped ` project ` :
204186
205- ``` gradle
187+ ``` groovy
206188sourceSets {
207189 main {
208190 assertJ {
@@ -219,9 +201,9 @@ sourceSets {
219201}
220202```
221203
222- #### P: entryPoints - ` EntryPointsGeneratorOptions `
204+ #### entryPoints - ` EntryPointsGeneratorOptions `
223205
224- Default: Only generate "standard" assertions
206+ Default: Only generate "standard" assertion entrypoint
225207
226208Entry points are classes that provide mechanisms to get access to all of the generated AssertJ types.
227209The [ AssertJ Generator - Entry Points] ( http://joel-costigliola.github.io/assertj/assertj-assertions-generator.html#generated-entry-points )
@@ -238,7 +220,7 @@ value to entry point:
238220By default, only the ` standard ` style is turned on. To adjust this, simply set the values to ` true ` within the
239221` entryPoints ` closure.
240222
241- ``` gradle
223+ ``` groovy
242224sourceSets {
243225 main {
244226 assertJ {
@@ -254,7 +236,7 @@ sourceSets {
254236
255237A useful trick to turn on _ only_ a set of values is to just set the ` entryPoints ` to a collection of types:
256238
257- ``` gradle
239+ ``` groovy
258240sourceSets {
259241 main {
260242 assertJ {
@@ -266,7 +248,7 @@ sourceSets {
266248
267249Or within the ` entryPoints ` closure:
268250
269- ``` gradle
251+ ``` groovy
270252sourceSets {
271253 main {
272254 assertJ {
0 commit comments