Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/bugfix/issue#7'
Browse files Browse the repository at this point in the history
  • Loading branch information
iwarapter committed Dec 1, 2015
2 parents 246ec14 + 0db1712 commit 48b4263
Show file tree
Hide file tree
Showing 29 changed files with 529 additions and 135 deletions.
11 changes: 3 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
Gradle Sonar Packaging Plugin
=========

This is a gradle plugin for building plugins for [SonarQube] it is a port of the original maven plugin.

Waffle Board (Issues)
------------
[![Stories in Ready](https://badge.waffle.io/iwarapter/gradle-sonar-packaging-plugin.png?label=ready&title=Ready)](https://waffle.io/iwarapter/gradle-sonar-packaging-plugin)
[![Stories in Ready](https://badge.waffle.io/iwarapter/gradle-sonar-packaging-plugin.png?label=In Progress&title=In Progress)](https://waffle.io/iwarapter/gradle-sonar-packaging-plugin)
This is a gradle plugin for building plugins for [SonarQube] it is a port of the original maven plugin.

Build Status
------------
Expand All @@ -28,7 +23,7 @@ buildscript {
}
}
dependencies {
classpath "gradle.plugin.com.iadams.plugins:gradle-sonar-packaging-plugin:0.1.2"
classpath "gradle.plugin.com.iadams.plugins:gradle-sonar-packaging-plugin:0.1.3"
}
}
Expand All @@ -37,7 +32,7 @@ apply plugin: "com.iadams.sonar-packaging"
Build script snippet for new, incubating, plugin mechanism introduced in Gradle 2.1:
```
plugins {
id "com.iadams.sonar-packaging" version "0.1.2"
id "com.iadams.sonar-packaging" version "0.1.3"
}
```

Expand Down
25 changes: 23 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ apply from: "$rootDir/gradle/sonar.gradle"
apply from: "$rootDir/gradle/groovydoc.gradle"

group = 'com.iadams.plugins'
version = '0.1.2'
version = '0.1.3-SNAPSHOT'

description = 'Gradle plugin for packaging SonarQube plugins.'

Expand All @@ -35,7 +35,28 @@ dependencies {
compile gradleApi()
compile 'org.codehaus.groovy.modules.http-builder:http-builder:0.7'

testCompile ('com.netflix.nebula:nebula-test:3.1.0') { exclude group: 'org.codehaus.groovy' }
testCompile gradleTestKit()
testCompile 'org.spockframework:spock-core:1.0-groovy-2.4', {
exclude module: 'groovy-all'
}
}

// Write the plugin's classpath to a file to share with the tests
task createClasspathManifest {
def outputDir = file("$buildDir/$name")

inputs.files sourceSets.main.runtimeClasspath
outputs.dir outputDir

doLast {
outputDir.mkdirs()
file("$outputDir/plugin-classpath.txt").text = sourceSets.main.runtimeClasspath.join("\n")
}
}

// Add the classpath file to the test runtime classpath
dependencies {
testRuntime files(createClasspathManifest)
}

pluginBundle {
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Oct 18 14:09:38 BST 2015
#Sun Nov 29 12:08:32 GMT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.9-all.zip
4 changes: 2 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ while [ -h "$PRG" ] ; do
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >&-
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >&-
cd "$SAVED" >/dev/null

CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,82 @@
package com.iadams.gradle.plugins

import com.iadams.gradle.plugins.utils.SonarPackagingBaseIntegSpec
import org.gradle.testkit.runner.GradleRunner
import spock.lang.Unroll

/**
* Created by iwarapter
*/
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS

class GradleCompatabilityIntegSpec extends SonarPackagingBaseIntegSpec {

@Unroll
def "should use Gradle #requestedGradleVersion when requested"() {
def "compatible with gradle #gradleVersion"() {
setup:
def sub1 = addSubproject('example-squid')
def sub2 = addSubproject('sonar-example-plugin')

writeHelloWorld('com.example', sub1)
writeHelloWorld('com.example', sub2)
writeHelloWorld('com.example', sub1.name)
writeHelloWorld('com.example', sub2.name)
copyResources('build.gradle', 'sonar-example-plugin/build.gradle')
fork = true
//remoteDebug = true

and:
gradleVersion = requestedGradleVersion
when:
def result = GradleRunner.create()
.withProjectDir(testProjectDir.root)
.withGradleVersion(gradleVersion)
.withArguments('build')
.withPluginClasspath(pluginClasspath)
.build()

then:
result.task(':sonar-example-plugin:build').outcome == SUCCESS
manifestContains('sonar-example-plugin/build/libs/sonar-example-plugin-1.0.jar', 'Plugin-Description', 'An Example Plugin!')
manifestContains('sonar-example-plugin/build/libs/sonar-example-plugin-1.0.jar', 'Plugin-Key', 'example')
manifestContains('sonar-example-plugin/build/libs/sonar-example-plugin-1.0.jar', 'Plugin-Class', 'com.example.HelloWorld')
manifestContains('sonar-example-plugin/build/libs/sonar-example-plugin-1.0.jar', 'Plugin-Name', 'Example')

where:
//using the new framework
gradleVersion << ['2.8', '2.9']
}

@Unroll
def "compatible with legacy gradle #gradleVersion"() {
setup:
def sub1 = addSubproject('example-squid')
def sub2 = addSubproject('sonar-example-plugin')

writeHelloWorld('com.example', sub1.name)
writeHelloWorld('com.example', sub2.name)
copyResources('legacy_build.gradle', 'sonar-example-plugin/build.gradle')

def classpathString = pluginClasspath
.collect { it.absolutePath.replace('\\', '\\\\') } // escape backslashes in Windows paths
.collect { "'$it'" }
.join(", ")

new File(sub2, 'build.gradle') << """
buildscript {
dependencies {
classpath files($classpathString)
}
}
"""

when:
runTasksSuccessfully('build')
def result = GradleRunner.create()
.withProjectDir(testProjectDir.root)
.withGradleVersion(gradleVersion)
.withArguments('build')
.build()

then:
result.task(':sonar-example-plugin:build').outcome == SUCCESS
manifestContains('sonar-example-plugin/build/libs/sonar-example-plugin-1.0.jar', 'Plugin-Description', 'An Example Plugin!')
manifestContains('sonar-example-plugin/build/libs/sonar-example-plugin-1.0.jar', 'Plugin-Key', 'example')
manifestContains('sonar-example-plugin/build/libs/sonar-example-plugin-1.0.jar', 'Plugin-Class', 'com.example.HelloWorld')
manifestContains('sonar-example-plugin/build/libs/sonar-example-plugin-1.0.jar', 'Plugin-Name', 'Example')

where:
//Add future versions, not backwards compatible.
requestedGradleVersion << ['2.3', '2.4', '2.5', '2.6', '2.7']
//testing the older versions
gradleVersion << ['2.5', '2.6', '2.7']
}
}
Loading

0 comments on commit 48b4263

Please sign in to comment.