Skip to content

Commit

Permalink
Update setting additional Scala compiler parameters
Browse files Browse the repository at this point in the history
This makes the plugin compatible with upcoming Gradle 8

Fixes #86
  • Loading branch information
ljacomet authored and augi committed Feb 2, 2023
1 parent d783941 commit 9e61619
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ class WartremoverPlugin implements Plugin<Project> {
project.afterEvaluate {
project.dependencies { scalaCompilerPlugins "org.wartremover:wartremover_${getWartremoverArtifactSuffix(project)}" }
project.tasks.withType(ScalaCompile).configureEach { scalaTask ->
if (scalaTask.scalaCompileOptions.additionalParameters == null) {
scalaTask.scalaCompileOptions.additionalParameters = new ArrayList<String>()
List<String> updatedParameters = new ArrayList<>()
if (scalaTask.scalaCompileOptions.additionalParameters != null) {
updatedParameters.addAll(scalaTask.scalaCompileOptions.additionalParameters)
}
WartremoverSettings settings = scalaTask.name.toLowerCase().contains('test') ? extension.getTest() : extension
scalaTask.scalaCompileOptions.additionalParameters.addAll(settings.errorWarts.collect { getErrorWartDirective(it) })
scalaTask.scalaCompileOptions.additionalParameters.addAll(settings.warningWarts.collect { getWarningWartDirective(it) })
scalaTask.scalaCompileOptions.additionalParameters.addAll(settings.excludedFiles.collect { getExludedFileDirective(project.file(it).canonicalPath) })
updatedParameters.addAll(settings.errorWarts.collect { getErrorWartDirective(it) })
updatedParameters.addAll(settings.warningWarts.collect { getWarningWartDirective(it) })
updatedParameters.addAll(settings.excludedFiles.collect { getExludedFileDirective(project.file(it).canonicalPath) })

scalaTask.scalaCompileOptions.additionalParameters.addAll(settings.classPaths.collect { getClasspathDirective(it) })
updatedParameters.addAll(settings.classPaths.collect { getClasspathDirective(it) })

scalaTask.scalaCompileOptions.additionalParameters = updatedParameters
}
}
}
Expand Down

0 comments on commit 9e61619

Please sign in to comment.