Skip to content

Commit 9c2c096

Browse files
committed
Update the project according to the current (gradle 5.0) plugin development configurations
1 parent 08a7f50 commit 9c2c096

File tree

11 files changed

+103
-121
lines changed

11 files changed

+103
-121
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
classes
22
build
3+
out
34
.gradle
45

56
*.iml

build.gradle

Lines changed: 56 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
1-
// First, apply the publishing plugin
2-
buildscript {
3-
repositories {
4-
maven {
5-
url "https://plugins.gradle.org/m2/"
6-
}
7-
}
8-
dependencies {
9-
classpath "com.gradle.publish:plugin-publish-plugin:0.9.10"
10-
}
11-
}
12-
13-
apply plugin: "com.gradle.plugin-publish"
14-
description = 'gradle-scoverage is a Gradle plugin for calculating code coverage using Scoverage'
15-
if (project.version == 'unspecified') {
16-
version = '2.0.0-SNAPSHOT'
1+
plugins {
2+
id 'java-gradle-plugin'
3+
id "com.gradle.plugin-publish" version "0.10.0"
4+
id "org.jetbrains.gradle.plugin.idea-ext" version "0.4.2"
175
}
186

197
repositories {
20-
mavenCentral()
8+
jcenter()
219
}
2210

11+
group 'org.scoverage'
12+
description = 'gradle-scoverage is a Gradle plugin for calculating code coverage using Scoverage'
13+
version = '2.0.0-SNAPSHOT'
14+
2315
ext {
2416
website = 'http://scoverage.org'
2517
vcsUrl = 'https://github.com/scoverage/gradle-scoverage.git'
@@ -28,24 +20,37 @@ ext {
2820
sonatypePass = System.env.SONATYPE_PASS
2921
}
3022

31-
apply plugin: 'idea'
23+
gradlePlugin {
24+
plugins {
25+
gradleScoverage {
26+
id = 'org.scoverage'
27+
implementationClass = 'org.scoverage.ScoveragePlugin'
28+
}
29+
}
30+
}
31+
32+
pluginBundle {
33+
website = project.website
34+
vcsUrl = ext.vcsUrl
35+
description = project.description
36+
tags = ['coverage', 'scala', 'scoverage']
37+
plugins {
38+
scoveragePlugin {
39+
displayName = 'Gradle Scoverage plugin'
40+
}
41+
}
42+
}
43+
3244
apply plugin: 'maven'
3345
apply plugin: 'groovy'
3446

35-
group 'org.scoverage'
3647
sourceCompatibility = '1.6'
3748
targetCompatibility = '1.6'
3849

39-
configurations {
40-
scoverage
41-
compile.extendsFrom scoverage
42-
}
43-
4450
dependencies {
45-
compile gradleApi()
46-
compile localGroovy()
47-
scoverage "org.scoverage:scalac-scoverage-plugin_2.11:1.1.1"
48-
testCompile 'junit:junit:4.12', 'org.hamcrest:hamcrest-library:1.3'
51+
compile "org.scoverage:scalac-scoverage-plugin_2.12:1.3.1"
52+
testCompile 'junit:junit:4.12'
53+
testCompile 'org.hamcrest:hamcrest-library:1.3'
4954
}
5055

5156
task groovydocJar(type: Jar, dependsOn: groovydoc) {
@@ -58,10 +63,6 @@ task sourcesJar(type: Jar) {
5863
classifier = 'sources'
5964
}
6065

61-
test {
62-
dependsOn jar
63-
}
64-
6566
artifacts {
6667
archives jar
6768
archives groovydocJar
@@ -75,25 +76,11 @@ if (project.properties.containsKey('signing.keyId')) {
7576
}
7677
}
7778

78-
pluginBundle {
79-
website = project.website
80-
vcsUrl = project.vcsUrl
81-
description = project.description
82-
tags = ['coverage', 'scala', 'scoverage']
83-
withDependencies { it.clear() }
84-
plugins {
85-
scoveragePlugin {
86-
id = 'org.scoverage'
87-
displayName = 'Gradle Scoverage plugin'
88-
}
89-
}
90-
}
91-
9279
uploadArchives {
9380
repositories {
9481
mavenDeployer {
9582
if (project.properties.containsKey('signing.keyId')) {
96-
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
83+
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
9784
}
9885

9986
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots') {
@@ -132,8 +119,30 @@ uploadArchives {
132119
developer {
133120
id 'D-Roch'
134121
}
122+
developer {
123+
id 'eyalroth'
124+
}
135125
}
136126
}
137127
}
138128
}
139129
}
130+
131+
// see https://stackoverflow.com/questions/44679007
132+
task fixIdeaPluginClasspath {
133+
doFirst {
134+
configure(tasks.pluginUnderTestMetadata) {
135+
def ideaClassesPath = project.buildDir.toPath().resolveSibling("out").resolve("production")
136+
def newClasspath = pluginClasspath as List
137+
newClasspath.add(0, ideaClassesPath)
138+
pluginClasspath.setFrom(newClasspath)
139+
}
140+
}
141+
}
142+
pluginUnderTestMetadata.mustRunAfter(fixIdeaPluginClasspath)
143+
144+
idea.project.settings {
145+
taskTriggers {
146+
beforeBuild fixIdeaPluginClasspath, pluginUnderTestMetadata
147+
}
148+
}

init-scoverage.gradle

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/test/groovy/org/scoverage/AcceptanceTestUtils.groovy

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.scoverage
22

3-
import org.gradle.tooling.BuildLauncher
4-
import org.gradle.tooling.GradleConnector
3+
import org.gradle.testkit.runner.GradleRunner
54
import org.hamcrest.core.Is
65
import org.junit.Assert
76

@@ -20,15 +19,16 @@ class AcceptanceTestUtils {
2019
parser.setFeature('http://apache.org/xml/features/nonvalidating/load-external-dtd', false)
2120
}
2221

23-
protected BuildLauncher setupBuild(File projectRoot) {
24-
return GradleConnector.
25-
newConnector().
26-
forProjectDirectory(projectRoot).
27-
connect().
28-
newBuild().
29-
withArguments(
30-
'--init-script',
31-
new File(System.properties.getProperty('user.dir'), 'init-scoverage.gradle').toString())
22+
protected void runBuild(File projectRoot, String... tasks) {
23+
def runner = GradleRunner
24+
.create()
25+
.withProjectDir(projectRoot)
26+
.withPluginClasspath()
27+
.forwardOutput()
28+
29+
def arguments = tasks + "-PscoverageVersion=1.3.1"
30+
31+
runner.withArguments(arguments as List).build()
3232
}
3333

3434
protected void checkFile(String description, File file, boolean shouldExist) throws Exception {

src/test/groovy/org/scoverage/AggregationAcceptanceTest.groovy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ class AggregationAcceptanceTest extends AcceptanceTestUtils {
77
@Test
88
public void testMultiProjectAggregation() throws Exception {
99
File projectDir = new File('src/test/water')
10-
def build = setupBuild(projectDir)
11-
build.forTasks('clean', 'aggregateScoverage').run()
10+
runBuild(projectDir, 'clean', 'aggregateScoverage')
1211
def indexHtml = new File(aggregateReportDir(projectDir), 'index.html')
1312
checkFile('an aggregated index HTML file', indexHtml, true)
1413
def cobertura = new File(aggregateReportDir(projectDir), 'cobertura.xml')

src/test/groovy/org/scoverage/SeparateTestsAcceptanceTest.groovy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ class SeparateTestsAcceptanceTest extends AcceptanceTestUtils {
1212
File projectDir = new File('src/test/separate-tests')
1313
File subprojectDir = new File(projectDir, 'a')
1414
File testsSubprojectDir = new File(projectDir, 'a-tests')
15-
def build = setupBuild(projectDir)
16-
build.forTasks('clean', 'reportScoverage').run()
15+
runBuild(projectDir, 'clean', 'reportScoverage')
1716
def indexHtml = new File(reportDir(subprojectDir), 'index.html')
1817
checkFile('an index HTML file', indexHtml, true)
1918
def testsIndexHtml = new File(reportDir(testsSubprojectDir), 'index.html')

src/test/groovy/org/scoverage/SimpleReportAcceptanceTest.groovy

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ class SimpleReportAcceptanceTest extends AcceptanceTestUtils {
88
@Test
99
public void testProjectWithCompleteCoverage() throws Exception {
1010
File projectRoot = new File('src/test/happy day')
11-
def build = setupBuild(projectRoot)
12-
build.forTasks('clean', 'checkScoverage').run()
11+
runBuild(projectRoot, 'clean', 'checkScoverage')
1312
def html = new File(reportDir(projectRoot), 'index.html')
1413
checkFile('an index HTML file', html, true)
1514
def cobertura = new File(reportDir(projectRoot), 'cobertura.xml')
@@ -21,7 +20,6 @@ class SimpleReportAcceptanceTest extends AcceptanceTestUtils {
2120
@Test
2221
public void testRun() throws Exception {
2322
File projectRoot = new File('src/test/runtime')
24-
def build = setupBuild(projectRoot)
25-
build.forTasks('clean', 'run').run()
23+
runBuild(projectRoot, 'clean', 'run')
2624
}
2725
}

src/test/happy day/build.gradle

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
1-
description = 'a project that builds successfully with 100% coverage'
2-
3-
buildscript {
4-
repositories {
5-
// need to get up to the working directory of gradle-plugins build
6-
flatDir dir: "${project.projectDir}/../../../build/libs"
7-
}
8-
dependencies {
9-
classpath name: 'gradle-scoverage', version: '+'
10-
}
1+
plugins {
2+
id 'org.scoverage'
113
}
124

13-
apply plugin: 'org.scoverage'
5+
description = 'a project that builds successfully with 100% coverage'
146

157
repositories {
16-
mavenCentral()
8+
jcenter()
179
}
1810

1911
dependencies {
20-
scoverage scoverageLib
12+
scoverage "org.scoverage:scalac-scoverage-plugin_2.11:${scoverageVersion}",
13+
"org.scoverage:scalac-scoverage-runtime_2.11:${scoverageVersion}"
2114
compile 'org.scala-lang:scala-library:2.11.0'
2215
testCompile 'junit:junit:4.11'
2316
}

src/test/runtime/build.gradle

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,16 @@
1-
description = 'a project that runs an application and captures scoverage'
2-
3-
buildscript {
4-
repositories {
5-
// need to get up to the working directory of gradle-plugins build
6-
flatDir dir: "${project.projectDir}/../../../build/libs"
7-
}
8-
dependencies {
9-
classpath name: 'gradle-scoverage', version: '+'
10-
}
1+
plugins {
2+
id 'org.scoverage'
113
}
124

13-
apply plugin: 'org.scoverage'
5+
description = 'a project that runs an application and captures scoverage'
146

157
repositories {
16-
mavenCentral()
8+
jcenter()
179
}
1810

1911
dependencies {
20-
scoverage scoverageLib
12+
scoverage "org.scoverage:scalac-scoverage-plugin_2.11:${scoverageVersion}",
13+
"org.scoverage:scalac-scoverage-runtime_2.11:${scoverageVersion}"
2114
compile 'org.scala-lang:scala-library:2.11.0'
2215
}
2316

src/test/separate-tests/build.gradle

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
1+
plugins {
2+
id 'org.scoverage'
3+
}
4+
15
description = 'a multi-project with separate tests setup for gradle-scoverage'
26

3-
buildscript {
7+
allprojects {
8+
49
repositories {
5-
// need to get up to the working directory of gradle-plugins build
6-
flatDir dir: "${project.projectDir}/../../../build/libs"
10+
jcenter()
711
}
12+
13+
apply plugin: 'org.scoverage'
14+
815
dependencies {
9-
classpath name: 'gradle-scoverage', version: '+'
16+
scoverage "org.scoverage:scalac-scoverage-plugin_2.11:${scoverageVersion}",
17+
"org.scoverage:scalac-scoverage-runtime_2.11:${scoverageVersion}"
1018
}
1119
}
1220

1321
subprojects {
1422

15-
repositories {
16-
mavenCentral()
17-
}
18-
1923
apply plugin: 'scala'
20-
apply plugin: 'org.scoverage'
2124

2225
dependencies {
2326
compile 'org.scala-lang:scala-library:2.11.4'
24-
scoverage scoverageLib
2527

2628
testCompile 'junit:junit:4.11'
2729
}

src/test/water/build.gradle

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1-
description = 'a multi-project setup for gradle-scoverage'
2-
3-
buildscript {
4-
repositories {
5-
// need to get up to the working directory of gradle-plugins build
6-
flatDir dir: "${project.projectDir}/../../../build/libs"
7-
}
8-
dependencies {
9-
classpath name: 'gradle-scoverage', version: '+'
10-
}
1+
plugins {
2+
id 'org.scoverage'
113
}
124

5+
description = 'a multi-project setup for gradle-scoverage'
6+
137
allprojects {
148
repositories {
15-
mavenCentral()
9+
jcenter()
1610
}
1711

1812
apply plugin: 'org.scoverage'
1913

2014
dependencies {
21-
scoverage scoverageLib
15+
scoverage "org.scoverage:scalac-scoverage-plugin_2.11:${scoverageVersion}",
16+
"org.scoverage:scalac-scoverage-runtime_2.11:${scoverageVersion}"
2217
compile 'org.scala-lang:scala-library:2.11.5'
2318

2419
testCompile 'junit:junit:4.11'

0 commit comments

Comments
 (0)