@@ -46,6 +46,8 @@ class ScoverageExtension {
46
46
/* * regex for each excluded file */
47
47
List<String > excludedFiles = []
48
48
49
+ FileCollection pluginClasspath
50
+
49
51
ScoverageExtension (Project project ) {
50
52
51
53
project. plugins. apply(JavaPlugin . class);
@@ -93,8 +95,9 @@ class ScoverageExtension {
93
95
})
94
96
}
95
97
96
- project. tasks. create(ScoveragePlugin . REPORT_NAME , JavaExec . class) {
98
+ project. tasks. create(ScoveragePlugin . REPORT_NAME , ScoverageReport . class) {
97
99
dependsOn(project. tasks[ScoveragePlugin . TEST_NAME ])
100
+ onlyIf { ScoveragePlugin . extensionIn(project). dataDir. list() }
98
101
}
99
102
100
103
project. tasks. create(ScoveragePlugin . CHECK_NAME , OverallCheckTask . class) {
@@ -104,6 +107,8 @@ class ScoverageExtension {
104
107
sources = project. projectDir
105
108
dataDir = new File (project. buildDir, ' scoverage' )
106
109
reportDir = new File (project. buildDir, ' reports' + File . separatorChar + ' scoverage' )
110
+ def classLocation = ScoverageExtension . class. getProtectionDomain(). getCodeSource(). getLocation()
111
+ pluginClasspath = project. files(classLocation. file) + project. configurations. scoverage
107
112
}
108
113
109
114
private Action<Project > configureRuntimeOptions = new Action<Project > () {
@@ -113,7 +118,6 @@ class ScoverageExtension {
113
118
114
119
def extension = ScoveragePlugin . extensionIn(t)
115
120
extension. dataDir. mkdirs()
116
- extension. reportDir. mkdirs()
117
121
118
122
Configuration configuration = t. configurations[ScoveragePlugin . CONFIGURATION_NAME ]
119
123
File pluginFile
@@ -122,7 +126,6 @@ class ScoverageExtension {
122
126
} catch (NoSuchElementException e) {
123
127
throw new GradleException (" Could not find a plugin jar in configuration '${ ScoveragePlugin.CONFIGURATION_NAME} '" )
124
128
}
125
- FileCollection pluginDependencies = configuration. filter { it != pluginFile }
126
129
127
130
t. tasks[ScoveragePlugin . COMPILE_NAME ]. configure {
128
131
List<String > parameters = [' -Xplugin:' + pluginFile. absolutePath]
@@ -151,21 +154,6 @@ class ScoverageExtension {
151
154
// the compile task creates a store of measured statements
152
155
outputs. file(new File (extension. dataDir, ' scoverage.coverage.xml' ))
153
156
}
154
-
155
- t. tasks[ScoveragePlugin . REPORT_NAME ]. configure {
156
- def classLocation = ScoverageExtension . class. getProtectionDomain(). getCodeSource(). getLocation()
157
- classpath = project. files(classLocation. file) + configuration
158
- main = ' org.scoverage.ScoverageReport'
159
- args = [
160
- extension. sources,
161
- extension. dataDir. absolutePath,
162
- extension. reportDir. absolutePath
163
- ]
164
- inputs. dir(extension. dataDir)
165
- outputs. dir(extension. reportDir)
166
- }
167
-
168
157
}
169
158
}
170
-
171
159
}
0 commit comments