Skip to content
Browse files

Fixes for the way the Gradle plugin works.

  • Loading branch information...
1 parent 538e485 commit c31769080edad44cc0d6b20df204a9f5633c5e88 @alkemist alkemist committed Jan 18, 2013
View
13 build.gradle
@@ -1,6 +1,6 @@
allprojects {
group = 'com.augusttechgroup'
- version = '0.7.0-SNAPSHOT'
+ version = rootProject.file("shared-resources/com/bleedingwolf/ratpack/ratpack-version.txt").text.trim()
apply plugin: 'idea'
apply plugin: 'eclipse'
@@ -9,6 +9,10 @@ allprojects {
apply from: "idea/idea.gradle"
subprojects {
+ if (project.name.endsWith("-test")) {
+ return
+ }
+
apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'signing'
@@ -17,6 +21,12 @@ subprojects {
mavenCentral()
}
+ sourceSets.main {
+ resources {
+ srcDir rootProject.file("shared-resources")
+ }
+ }
+
task sourceJar(type: Jar) {
description 'An archive of the source code for Maven Central'
classifier 'sources'
@@ -76,6 +86,7 @@ subprojects {
}
}
+
poms*.whenConfigured { applyPomMods(it) }
modifyPom {
View
11 ratpack-core/build.gradle
@@ -1,18 +1,11 @@
dependencies {
groovy 'org.codehaus.groovy:groovy-all:2.0.6'
+ compile 'org.codehaus.groovy:groovy-all:2.0.6'
compile 'org.slf4j:slf4j-api:1.6.3'
compile 'org.eclipse.jetty:jetty-server:8.1.8.v20121106'
runtime 'org.slf4j:slf4j-simple:1.6.3'
testCompile 'cglib:cglib-nodep:2.2'
testCompile 'org.spockframework:spock-core:0.7-groovy-2.0'
-}
-
-processResources {
- eachFile {
- if (it.file.name != "exception.html") {
- it.expand ratpackVersion: version, servletApiVersion: "2.5"
- }
- }
-}
+}
View
16 ratpack-gradle-plugin-test/build.gradle
@@ -0,0 +1,16 @@
+buildscript {
+ repositories {
+ mavenLocal()
+ mavenCentral()
+ }
+ dependencies {
+ classpath group: rootProject.group, name: "ratpack-gradle-plugin", version: version
+ }
+}
+
+apply plugin: 'ratpack'
+
+repositories {
+ mavenLocal()
+ mavenCentral()
+}
View
3 ratpack-gradle-plugin-test/src/ratpack/ratpack.groovy
@@ -0,0 +1,3 @@
+get("/") {
+ response.renderString "foo"
+}
View
4 ratpack-gradle-plugin/src/main/groovy/com/timberglund/ratpack/gradle/RatpackPlugin.groovy
@@ -29,7 +29,7 @@ import org.gradle.api.plugins.ApplicationPlugin
class RatpackPlugin implements Plugin<Project> {
void apply(Project project) {
- def meta = RatpackPluginMeta.fromResource(getClass().classLoader)
+ def version = getClass().classLoader.getResource("com/bleedingwolf/ratpack/ratpack-version.txt").text.trim()
project.plugins.apply(GroovyPlugin)
project.plugins.apply(ApplicationPlugin)
@@ -42,7 +42,7 @@ class RatpackPlugin implements Plugin<Project> {
project.dependencies {
runtime 'org.slf4j:slf4j-simple:1.6.3'
- compile "com.augusttechgroup:ratpack-core:${meta.ratpackVersion}"
+ compile "com.augusttechgroup:ratpack-core:${version}"
}
project.run {
View
51 ...ack-gradle-plugin/src/main/groovy/com/timberglund/ratpack/gradle/RatpackPluginMeta.groovy
@@ -1,51 +0,0 @@
-/*
- * Copyright 2012 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.timberglund.ratpack.gradle
-
-class RatpackPluginMeta {
-
- public static final String DEFAULT_RATPACK_VERSION = "0.7.0-SNAPSHOT"
-
- public static final String
-
- final String ratpackVersion
- final String servletApiVersion
-
- RatpackPluginMeta(String ratpackVersion, String servletApiVersion) {
- this.ratpackVersion = ratpackVersion
- this.servletApiVersion = servletApiVersion
- }
-
- static RatpackPluginMeta fromResource(ClassLoader classLoader) {
- def resource = classLoader.getResource("ratpack.properties")
- def properties = new Properties()
- resource.withInputStream { properties.load(it) }
-
- String ratpackVersion
- String servletApiVersion
-
- if (properties["ratpack-version"].startsWith("\${")) {
- // means we loaded from the IDE and the file has not been tokenised.
- ratpackVersion = DEFAULT_RATPACK_VERSION
- } else {
- ratpackVersion = properties["ratpack-version"]
- }
-
- new RatpackPluginMeta(ratpackVersion, servletApiVersion)
- }
-
-}
View
66 ...gradle-plugin/src/test/groovy/com/timberglund/ratpack/gradle/RatpackPluginMetaTest.groovy
@@ -1,66 +0,0 @@
-/*
- * Copyright 2012 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.timberglund.ratpack.gradle
-
-import spock.lang.Specification
-import org.junit.rules.TemporaryFolder
-import org.junit.Rule
-
-public class RatpackPluginMetaTest extends Specification {
-
- @Rule TemporaryFolder tmp
-
- private tmpFileCounter = 0
-
- def "can load when file has not been parameterised"() {
- given:
- def loader = createMockedClassLoader """
- ratpack-version=\${ratpackVersion}
- """
-
- when:
- def meta = RatpackPluginMeta.fromResource(loader)
-
- then:
- meta.ratpackVersion == RatpackPluginMeta.DEFAULT_RATPACK_VERSION
- }
-
- def "can load when file has been parameterised"() {
- given:
- def loader = createMockedClassLoader """
- ratpack-version=1.3
- """
-
- when:
- def meta = RatpackPluginMeta.fromResource(loader)
-
- then:
- meta.ratpackVersion == "1.3"
- }
-
- def ClassLoader createMockedClassLoader(String content) {
- def loader = Mock(ClassLoader)
- interaction { _ * loader.getResource("ratpack.properties") >> createUrl(content) }
- loader
- }
-
- def URL createUrl(String content) {
- def file = tmp.newFile("tmp${tmpFileCounter++}.txt")
- file.write(content)
- file.toURL()
- }
-}
View
5 ...le-plugin/src/test/groovy/com/timberglund/ratpack/gradle/functional/FunctionalSpec.groovy
@@ -80,14 +80,17 @@ abstract class FunctionalSpec extends Specification {
}
File file(String path) {
- new File(dir.root, path)
+ def file = new File(dir.root, path)
+ assert file.parentFile.mkdirs() || file.parentFile.exists()
+ file
}
ExecutedTask task(String name) {
executedTasks.find { it.task.name == name }
}
def setup() {
+ file("settings.gradle") << "rootProject.name = 'test-app'"
buildFile << """
ext.RatpackPlugin = project.class.classLoader.loadClass('${RatpackPlugin.name}')
apply plugin: RatpackPlugin
View
61 ...le-plugin/src/test/groovy/com/timberglund/ratpack/gradle/functional/InstallAppSpec.groovy
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2012 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.timberglund.ratpack.gradle.functional
+
+import spock.util.concurrent.PollingConditions
+
+class InstallAppSpec extends FunctionalSpec {
+
+ def "everything goes in the right place"() {
+ given:
+ buildFile << """
+ repositories {
+ mavenLocal()
+ }
+ """
+ file("src/ratpack/ratpack.groovy") << """
+ get("/") { response.renderString "foo" }
+ """
+ when:
+ run "installApp"
+
+ def process = new ProcessBuilder().directory(file("build/install/test-app")).command("bin/test-app").start()
+ process.consumeProcessOutput(System.out, System.err)
+
+ then:
+ new PollingConditions().within(10) {
+ try {
+ urlText("") == "foo"
+ } catch (ConnectException ignore) {
+ false
+ }
+ }
+
+ cleanup:
+ process?.destroy()
+ process?.waitFor()
+ }
+
+ HttpURLConnection url(String path = "") {
+ new URL("http://localhost:5050/$path").openConnection() as HttpURLConnection
+ }
+
+ String urlText(String path = "") {
+ new URL("http://localhost:5050/$path").text
+ }
+
+}
View
35 .../src/test/groovy/com/timberglund/ratpack/gradle/functional/PackagingFunctionalSpec.groovy
@@ -1,35 +0,0 @@
-/*
- * Copyright 2012 the original author or authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.timberglund.ratpack.gradle.functional
-
-class PackagingFunctionalSpec extends FunctionalSpec {
-
-/*
- def "everything goes in the right place"() {
- given:
- makeFile("src/app/scripts/app.groovy") << "get('/') { render 'index.html' }"
- makeFile("src/app/templates/index.html") << "Hello World!"
-
- when:
- run "war"
-
- then:
- unpackedWarFile("WEB-INF/scripts/app.groovy").text == "get('/') { render 'index.html' }"
- unpackedWarFile("WEB-INF/classes/templates/index.html").text == "Hello World!"
- }
-*/
-}
View
6 settings.gradle
@@ -1 +1,5 @@
-include "ratpack-core", "ratpack-gradle-plugin"
+include "ratpack-core", "ratpack-gradle-plugin"
+
+if (System.properties["incTestProject"] != null) {
+ include "ratpack-gradle-plugin-test"
+}
View
1 shared-resources/com/bleedingwolf/ratpack/ratpack-version.txt
@@ -0,0 +1 @@
+0.7.0-SNAPSHOT

0 comments on commit c317690

Please sign in to comment.
Something went wrong with that request. Please try again.