Skip to content

Commit

Permalink
Move excludes values to the JunitJacocoExtension configuration st…
Browse files Browse the repository at this point in the history
…age, to allow easier modification. (#173)
  • Loading branch information
gtcompscientist authored May 1, 2020
1 parent feb9fa4 commit 5f08ba5
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 32 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@ Version 0.1.1 *(2015-10-25)*
Version 0.1.0 *(2015-10-15)*
----------------------------

- Initial release
- Initial release
Original file line number Diff line number Diff line change
Expand Up @@ -322,28 +322,7 @@ class GenerationPlugin implements Plugin<Project> {
}

static List<String> getExcludes(final JunitJacocoExtension extension) {
extension.excludes == null ? [
'**/R.class',
'**/R2.class', // ButterKnife Gradle Plugin.
'**/R$*.class',
'**/R2$*.class', // ButterKnife Gradle Plugin.
'**/*$$*',
'**/*$ViewInjector*.*', // Older ButterKnife Versions.
'**/*$ViewBinder*.*', // Older ButterKnife Versions.
'**/*_ViewBinding*.*', // Newer ButterKnife Versions.
'**/BuildConfig.*',
'**/Manifest*.*',
'**/*$Lambda$*.*', // Jacoco can not handle several "$" in class name.
'**/*Dagger*.*', // Dagger auto-generated code.
'**/*MembersInjector*.*', // Dagger auto-generated code.
'**/*_Provide*Factory*.*', // Dagger auto-generated code.
'**/*_Factory*.*', // Dagger auto-generated code.
'**/*$JsonObjectMapper.*', // LoganSquare auto-generated code.
'**/*$inlined$*.*', // Kotlin specific, Jacoco can not handle several "$" in class name.
'**/*$Icepick.*', // Icepick auto-generated code.
'**/*$StateSaver.*', // android-state auto-generated code.
'**/*AutoValue_*.*' // AutoValue auto-generated code.
] : extension.excludes
extension.excludes ?: []
}

private static boolean isAndroidProject(final Project project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,28 @@ class JunitJacocoExtension {
* Patterns of files that should be ignored
* @since 0.5.0
*/
List<String> excludes = null
List<String> excludes = [
'**/R.class',
'**/R2.class', // ButterKnife Gradle Plugin.
'**/R$*.class',
'**/R2$*.class', // ButterKnife Gradle Plugin.
'**/*$$*',
'**/*$ViewInjector*.*', // Older ButterKnife Versions.
'**/*$ViewBinder*.*', // Older ButterKnife Versions.
'**/*_ViewBinding*.*', // Newer ButterKnife Versions.
'**/BuildConfig.*',
'**/Manifest*.*',
'**/*$Lambda$*.*', // Jacoco can not handle several "$" in class name.
'**/*Dagger*.*', // Dagger auto-generated code.
'**/*MembersInjector*.*', // Dagger auto-generated code.
'**/*_Provide*Factory*.*', // Dagger auto-generated code.
'**/*_Factory*.*', // Dagger auto-generated code.
'**/*$JsonObjectMapper.*', // LoganSquare auto-generated code.
'**/*$inlined$*.*', // Kotlin specific, Jacoco can not handle several "$" in class name.
'**/*$Icepick.*', // Icepick auto-generated code.
'**/*$StateSaver.*', // android-state auto-generated code.
'**/*AutoValue_*.*' // AutoValue auto-generated code.
]

/**
* Whether or not to include no location classes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,13 +618,33 @@ class GenerationTest {
assert excludes.contains('**/*AutoValue_*.*')
}

@Test void getExcludesCustom() {
final def extension = new JunitJacocoExtension()
extension.excludes = new ArrayList<>()
extension.excludes.add("**/*.java")
@Test void getExcludesCustom() {
final def extension = new JunitJacocoExtension()
extension.excludes = new ArrayList<>()
extension.excludes.add("**/*.java")

final def excludes = GenerationPlugin.getExcludes(extension)
final def excludes = GenerationPlugin.getExcludes(extension)

assert excludes == extension.excludes
}
assert excludes == extension.excludes
}

@Test void getExcludesCustomPlus() {
final def extension = new JunitJacocoExtension()
extension.excludes.add("**/*custom*.java")

final def excludes = GenerationPlugin.getExcludes(extension)

assert excludes == extension.excludes
assert 1 < excludes.size() // Includes defaults
}

@Test void getExcludesNull() {
final def extension = new JunitJacocoExtension()
extension.excludes = null

final def excludes = GenerationPlugin.getExcludes(extension)

assert null != excludes
assert 0 == excludes.size()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class JunitJacocoExtensionTest {

assert extension.jacocoVersion == '0.8.2'
assert extension.ignoreProjects.size() == 0
assert extension.excludes == null
assert extension.excludes != null
assert !extension.includeNoLocationClasses
assert !extension.includeInstrumentationCoverageInMergedReport
}
Expand Down

0 comments on commit 5f08ba5

Please sign in to comment.