Skip to content

Performance Fixes #99

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

Merged
merged 2 commits into from
May 22, 2019
Merged
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
23 changes: 18 additions & 5 deletions src/main/groovy/org/scoverage/ScoveragePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.gradle.api.tasks.SourceSet
import org.gradle.api.tasks.scala.ScalaCompile

import java.nio.file.Files
import java.util.concurrent.ConcurrentHashMap

import static groovy.io.FileType.FILES

Expand All @@ -23,6 +24,9 @@ class ScoveragePlugin implements Plugin<PluginAware> {

static final String DEFAULT_REPORT_DIR = 'reports' + File.separatorChar + 'scoverage'

private volatile File pluginFile = null
private final ConcurrentHashMap<Task, Set<? extends Task>> taskDependencies = new ConcurrentHashMap<>();

@Override
void apply(PluginAware pluginAware) {
if (pluginAware instanceof Project) {
Expand Down Expand Up @@ -174,9 +178,12 @@ class ScoveragePlugin implements Plugin<PluginAware> {
}

compileTask.configure {
File pluginFile = project.configurations[CONFIGURATION_NAME].find {
it.name.startsWith("scalac-scoverage-plugin")
if (pluginFile == null) {
pluginFile = project.configurations[CONFIGURATION_NAME].find {
it.name.startsWith("scalac-scoverage-plugin")
}
}

List<String> parameters = ['-Xplugin:' + pluginFile.absolutePath]
List<String> existingParameters = scalaCompileOptions.additionalParameters
if (existingParameters) {
Expand Down Expand Up @@ -269,9 +276,15 @@ class ScoveragePlugin implements Plugin<PluginAware> {
}

private Set<? extends Task> recursiveDependenciesOf(Task task) {
if (!taskDependencies.containsKey(task)) {
def directDependencies = task.getTaskDependencies().getDependencies(task)
def nestedDependencies = directDependencies.collect {recursiveDependenciesOf(it) }.flatten()
def dependencies = directDependencies + nestedDependencies

def directDependencies = task.getTaskDependencies().getDependencies(task)
def nestedDependencies = directDependencies.collect {recursiveDependenciesOf(it) }.flatten()
return directDependencies + nestedDependencies
taskDependencies.put(task, dependencies)
return dependencies
} else {
return taskDependencies.get(task)
}
}
}