Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 17a18af

Browse files
committed
disable -PscoverageCompileOnly with a view to getting a release out
1 parent f99718a commit 17a18af

File tree

6 files changed

+52
-78
lines changed

6 files changed

+52
-78
lines changed

README.md

+5-12
Original file line numberDiff line numberDiff line change
@@ -105,24 +105,17 @@ scoverage {
105105
}
106106
```
107107

108-
### Run without normal compilation
109-
110-
By default, running any of the plugin tasks will compile the code both using "normal" compilation (`compileScala`)
111-
and using the scoverage scalac plugin (`compileScoverageScala`).
112-
113-
In cases where you only wish to generate reports / validate coverage, but are not interested in publishing the code,
114-
it is possible to only compile the code with the scoverage scalac plugin, thus reducing build times significantly.
115-
In order to do so, simply add the arguments `-PscoverageCompileOnly` to the gradle execution.
116-
For example: `gradle reportScoverage -PscoverageCompileOnly`.
117-
118-
Note that this mode is incompatible with parallel builds in multi-module projects.
119-
120108
### Compatibility with Consistent Versions Plugin
121109

122110
In order for the plugin to work alongside [Palantir's consistent versions plugin](https://github.com/palantir/gradle-consistent-versions),
123111
the Scala version must be manually configured (via `scoverageScalaVersion`); otherwise, the plugin will attempt to
124112
resolve the compilation classpath, which is prohibited by the versions plugin.
125113

114+
Migration to 8.x
115+
----------------
116+
117+
* Running without normal compilation is no longer supported.
118+
126119
Migration to 7.x
127120
----------------
128121

src/functionalTest/java/org/scoverage/ScalaMultiModuleTest.java

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.scoverage;
22

33
import org.junit.Assert;
4+
import org.junit.Ignore;
45
import org.junit.Test;
56

67
import java.io.File;
@@ -60,6 +61,7 @@ public void reportScoverageOnlyA() {
6061
}
6162

6263
@Test
64+
@Ignore
6365
public void reportScoverageOnlyAWithoutNormalCompilation() {
6466

6567
AssertableBuildResult result = run("clean", ":a:" + ScoveragePlugin.getREPORT_NAME(),
@@ -192,6 +194,7 @@ public void checkScoverageWithoutCoverageInA() throws Exception {
192194
}
193195

194196
@Test
197+
@Ignore
195198
public void checkScoverageWithoutNormalCompilationAndWithoutCoverageInCommon() throws Exception {
196199

197200
AssertableBuildResult result = runAndFail("clean",
@@ -254,6 +257,7 @@ public void checkAndAggregateScoverageWithoutCoverageInAll() throws Exception {
254257
}
255258

256259
@Test
260+
@Ignore
257261
public void aggregateScoverageWithoutNormalCompilation() throws Exception {
258262

259263
AssertableBuildResult result = run("clean", ScoveragePlugin.getAGGREGATE_NAME(),

src/functionalTest/java/org/scoverage/ScalaMultiModuleWithMultipleTestTasksTest.java

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.scoverage;
22

33
import org.junit.Assert;
4+
import org.junit.Ignore;
45
import org.junit.Test;
56

67

@@ -188,6 +189,7 @@ public void checkScoverageWithoutCoverageInA() throws Exception {
188189
}
189190

190191
@Test
192+
@Ignore
191193
public void checkScoverageWithoutNormalCompilationAndWithoutCoverageInCommon() throws Exception {
192194

193195
AssertableBuildResult result = runAndFail("clean",
@@ -251,6 +253,7 @@ public void checkAndAggregateScoverageWithoutCoverageInAll() throws Exception {
251253
}
252254

253255
@Test
256+
@Ignore
254257
public void aggregateScoverageWithoutNormalCompilation() throws Exception {
255258

256259
AssertableBuildResult result = run("clean", ScoveragePlugin.getAGGREGATE_NAME(),

src/functionalTest/java/org/scoverage/ScalaSingleModuleTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.scoverage;
22

33
import org.junit.Assert;
4+
import org.junit.Ignore;
45
import org.junit.Test;
56

67
public class ScalaSingleModuleTest extends ScoverageFunctionalTest {
@@ -100,6 +101,7 @@ public void reportScoverageWithExcludedClasses() throws Exception {
100101
}
101102

102103
@Test
104+
@Ignore
103105
public void reportScoverageWithoutNormalCompilation() throws Exception {
104106

105107
AssertableBuildResult result = run("clean", ScoveragePlugin.getREPORT_NAME(),

src/functionalTest/java/org/scoverage/ScalaSingleModuleWithMultipleTestTasksTest.java

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.scoverage;
22

33
import org.junit.Assert;
4+
import org.junit.Ignore;
45
import org.junit.Test;
56

67
public class ScalaSingleModuleWithMultipleTestTasksTest extends ScoverageFunctionalTest {
@@ -118,6 +119,7 @@ public void reportScoverageWithExcludedClasses() throws Exception {
118119
}
119120

120121
@Test
122+
@Ignore
121123
public void reportScoverageWithoutNormalCompilation() throws Exception {
122124

123125
AssertableBuildResult result = run("clean", ScoveragePlugin.getREPORT_NAME(),

src/main/groovy/org/scoverage/ScoveragePlugin.groovy

+36-66
Original file line numberDiff line numberDiff line change
@@ -210,80 +210,50 @@ class ScoveragePlugin implements Plugin<PluginAware> {
210210
}
211211
}
212212

213-
if (project.hasProperty(SCOVERAGE_COMPILE_ONLY_PROPERTY)) {
214-
project.logger.info("Making scoverage compilation the primary compilation task (instead of compileScala)")
215-
216-
originalCompileTask.enabled = false;
217-
compileTask.destinationDirectory = originalCompileTask.destinationDirectory
218-
219-
project.getTasks().each {
220-
if (recursiveDependenciesOf(it, true).contains(originalCompileTask)) {
221-
it.dependsOn(compileTask)
222-
}
223-
}
224-
225-
// make this project's scoverage compilation depend on scoverage compilation of any other project
226-
// which this project depends on its normal compilation
227-
def originalCompilationDependencies = recursiveDependenciesOf(compileTask, false).findAll {
228-
it instanceof ScalaCompile
229-
}
230-
originalCompilationDependencies.each {
231-
def dependencyProjectCompileTask = it.project.tasks.findByName(COMPILE_NAME)
232-
def dependencyProjectReportTask = it.project.tasks.findByName(REPORT_NAME)
233-
if (dependencyProjectCompileTask != null) {
234-
compileTask.dependsOn(dependencyProjectCompileTask)
235-
// we don't want this project's tests to affect the other project's report
236-
testTasks.each {
237-
it.mustRunAfter(dependencyProjectReportTask)
238-
}
239-
}
213+
compileTask.configure {
214+
doFirst {
215+
destinationDir.deleteDir()
240216
}
241-
} else {
242-
compileTask.configure {
243-
doFirst {
244-
destinationDir.deleteDir()
245-
}
246217

247-
// delete non-instrumented classes by comparing normally compiled classes to those compiled with scoverage
248-
doLast {
249-
project.logger.info("Deleting classes compiled by scoverage but non-instrumented (identical to normal compilation)")
250-
def originalCompileTaskName = project.sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME)
251-
.getCompileTaskName("scala")
252-
def originalDestinationDirectory = project.tasks[originalCompileTaskName].destinationDirectory
253-
def originalDestinationDir = originalDestinationDirectory.get().asFile
254-
def destinationDir = destinationDirectory.get().asFile
255-
256-
257-
def findFiles = { File dir, Closure<Boolean> condition = null ->
258-
def files = []
259-
260-
if (dir.exists()) {
261-
dir.eachFileRecurse(FILES) { f ->
262-
if (condition == null || condition(f)) {
263-
def relativePath = dir.relativePath(f)
264-
files << relativePath
265-
}
218+
// delete non-instrumented classes by comparing normally compiled classes to those compiled with scoverage
219+
doLast {
220+
project.logger.info("Deleting classes compiled by scoverage but non-instrumented (identical to normal compilation)")
221+
def originalCompileTaskName = project.sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME)
222+
.getCompileTaskName("scala")
223+
def originalDestinationDirectory = project.tasks[originalCompileTaskName].destinationDirectory
224+
def originalDestinationDir = originalDestinationDirectory.get().asFile
225+
def destinationDir = destinationDirectory.get().asFile
226+
227+
228+
def findFiles = { File dir, Closure<Boolean> condition = null ->
229+
def files = []
230+
231+
if (dir.exists()) {
232+
dir.eachFileRecurse(FILES) { f ->
233+
if (condition == null || condition(f)) {
234+
def relativePath = dir.relativePath(f)
235+
files << relativePath
266236
}
267237
}
268-
269-
files
270238
}
271239

272-
def isSameFile = { String relativePath ->
273-
def fileA = new File(originalDestinationDir, relativePath)
274-
def fileB = new File(destinationDir, relativePath)
275-
FileUtils.contentEquals(fileA, fileB)
276-
}
240+
files
241+
}
277242

278-
def originalClasses = findFiles(originalDestinationDir)
279-
def identicalInstrumentedClasses = findFiles(destinationDir, { f ->
280-
def relativePath = destinationDir.relativePath(f)
281-
originalClasses.contains(relativePath) && isSameFile(relativePath)
282-
})
243+
def isSameFile = { String relativePath ->
244+
def fileA = new File(originalDestinationDir, relativePath)
245+
def fileB = new File(destinationDir, relativePath)
246+
FileUtils.contentEquals(fileA, fileB)
247+
}
283248

284-
identicalInstrumentedClasses.each { f ->
285-
Files.deleteIfExists(destinationDir.toPath().resolve(f))
286-
}
249+
def originalClasses = findFiles(originalDestinationDir)
250+
def identicalInstrumentedClasses = findFiles(destinationDir, { f ->
251+
def relativePath = destinationDir.relativePath(f)
252+
originalClasses.contains(relativePath) && isSameFile(relativePath)
253+
})
254+
255+
identicalInstrumentedClasses.each { f ->
256+
Files.deleteIfExists(destinationDir.toPath().resolve(f))
287257
}
288258
}
289259
}

0 commit comments

Comments
 (0)