@@ -46,6 +46,8 @@ class ScoverageExtension {
4646 /* * regex for each excluded file */
4747 List<String > excludedFiles = []
4848
49+ FileCollection pluginClasspath
50+
4951 ScoverageExtension (Project project ) {
5052
5153 project. plugins. apply(JavaPlugin . class);
@@ -93,8 +95,9 @@ class ScoverageExtension {
9395 })
9496 }
9597
96- project. tasks. create(ScoveragePlugin . REPORT_NAME , JavaExec . class) {
98+ project. tasks. create(ScoveragePlugin . REPORT_NAME , ScoverageReport . class) {
9799 dependsOn(project. tasks[ScoveragePlugin . TEST_NAME ])
100+ onlyIf { ScoveragePlugin . extensionIn(project). dataDir. list() }
98101 }
99102
100103 project. tasks. create(ScoveragePlugin . CHECK_NAME , OverallCheckTask . class) {
@@ -104,6 +107,8 @@ class ScoverageExtension {
104107 sources = project. projectDir
105108 dataDir = new File (project. buildDir, ' scoverage' )
106109 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
107112 }
108113
109114 private Action<Project > configureRuntimeOptions = new Action<Project > () {
@@ -113,7 +118,6 @@ class ScoverageExtension {
113118
114119 def extension = ScoveragePlugin . extensionIn(t)
115120 extension. dataDir. mkdirs()
116- extension. reportDir. mkdirs()
117121
118122 Configuration configuration = t. configurations[ScoveragePlugin . CONFIGURATION_NAME ]
119123 File pluginFile
@@ -122,7 +126,6 @@ class ScoverageExtension {
122126 } catch (NoSuchElementException e) {
123127 throw new GradleException (" Could not find a plugin jar in configuration '${ ScoveragePlugin.CONFIGURATION_NAME} '" )
124128 }
125- FileCollection pluginDependencies = configuration. filter { it != pluginFile }
126129
127130 t. tasks[ScoveragePlugin . COMPILE_NAME ]. configure {
128131 List<String > parameters = [' -Xplugin:' + pluginFile. absolutePath]
@@ -151,21 +154,6 @@ class ScoverageExtension {
151154 // the compile task creates a store of measured statements
152155 outputs. file(new File (extension. dataDir, ' scoverage.coverage.xml' ))
153156 }
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-
168157 }
169158 }
170-
171159}
0 commit comments