Skip to content

Commit

Permalink
Updating dependencies and tests for 0.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
eriwen committed Aug 15, 2011
1 parent 8715dea commit 9f9f757
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 126 deletions.
6 changes: 3 additions & 3 deletions griffon-app/conf/BuildConfig.groovy
Expand Up @@ -8,11 +8,11 @@ griffon.project.dependency.resolution = {
mavenCentral()
}
dependencies {
build 'org.python:jython:2.5.0'
compile 'org.python:jython:2.5.0'
build 'org.python:jython-standalone:2.5.2'
compile 'org.python:jython-standalone:2.5.2'

def springVersion = '3.0.5.RELEASE'
compile("org.springframework:org.springframework.core:$springVersion") {
compile("org.springframework:spring-core:$springVersion") {
transitive = false
}
}
Expand Down
43 changes: 22 additions & 21 deletions scripts/CreateJythonClass.groovy
@@ -1,11 +1,11 @@
/*
* Copyright 2010 the original author or authors.
* Copyright 2011 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
* 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,
Expand All @@ -27,27 +27,28 @@ includeTargets << griffonScript("_GriffonInit")
includeTargets << griffonScript("_GriffonCreateArtifacts")

target(default: "Creates a new Jython class") {
depends(checkVersion, parseArguments)
promptForName(type: "Class")
def (pkg, name) = extractArtifactName(argsMap["params"][0])
pkg = pkg ?: "griffon"
def clazzName = GCU.getClassNameRepresentation(name)
def clazz = "${pkg}.${clazzName}"
depends(checkVersion, parseArguments)
promptForName(type: "Class")
def (pkg, name) = extractArtifactName(argsMap["params"][0])
pkg = pkg ?: "griffon"
def clazzName = GCU.getClassNameRepresentation(name)
def clazz = "${pkg}.${clazzName}"

def packageDir = new File("${basedir}/src/jython/${pkg.replace('.','/')}")
println packageDir
packageDir.mkdirs()
def packageDir = new File("${basedir}/src/jython/${pkg.replace('.','/')}")
println packageDir
packageDir.mkdirs()

def classFile = new File(packageDir, "${name}.py")
if(classFile.exists()) {
if(!confirmInput("WARNING: ${clazz} already exists. Are you sure you want to replace it?")) {
exit(0)
}
}
println "Creating ${clazz} ..."
classFile.text = """\
def classFile = new File(packageDir, "${name}.py")
if(classFile.exists()) {
if(!confirmInput("WARNING: ${clazz} already exists. Are you sure you want to replace it?")) {
exit(0)
}
}
println "Creating ${clazz} ..."
classFile.text = """\
class ${clazzName}:
def __init__(self):
print 'Hello ${clazzName}'
def __init__(self):
print 'Hello ${clazzName}'
"""
exit(0)
}
37 changes: 19 additions & 18 deletions scripts/CreateJythonScript.groovy
@@ -1,11 +1,11 @@
/*
* Copyright 2010 the original author or authors.
* Copyright 2011 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
* 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,
Expand All @@ -25,27 +25,28 @@ includeTargets << griffonScript("_GriffonInit")
includeTargets << griffonScript("_GriffonCreateArtifacts")

target('default': "Creates a new Jython script") {
depends(parseArguments)
depends(parseArguments)

promptForName(type: 'Script')
promptForName(type: 'Script')

def name = argsMap["params"][0]
def scriptDir = new File("./griffon-app/resources/jython")
scriptDir.mkdirs()
def name = argsMap["params"][0]
def scriptDir = new File("./griffon-app/resources/jython")
scriptDir.mkdirs()

def scriptName = "${scriptDir.canonicalPath}/${name}.py"
def scriptFile = new File(scriptName)
if(scriptFile.exists()) {
if(!confirmInput("WARNING: ${scriptName} already exists. Are you sure you want to replace this script?")) {
exit(0)
}
}
println "Creating ${scriptName} ..."
scriptFile.text = """\
def scriptName = "${scriptDir.canonicalPath}/${name}.py"
def scriptFile = new File(scriptName)
if(scriptFile.exists()) {
if(!confirmInput("WARNING: ${scriptName} already exists. Are you sure you want to replace this script?")) {
exit(0)
}
}
println "Creating ${scriptName} ..."
scriptFile.text = """\
def main():
print 'Hello ${name}!'
print 'Hello ${name}!'
if __name__ == '__main__':
main()
main()
"""
exit(0)
}
16 changes: 8 additions & 8 deletions scripts/JythonRepl.groovy
@@ -1,11 +1,11 @@
/*
* Copyright 2010 the original author or authors.
* Copyright 2011 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
* 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,
Expand All @@ -26,13 +26,13 @@ includeTargets << griffonScript("_GriffonPackage")
includePluginScript("jython", "_JythonCommon")

target(default: "Run Jython REPL") {
depends(checkVersion, classpath, packageApp)
depends(checkVersion, classpath, packageApp)

addUrlIfNotPresent classLoader.parent, classesDir
addUrlIfNotPresent classLoader.parent, resourcesDir
addUrlIfNotPresent classLoader.parent, classesDir
addUrlIfNotPresent classLoader.parent, resourcesDir

//TODO: setup python interpreter to allow up-arrow etc. May have to use JLine
PythonInterpreter pi = new PythonInterpreter()
pi.exec("from code import InteractiveConsole")
pi.exec("InteractiveConsole.interact(InteractiveConsole(), '\\nWelcome to the Griffon - Jython REPL!\\nUse Ctrl+D to exit\\n')")
PythonInterpreter pi = new PythonInterpreter()
pi.exec("from code import InteractiveConsole")
pi.exec("InteractiveConsole.interact(InteractiveConsole(), '\\nWelcome to the Griffon - Jython REPL!\\nUse Ctrl+D to exit\\n')")
}
116 changes: 58 additions & 58 deletions scripts/_JythonCommon.groovy
@@ -1,11 +1,11 @@
/*
* Copyright 2010 the original author or authors.
* Copyright 2011 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
* 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,
Expand All @@ -31,78 +31,78 @@ import org.python.core.imp as JythonImp
import org.python.modules._py_compile

target(name: 'compileJythonSrc', description: "", prehook: null, posthook: null) {
depends(parseArguments)
depends(parseArguments)

includePluginScript("lang-bridge", "CompileCommons")
compileCommons()
def jythonsrc = "${basedir}/src/jython"
def jythonsrcdir = new File(jythonsrc)
if(!jythonsrcdir.exists() || !jythonsrcdir.list().size()) {
ant.echo(message: "[jython] No Jython sources were found.")
return
}

if(sourcesUpToDate("${basedir}/src/jython", classesDirPath, ".py")) return

ant.echo(message: "[jython] Compiling Jython sources to $classesDirPath")
try {
defineJythonCompilePath(jythonsrc, classesDirPath)
compileJythonFiles(jythonsrcdir, classesDirPath)
}
catch (Exception e) {
if(argsMap.verboseCompile) {
StackTraceUtils.deepSanitize(e)
e.printStackTrace(System.err)
}
event("StatusFinal", ["Compilation error: ${e.message}"])
exit(1)
}
compileCommons()
def jythonsrc = "${basedir}/src/jython"
def jythonsrcdir = new File(jythonsrc)
if(!jythonsrcdir.exists() || !jythonsrcdir.list().size()) {
ant.echo(message: "[jython] No Jython sources were found.")
return
}

if(sourcesUpToDate("${basedir}/src/jython", classesDirPath, ".py")) return

ant.echo(message: "[jython] Compiling Jython sources to $classesDirPath")
try {
defineJythonCompilePath(jythonsrc, classesDirPath)
compileJythonFiles(jythonsrcdir, classesDirPath)
}
catch (Exception e) {
if(argsMap.verboseCompile) {
StackTraceUtils.deepSanitize(e)
e.printStackTrace(System.err)
}
event("StatusFinal", ["Compilation error: ${e.message}"])
exit(1)
}
}

target(name: 'compileJythonTest', description: "", prehook: null, posthook: null) {
depends(parseArguments)
depends(parseArguments)

def jythontest = "${basedir}/test/jython"
def jythontestdir = new File(jythontest)
if(!jythontestdir.exists() || !jythontestdir.list().size()) {
ant.echo(message: "[jython] No Jython tests sources were found.")
return
}
def jythontest = "${basedir}/test/jython"
def jythontestdir = new File(jythontest)
if(!jythontestdir.exists() || !jythontestdir.list().size()) {
ant.echo(message: "[jython] No Jython tests sources were found.")
return
}

def destdir = new File(griffonSettings.testClassesDir, "jython")
ant.mkdir(dir: destdir)
def destdir = new File(griffonSettings.testClassesDir, "jython")
ant.mkdir(dir: destdir)

if(sourcesUpToDate(jythontest, destdir.absolutePath, ".py")) return
if(sourcesUpToDate(jythontest, destdir.absolutePath, ".py")) return

ant.echo(message: "[jython] Compiling Jython test sources to $destdir")
try {
defineJythonTestPath(jythontest, destdir)
ant.echo(message: "[jython] Compiling Jython test sources to $destdir")
try {
defineJythonTestPath(jythontest, destdir)
compileJythonFiles(jythontestdir, destdir)
}
catch (Exception e) {
if(argsMap.verboseCompile) {
StackTraceUtils.deepSanitize(e)
e.printStackTrace(System.err)
}
event("StatusFinal", ["Compilation error: ${e.message}"])
exit(1)
}
}
catch (Exception e) {
if(argsMap.verboseCompile) {
StackTraceUtils.deepSanitize(e)
e.printStackTrace(System.err)
}
event("StatusFinal", ["Compilation error: ${e.message}"])
exit(1)
}
}

defineJythonCompilePath = { srcdir, destdir ->
ant.path(id: "jython.compile.classpath") {
path(refid: "griffon.compile.classpath")
pathElement(location: destdir)
pathElement(location: srcdir)
}
ant.path(id: "jython.compile.classpath") {
path(refid: "griffon.compile.classpath")
pathElement(location: destdir)
pathElement(location: srcdir)
}
}

defineJythonTestPath = { srcdir, destdir ->
ant.path(id: "jython.test.classpath") {
path(refid: "jython.compile.classpath")
pathElement(location: destdir)
pathElement(location: srcdir)
}
ant.path(id: "jython.test.classpath") {
path(refid: "jython.compile.classpath")
pathElement(location: destdir)
pathElement(location: srcdir)
}
}

compileJythonFiles = { jythonsrcdir, classesDirPath ->
Expand Down
18 changes: 9 additions & 9 deletions test/cli/CreateJythonClassTests.groovy
Expand Up @@ -4,14 +4,14 @@ import griffon.test.AbstractCliTestCase
* Test case for the "create-jython-class" Griffon command.
*/
class CreateJythonClassTests extends AbstractCliTestCase {
void testDefault() {
execute(["create-jython-class griffonjython.Test"])

assertEquals 0, waitForProcess()
verifyHeader()

// Make sure that the script was found.
assertFalse "CreateJythonClass script not found.", output.contains("Script not found:")
void testDefault() {
execute(["create-jython-class griffonjython.Test"])
assertEquals 0, waitForProcess()
verifyHeader()
// Make sure that the script was found.
assertFalse "CreateJythonClass script not found.", output.contains("Script not found:")

def newJythonClassPath = 'src/jython/griffonjython/Test.py'
def newJythonClassFile = new File(newJythonClassPath)
Expand All @@ -20,5 +20,5 @@ class CreateJythonClassTests extends AbstractCliTestCase {
}
newJythonClassFile.delete()
(new File('src/jython/griffonjython')).delete()
}
}
}
16 changes: 8 additions & 8 deletions test/cli/CreateJythonScriptTests.groovy
Expand Up @@ -4,20 +4,20 @@ import griffon.test.AbstractCliTestCase
* Test case for the "create-jython-script" Griffon command.
*/
class CreateJythonScriptTests extends AbstractCliTestCase {
void testDefault() {
execute(["create-jython-script TestScript"])
void testDefault() {
execute(["create-jython-script TestScript"])

assertEquals 0, waitForProcess()
verifyHeader()
assertEquals 0, waitForProcess()
verifyHeader()

// Make sure that the script was found.
assertFalse "CreateJythonScript script not found.", output.contains("Script not found:")
// Make sure that the script was found.
assertFalse "CreateJythonScript script not found.", output.contains("Script not found:")

def newJythonScriptPath = 'griffon-app/resources/TestScript.py'
def newJythonScriptPath = 'griffon-app/resources/jython/TestScript.py'
def newJythonScriptFile = new File(newJythonScriptPath)
if (!newJythonScriptFile.exists()) {
fail "Expected new Jython script ${newJythonScriptPath}"
}
newJythonScriptFile.delete()
}
}
}
2 changes: 1 addition & 1 deletion test/cli/JythonReplTests.groovy
Expand Up @@ -5,7 +5,7 @@ import griffon.test.AbstractCliTestCase
*/
class JythonReplTests extends AbstractCliTestCase {
void testDefault() {
execute([ "jython-repl" ])
execute(["jython-repl"])

assertEquals 0, waitForProcess()
verifyHeader()
Expand Down

0 comments on commit 9f9f757

Please sign in to comment.