Skip to content

Commit cb1a966

Browse files
authored
[Docs] Update docs for 1.1.0 release (#70)
Update docs to be correct and more modern. Thanks to @maciejwalkowiak for reporting. Closes #69
1 parent 4bf651a commit cb1a966

File tree

1 file changed

+32
-73
lines changed

1 file changed

+32
-73
lines changed

README.md

Lines changed: 32 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
![Build Status](https://img.shields.io/github/actions/workflow/status/assertj/assertj-generator-gradle-plugin/ci.yml)
44
[![Gradle Plugin Portal](https://img.shields.io/gradle-plugin-portal/v/org.assertj.generator)](https://plugins.gradle.org/plugin/org.assertj.generator)
5+
[![Licence](https://img.shields.io/github/license/assertj/assertj-generator-gradle-plugin)](./LICENSE)
56

67
This is the source for the Gradle plugin for the
78
[AssertJ Generator](http://joel-costigliola.github.io/assertj/assertj-assertions-generator.html). This plugin leverages
@@ -10,23 +11,19 @@ easier to integrate the AssertJ Generator into existing Gradle-based projects. T
1011
provided by
1112
the [AssertJ Generator Maven Plugin](http://joel-costigliola.github.io/assertj/assertj-assertions-generator-maven-plugin.html).
1213

14+
This plugin will automatically detect Kotlin, and Java sources. The plugin automatically configures the generation step
15+
for each `SourceSet` (except `test`) in a Gradle project when applied.
16+
1317
## Quick Start
1418

15-
Below is a minimal configuration that will cause _all_ classes defined in the `main` source set to have an `AssertJ`
16-
assertion generated for it. All of these will be placed into the highest package in use.
19+
Below is a minimal configuration that will cause _all_ classes defined in the `main` source set to have an `assertJ`
20+
assertion generated for it. All of these will be placed into the longest common package of the sources presented.
1721

1822
This plugin is built with Gradle 7.6.
1923

2024
```groovy
2125
plugins {
22-
id 'org.assertj.generator' version '0.0.6b'
23-
}
24-
25-
sourceSets {
26-
main {
27-
// Configurations are per source-set
28-
assertJ { }
29-
}
26+
id 'org.assertj.generator' version '1.1.0'
3027
}
3128
3229
// add some classpath dependencies
@@ -35,35 +32,28 @@ repositories {
3532
}
3633
3734
dependencies {
38-
// https://mvnrepository.com/artifact/org.assertj/assertj-core
39-
testCompile group: 'org.assertj', name: 'assertj-core', version: '3.8.0'
40-
35+
testCompile group: 'org.assertj', name: 'assertj-core', version: '3.24.2'
4136
testCompile group: 'junit', name: 'junit', version: '4.12'
4237
}
4338
```
4439

40+
## License
41+
42+
This plugin is licensed under the [Apache License](./LICENSE).
43+
4544
## Configuration
4645

47-
Primary configuration of included/excluded files is done via the same mechanisms that are used for Gradle's SourceSet
46+
Primary configuration of included/excluded files is done via the same mechanisms that are used for Gradle's `SourceSet`
4847
DSL. For explanation on how filters work, please review the
4948
[Java Plugin Tutorial for Gradle](https://docs.gradle.org/current/userguide/java_plugin.html#sec:changing_java_project_layout).
50-
This plugin utilizes the filters to gather classes to run against the generator. **This is different than how the
51-
AssertJ
52-
Generator normally functions** -- this plugin does not work on class/package names, but folder/file patterns like the
53-
Java plugin.
54-
55-
### Plugin Version
56-
57-
The plugin version is tied to the version of
58-
the [AssertJ Generator](http://joel-costigliola.github.io/assertj/assertj-assertions-generator.html).
59-
The version of the generator used will always match the plugin's version.
49+
This plugin utilizes the filters to gather classes to run against the generator.
6050

6151
### Parameters
6252

6353
The following sections outline the available parameters, linking to the appropriate generator docs when available.
6454

6555
For any unlisted parameters, please see the
66-
[javadoc for `AssertJGeneratorOptions`](./src/main/groovy/org/assertj/generator/gradle/tasks/AssertJGeneratorOptions.groovy)
56+
[javadoc for `AssertJGeneratorExtension`](./src/main/kotlin/org/assertj/generator/gradle/tasks/config/AssertJGeneratorExtension.kt)
6757
and open issues for unclear/missing documentation.
6858

6959
#### skip - `boolean`
@@ -81,9 +71,8 @@ The following example turns _off_ generation for `main`. All classes found withi
8171
```groovy
8272
sourceSets {
8373
main {
84-
assertJ { skip = true } // sets skip = true
74+
assertJ { skip = true } // sets skip = true
8575
}
86-
test { }
8776
}
8877
```
8978

@@ -94,13 +83,9 @@ block, set `skip = true`.
9483
sourceSets {
9584
brokenGeneration {
9685
assertJ {
97-
skip = true // no assertions will be generated for
98-
// "brokenGeneration"
99-
// other parameters follow, order of assignment of different
100-
// parameters does not matter, like with gradle
86+
skip = true // no assertions will be generated for "brokenGeneration"
10187
}
10288
}
103-
test { }
10489
}
10590
```
10691

@@ -114,18 +99,16 @@ Changing this parameter will place all generated files into the passed directory
11499
relative to the _build_ directory as any sources should not be checked into source control and destroyed with `clean`.
115100
However, in true Gradle tradition, this may use any absolute path.
116101

117-
The following example changes the output directory for _all_ source sets to be
118-
`${buildDir}/src-gen/${sourceSet.testName}/java/`. The same change could be applied to a local
119-
scope.
102+
The following example changes the output directory for the `main` `SourceSet` to be
103+
`${buildDir}/src-gen/main-test/java`.
120104

121105
```groovy
122106
sourceSets {
123107
main {
124-
// turn on assertJ generation
125-
assertJ {
108+
assertJ {
126109
// default: ${buildDir}/generated-srcs/${sourceSet.name}-test/java
127110
outputDir = file("src-gen/main-test/java")
128-
}
111+
}
129112
}
130113
}
131114
```
@@ -135,10 +118,7 @@ sourceSets {
135118
Default: Built-in templates
136119

137120
Templates can be configured to change the output of the generator. The templates to be replaced can be specified via
138-
either `String`s or `File`s. Within this Closure, all paths are relative to where they are defined. For example, if
139-
defined in the global scope, files are relative to `${projectDir}/assertj-templates` by default, for local scopes, the
140-
path of the source set (e.g. `main` implies templates are in `src/main/assertj-templates`). This convention may be
141-
overridden by specifying the `dir` parameter within the block.
121+
either `String`s or `File`s.
142122

143123
For more information on template syntax, please see the
144124
[AssertJ Generator Templates Section](http://joel-costigliola.github.io/assertj/assertj-assertions-generator.html#generated-assertions-templates).
@@ -165,7 +145,7 @@ sourceSets {
165145

166146
The following example changes the template to a `file()` template for the `main` source sets. The `file()` method
167147
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)).
148+
[`Project#file(...)`](https://docs.gradle.org/7.6.1/dsl/org.gradle.api.Project.html#org.gradle.api.Project:file(java.lang.Object)).
169149

170150
```groovy
171151
sourceSets {
@@ -176,26 +156,7 @@ sourceSets {
176156
methods {
177157
wholeNumberPrimitive.file('wholeNumberOverride.txt')
178158
}
179-
}
180-
}
181-
}
182-
}
183-
```
184-
185-
We can root all files under a directory by using a file from the scoped `project`:
186-
187-
```groovy
188-
sourceSets {
189-
main {
190-
assertJ {
191-
templates {
192-
// Set all templates in this block to be relative to the folder specified
193-
def rootDirectory = projectDir.dir("gradle/other-templates")
194-
195-
// Change the file content to:
196-
// ${projectDir}/gradle/other-templates/wholeNumberOverride.txt
197-
wholeNumberAssertion.file(rootDirectory.file('wholeNumberOverride.txt'))
198-
}
159+
}
199160
}
200161
}
201162
}
@@ -215,13 +176,13 @@ sourceSets {
215176
packages {
216177
include "org.example**" // include *all* packages in `org.example`
217178
exclude "org.example.foo" // exclude `org.example.foo` specifically
218-
}
179+
}
219180
}
220181
}
221182
}
222183
```
223184

224-
See [`PackageFilter` tests](src/test/groovy/org/assertj/generator/gradle/parameter/PackageFilter.groovy) for more
185+
See [`PackageFilter` tests](src/test/kotlin/org/assertj/generator/gradle/parameter/PackageFilter.kt) for more
225186
examples.
226187

227188
#### classes - `JavaClassPatternFilterable`
@@ -245,7 +206,7 @@ sourceSets {
245206
}
246207
```
247208

248-
See [`ClassesFilter` tests](src/test/groovy/org/assertj/generator/gradle/parameter/ClassesFilter.groovy) for more
209+
See [`ClassesFilter` tests](src/test/kotlin/org/assertj/generator/gradle/parameter/ClassesFilter.kt) for more
249210
examples.
250211

251212
#### entryPoints - `EntryPointsGeneratorOptions`
@@ -264,6 +225,9 @@ value to entry point:
264225
| `junitSoft` | `JUNIT_SOFT` | [JUnit Soft](http://joel-costigliola.github.io/assertj/assertj-core-features-highlight.html#soft-assertions) |
265226
| `soft` | `SOFT` | [Soft](http://joel-costigliola.github.io/assertj/assertj-core-features-highlight.html#soft-assertions) |
266227

228+
(This table is likely incomplete, please see
229+
the [AssertJ Generator Docs](http://joel-costigliola.github.io/assertj/assertj-assertions-generator.html#generated-entry-points))
230+
267231
By default, only the `standard` style is turned on. To adjust this, simply set the values to `true` within the
268232
`entryPoints` closure.
269233

@@ -275,7 +239,7 @@ sourceSets {
275239
standard = false // No more standard generation
276240
bdd = true // Turn on BDD
277241
junitSoft = true // and JUnit Soft
278-
}
242+
}
279243
}
280244
}
281245
}
@@ -319,8 +283,7 @@ This plugin injects itself where it is needed for complete compilation.
319283

320284
1. Java code that will be "generated from" is compiled
321285
2. These compiled classes and the source files "classpath" are used to generate the files
322-
3. These files are placed into the source path for the `test` sourceSet (TODO configurable?)
323-
4. The `test` set is compiled
286+
3. These files are placed into the source compilation path for the `SourceSet`'s `compileJava` task
324287

325288
## Alternatives
326289

@@ -334,7 +297,3 @@ Currently, known:
334297
Generator
335298
* [fhermansson/assertj-generator-gradle-plugin](https://github.com/fhermansson/assertj-generator-gradle-plugin) - only
336299
works on a single source-set and still just wraps package/class names as strings
337-
338-
## License
339-
340-
This plugin is licensed under the Apache License. See [LICENSE](./LICENSE) for more details.

0 commit comments

Comments
 (0)