Skip to content

Commit 378217e

Browse files
committed
Merge pull request #21 from maiflai/scoverage-master
Support scoverage 1.0
2 parents e5bcf58 + 339ab71 commit 378217e

File tree

5 files changed

+31
-19
lines changed

5 files changed

+31
-19
lines changed

build.gradle

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
buildscript {
2-
repositories {
3-
mavenCentral()
1+
def isDirty = { ->
2+
def stdout = new ByteArrayOutputStream()
3+
exec {
4+
commandLine 'git', 'status', '--porcelain'
5+
standardOutput = stdout
46
}
5-
dependencies {
6-
classpath 'com.github.townsfolk:gradle-release:1.2'
7+
return stdout.toString().trim()
8+
}
9+
def getVersionName = { ->
10+
def stdout = new ByteArrayOutputStream()
11+
exec {
12+
commandLine 'git', 'describe', '--tags'
13+
standardOutput = stdout
714
}
15+
def gitVersionName = stdout.toString().trim()
16+
return isDirty() ? gitVersionName + '-SNAPSHOT' : gitVersionName
817
}
18+
version = getVersionName()
919

1020
repositories {
1121
mavenCentral()
@@ -19,7 +29,6 @@ ext {
1929
apply plugin: 'idea'
2030
apply plugin: 'maven'
2131
apply plugin: 'groovy'
22-
apply plugin: 'release'
2332

2433
group 'org.scoverage'
2534

@@ -31,7 +40,7 @@ configurations {
3140
dependencies {
3241
compile gradleApi()
3342
compile localGroovy()
34-
scoverage 'org.scoverage:scalac-scoverage-plugin_2.10:0.99.5'
43+
scoverage 'org.scoverage:scalac-scoverage-plugin_2.11:1.0.1'
3544
}
3645

3746
task groovydocJar(type: Jar, dependsOn: groovydoc) {

gradle.properties

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/main/groovy/org/scoverage/ScoverageExtension.groovy

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ package org.scoverage
22

33
import org.gradle.api.Action
44
import org.gradle.api.Project
5-
import org.gradle.api.artifacts.ResolvedConfiguration
5+
import org.gradle.api.artifacts.Configuration
6+
import org.gradle.api.file.FileCollection
67
import org.gradle.api.plugins.JavaPlugin
78
import org.gradle.api.plugins.scala.ScalaPlugin
89
import org.gradle.api.tasks.JavaExec
@@ -77,13 +78,14 @@ class ScoverageExtension {
7778
extension.dataDir.mkdirs()
7879
extension.reportDir.mkdirs()
7980

80-
ResolvedConfiguration s = t.configurations[ScoveragePlugin.CONFIGURATION_NAME].resolvedConfiguration
81-
String pluginPath = s.getFirstLevelModuleDependencies().iterator().next().moduleArtifacts.iterator().next().file.absolutePath
81+
Configuration configuration = t.configurations[ScoveragePlugin.CONFIGURATION_NAME]
82+
File pluginFile = configuration.filter { it.name.contains('plugin') }.iterator().next()
83+
FileCollection pluginDependencies = configuration.filter { it != pluginFile }
8284

8385
t.tasks[ScoveragePlugin.COMPILE_NAME].configure {
8486

8587

86-
List<String> plugin = ['-Xplugin:' + pluginPath]
88+
List<String> plugin = ['-Xplugin:' + pluginFile.absolutePath]
8789
List<String> parameters = scalaCompileOptions.additionalParameters
8890
if (parameters != null) {
8991
plugin.addAll(parameters)
@@ -100,19 +102,18 @@ class ScoverageExtension {
100102
}
101103
scalaCompileOptions.additionalParameters = plugin
102104
// exclude the scala libraries that are added to enable scala version detection
103-
classpath += t.configurations[ScoveragePlugin.CONFIGURATION_NAME]
105+
classpath += pluginDependencies
104106
}
105107

106108
t.tasks[ScoveragePlugin.TEST_NAME].configure {
107109
def existingClasspath = classpath
108110
classpath = t.files(t.sourceSets[ScoveragePlugin.CONFIGURATION_NAME].output.classesDir) +
109-
project.configurations[ScoveragePlugin.CONFIGURATION_NAME] +
111+
pluginDependencies +
110112
existingClasspath
111113
}
112114

113115
t.tasks[ScoveragePlugin.REPORT_NAME].configure {
114-
classpath = project.buildscript.configurations.classpath +
115-
project.configurations[ScoveragePlugin.CONFIGURATION_NAME]
116+
classpath = project.buildscript.configurations.classpath + configuration
116117
main = 'org.scoverage.ScoverageReport'
117118
args = [
118119
extension.sources,

src/main/groovy/org/scoverage/ScoverageReport.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import scala.collection.Set;
55
import scoverage.Coverage;
66
import scoverage.IOUtils;
7+
import scoverage.Serializer;
78
import scoverage.report.CoberturaXmlWriter;
89
import scoverage.report.ScoverageHtmlWriter;
910

@@ -19,13 +20,14 @@ public static void main(String... args) {
1920
File sourceDir = new File(args[0]);
2021
File dataDir = new File(args[1]);
2122
File reportDir = new File(args[2]);
23+
reportDir.mkdirs();
2224

23-
File coverageFile = IOUtils.coverageFile(dataDir);
25+
File coverageFile = Serializer.coverageFile(dataDir);
2426
File[] array = IOUtils.findMeasurementFiles(dataDir);
2527
// TODO: patch scoverage core to use a consistent collection type?
2628
Seq<File> measurementFiles = scala.collection.JavaConversions.asScalaBuffer(Arrays.asList(array));
2729

28-
Coverage coverage = IOUtils.deserialize(coverageFile);
30+
Coverage coverage = Serializer.deserialize(coverageFile);
2931

3032
Set<Object> measurements = IOUtils.invoked(measurementFiles);
3133
coverage.apply(measurements);

src/test/happyday/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ repositories {
1717
}
1818

1919
dependencies {
20-
scoverage 'org.scoverage:scalac-scoverage-plugin_2.11:0.99.5'
20+
scoverage 'org.scoverage:scalac-scoverage-plugin_2.11:1.0.1',
21+
'org.scoverage:scalac-scoverage-runtime_2.11:1.0.1'
2122
compile 'org.scala-lang:scala-library:2.11.0'
2223
testCompile 'junit:junit:4.11'
2324
}

0 commit comments

Comments
 (0)