Skip to content

fix links to source files #7

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
Jun 21, 2014
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ task sourcesJar(type: Jar) {
classifier = 'sources'
}

test {
dependsOn jar
}

artifacts {
archives jar
archives groovydocJar
Expand Down
2 changes: 1 addition & 1 deletion src/main/groovy/org/scoverage/OverallCheckTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class OverallCheckTask extends DefaultTask {
void requireLineCoverage() {
def extension = ScoveragePlugin.extensionIn(project)

if (cobertura == null) cobertura = new File(extension.dataDir, 'cobertura.xml')
if (cobertura == null) cobertura = new File(extension.reportDir, 'cobertura.xml')

def xml = new XmlParser().parse(cobertura)
def overallLineRate = xml.attribute('line-rate').toDouble()
Expand Down
15 changes: 7 additions & 8 deletions src/main/groovy/org/scoverage/ScoverageExtension.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ class ScoverageExtension {
/** a directory to write final output to */
File reportDir
/** sources to highlight */
SourceSet sourceSet

File sources

ScoverageExtension(Project project) {

Expand All @@ -36,7 +35,7 @@ class ScoverageExtension {
description = 'Scoverage dependencies'
}

sourceSet = project.sourceSets.create(ScoveragePlugin.CONFIGURATION_NAME) {
project.sourceSets.create(ScoveragePlugin.CONFIGURATION_NAME) {
def mainSourceSet = project.sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME)

java.source(mainSourceSet.java)
Expand All @@ -50,17 +49,16 @@ class ScoverageExtension {
dependsOn(project.tasks[ScoveragePlugin.COMPILE_NAME])
}

project.tasks.create(ScoveragePlugin.CHECK_NAME, OverallCheckTask.class) {
project.tasks.create(ScoveragePlugin.REPORT_NAME, JavaExec.class) {
dependsOn(project.tasks[ScoveragePlugin.TEST_NAME])
}

project.tasks.create(ScoveragePlugin.REPORT_NAME, JavaExec.class) {
dependsOn(project.tasks[ScoveragePlugin.TEST_NAME])
project.tasks.create(ScoveragePlugin.CHECK_NAME, OverallCheckTask.class) {
dependsOn(project.tasks[ScoveragePlugin.REPORT_NAME])
}

dataDir = new File(project.buildDir, 'scoverage')
reportDir = new File(project.buildDir, 'reports' + File.separatorChar + 'scoverage')

}

private Action<Project> configureRuntimeOptions = new Action<Project>() {
Expand All @@ -69,6 +67,7 @@ class ScoverageExtension {
void execute(Project t) {

def extension = ScoveragePlugin.extensionIn(t)
extension.sources = t.sourceSets.getByName(SourceSet.MAIN_SOURCE_SET_NAME).scala.srcDirs.iterator().next() as File
extension.dataDir.mkdirs()
extension.reportDir.mkdirs()

Expand Down Expand Up @@ -102,7 +101,7 @@ class ScoverageExtension {
project.configurations[ScoveragePlugin.CONFIGURATION_NAME]
main = 'org.scoverage.ScoverageReport'
args = [
extension.sourceSet.allSource.iterator().next().absolutePath,
extension.sources,
extension.dataDir.absolutePath,
extension.reportDir.absolutePath
]
Expand Down
22 changes: 22 additions & 0 deletions src/test/groovy/org/scoverage/PluginAcceptanceTest.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.scoverage

import org.gradle.tooling.GradleConnector
import org.junit.Test

import static org.junit.Assert.assertThat
import static org.hamcrest.core.Is.is

class PluginAcceptanceTest {

@Test
public void testProjectWithCompleteCoverage() throws Exception {
def build = GradleConnector.
newConnector().
forProjectDirectory(new File("src/test/happyday")).
connect().newBuild()
build.forTasks('clean', 'checkScoverage').run()

def html = new File('src/test/happyday/build/reports/scoverage/index.html')
assertThat('an HTML file should be created at ' + html.absolutePath, html.exists(), is(true))
}
}
27 changes: 27 additions & 0 deletions src/test/happyday/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
description = 'a project that builds successfully with 100% coverage'

buildscript {
repositories {
// need to get up to the working directory of gradle-plugins build
flatDir dir: "${project.projectDir}/../../../build/libs"
}
dependencies {
classpath name: 'gradle-scoverage', version: '+'
}
}

apply plugin: 'scoverage'

repositories {
mavenCentral()
}

dependencies {
scoverage 'org.scoverage:scalac-scoverage-plugin_2.11:0.99.5'
compile 'org.scala-lang:scala-library:2.11.0'
testCompile 'junit:junit:4.11'
}

checkScoverage {
minimumLineRate = 1.0
}
5 changes: 5 additions & 0 deletions src/test/happyday/src/main/scala/hello/World.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package hello

object World {
def say() = println("ahoy")
}
10 changes: 10 additions & 0 deletions src/test/happyday/src/test/scala/hello/WorldTest.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package hello

import org.junit.Test

class WorldTest {
@Test
def bob() {
World.say()
}
}