Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added privateFields property #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Gradle version >= 7.1
#### Configuration
```groovy
plugins {
id "com.github.fhermansson.assertj-generator" version "1.1.3"
id "com.github.fhermansson.assertj-generator" version "1.1.5"
}

assertjGenerator {
Expand All @@ -33,6 +33,7 @@ type `com.github.fhermansson.gradle.assertj.plugin.GenerateAssertions`.
|entryPointTypes|AssertionsEntryPointType[]|['STANDARD']|Types of entry point classes to generate. Possible values: 'STANDARD', 'SOFT', 'BDD', 'JUNIT_SOFT', 'BDD_SOFT', 'JUNIT_BDD_SOFT', 'AUTO_CLOSEABLE_SOFT', 'AUTO_CLOSEABLE_BDD_SOFT'|
|entryPointInherits|boolean|true|Entry point classes [inherit](http://joel-costigliola.github.io/assertj/assertj-core-custom-assertions.html#single-assertion-entry-point) from core Assertj classes|
|cleanOutputDir|boolean|true|Remove all files in `outputDir` before generating assertions.|
|privateFields|boolean|false|Generate assertions for not public properties and fields|


##### How to create additional tasks
Expand All @@ -53,6 +54,5 @@ task generateOtherAssertions(type: GenerateAssertions) {
sourceSet = sourceSets.other
testSourceSet = sourceSets.otherTest
}

```

4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = "com.github.fhermansson"
version = "1.1.4"
version = "1.1.5"

repositories {
mavenCentral()
Expand Down Expand Up @@ -43,4 +43,4 @@ pluginBundle {
tasks.wrapper {
distributionType = Wrapper.DistributionType.ALL
gradleVersion = "7.2"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,9 @@ open class AssertjGeneratorExtension(project: Project) {
* Clean output directory before generating assertions.
*/
var cleanOutputDir: Boolean = true

/**
* Consider not public properties and fields.
*/
var privateFields: Boolean = false
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ open class GenerateAssertions : DefaultTask(), ProjectEvaluationListener {
@Input
get() = field ?: extension.cleanOutputDir

var privateFields: Boolean? = null
@Input
get() = field ?: extension.privateFields

init {
group = "assertj"
description = "Generate Assertj Assertions"
Expand Down Expand Up @@ -146,7 +150,9 @@ open class GenerateAssertions : DefaultTask(), ProjectEvaluationListener {
}
val descriptionConverter = ClassToClassDescriptionConverter()
val assertionGenerator = BaseAssertionGenerator()
assertionGenerator.setDirectoryWhereAssertionFilesAreGenerated(resolvedOutputDir)
if (privateFields == true) // not (false or null)
assertionGenerator.setGenerateAssertionsForAllFields(true)
assertionGenerator.setDirectoryWhereAssertionFilesAreGenerated(File(resolvedOutputDir.absolutePath))
if (entryPointInherits!!) {
entryPointTypesAsSet.forEach {
assertionGenerator.register(getTemplate(it))
Expand Down