Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:grails/grails-core

  • Loading branch information...
commit a0d4f555b982f1e7f117ee2ff6d4a9925891f0ca 2 parents 61b042a + b4dae55
@graemerocher graemerocher authored
View
2  grails-resources/src/grails/home/bash/grails.bat
@@ -12,4 +12,4 @@ if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.\
-CALL "%DIRNAME%\startGrails.bat" "%DIRNAME%" %*
+CALL "%DIRNAME%\startGrails.bat" %*
View
3  grails-resources/src/grails/home/bash/startGrails.bat
@@ -8,9 +8,6 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-set DIRNAME=%~1
-shift
-
set CLASS=@starter.main.class@
if exist "%USERPROFILE%/.groovy/preinit.bat" call "%USERPROFILE%/.groovy/preinit.bat"
View
2  grails-resources/src/grails/plugin/grails-app/conf/BuildConfig.groovy
@@ -28,7 +28,7 @@ grails.project.dependency.resolution = {
plugins {
build(":tomcat:$grailsVersion",
- ":release:1.0.1") {
+ ":release:2.0.0") {
export = false
}
}
View
17 ...-suite-web/src/test/groovy/org/codehaus/groovy/grails/web/binding/DataBindingTests.groovy
@@ -67,8 +67,25 @@ class Person {
birthDate nullable: true
}
}
+@Entity
+class Pet {
+ String name
+ Map detailMap
+ Person owner
+}
''')
}
+
+ void testBindingMapValue() {
+ def petClass = ga.getDomainClass('databindingtests.Pet')
+ def pet = petClass.newInstance()
+ pet.properties = [name: 'lemur', detailMap: [first: 'one', second: 'two'], owner: [name: 'Jeff'], foo: 'bar', bar: [a: 'a', b: 'b']]
+
+ assert pet.name == 'lemur'
+ assert pet.detailMap.first == 'one'
+ assert pet.detailMap.second == 'two'
+ assert !pet.hasErrors()
+ }
void testBindingNullToANullableDateThatAlreadyHasAValue() {
def c = ga.getControllerClass('databindingtests.TestController').newInstance()
View
36 ...suite-web/src/test/groovy/org/codehaus/groovy/grails/web/pages/OptionalTagBodySpec.groovy
@@ -0,0 +1,36 @@
+package org.codehaus.groovy.grails.web.pages
+
+import grails.test.AbstractGrailsEnvChangingSpec
+
+import spock.lang.Specification
+import grails.test.mixin.TestFor
+import grails.util.Environment;
+import grails.artefact.Artefact
+
+
+@TestFor(CustomTagLib)
+class OptionalTagBodySpec extends AbstractGrailsEnvChangingSpec {
+ def "Test that the existence of a body can be tested with groovy truth"(grailsEnv) {
+ when:
+ changeGrailsEnv(grailsEnv)
+ def content = applyTemplate("<a:myBody />")
+ def content2 = applyTemplate("<a:myBody>Hello</a:myBody>")
+ then:
+ content == 'nobody'
+ content2 == 'Hello'
+ where:
+ grailsEnv << grailsEnvs
+ }
+}
+@Artefact("TagLibrary")
+class CustomTagLib {
+ static namespace = "a"
+
+ def myBody = { attrs, body ->
+ if(body) {
+ out << body()
+ } else {
+ out << 'nobody'
+ }
+ }
+}
View
23 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/binding/GrailsDataBinder.java
@@ -26,6 +26,7 @@
import groovy.lang.MissingMethodException;
import groovy.lang.MissingPropertyException;
+import java.beans.PropertyDescriptor;
import java.beans.PropertyEditor;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -71,6 +72,7 @@
import org.codehaus.groovy.runtime.InvokerHelper;
import org.codehaus.groovy.runtime.MetaClassHelper;
import org.codehaus.groovy.runtime.metaclass.ThreadManagedMetaBeanProperty;
+import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.ConfigurablePropertyAccessor;
@@ -512,14 +514,29 @@ private void filterNestedParameterMaps(MutablePropertyValues mpvs) {
if (JSONObject.NULL.getClass().isInstance(value)) {
mpvs.removePropertyValue(pv);
}
- if (isNotCandidateForBinding(value)) {
+ if (!isCandidateForBinding(pv)) {
mpvs.removePropertyValue(pv);
}
}
}
- private boolean isNotCandidateForBinding(Object value) {
- return value instanceof Map;
+ private boolean isCandidateForBinding(PropertyValue pv) {
+ boolean isCandidate = true;
+ final Object value = pv.getValue();
+ if(value instanceof GrailsParameterMap || value instanceof JSONObject) {
+ isCandidate = false;
+ } else if(value instanceof Map) {
+ isCandidate = false;
+ final String propertyName = pv.getName();
+ final PropertyDescriptor property = BeanUtils.getPropertyDescriptor(getTarget().getClass(), propertyName);
+ if(property != null) {
+ final Class<?> propertyType = property.getPropertyType();
+ if(propertyType.isAssignableFrom(value.getClass())) {
+ isCandidate = true;
+ }
+ }
+ }
+ return isCandidate;
}
private PropertyValues filterPropertyValues(PropertyValues propertyValues, String prefix) {
View
5 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/pages/GroovyPage.java
@@ -47,6 +47,7 @@
import org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException;
import org.codehaus.groovy.grails.web.util.CodecPrintWriter;
import org.codehaus.groovy.grails.web.util.GrailsPrintWriter;
+import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation;
/**
* NOTE: Based on work done by on the GSP standalone project (https://gsp.dev.java.net/)
@@ -154,6 +155,10 @@ public Object doCall(@SuppressWarnings("unused") Object[] args) {
public Object call(Object... args) {
return retval;
}
+
+ public boolean asBoolean() {
+ return DefaultTypeTransformation.castToBoolean(retval);
+ }
}
protected static final Closure<?> EMPTY_BODY_CLOSURE = new ConstantClosure(BLANK_STRING);
View
31 grails-wrapper/src/main/java/org/grails/wrapper/GrailsWrapper.java
@@ -11,7 +11,9 @@
import java.net.URI;
import java.net.URL;
import java.net.URLClassLoader;
+import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.List;
import java.util.ResourceBundle;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -44,6 +46,23 @@ public static void main(final String[] args) throws Exception{
final File grailsHome = new File(installDir, "grails-" + grailsVersion);
System.setProperty("grails.home", grailsHome.getAbsolutePath());
+
+ final List<String> newArgsList = new ArrayList<String>();
+ for(int i = 0; i < args.length; i++) {
+ final String arg = args[0];
+ if("--main".equals(arg) && i < args.length - 1) {
+ // skip --main and the following argument
+ i++;
+ } else if("--conf".equals(arg) && i < args.length - 1) {
+ newArgsList.add(arg);
+ final File groovyStarterConf = new File(grailsHome, "conf/groovy-starter.conf");
+ newArgsList.add(groovyStarterConf.getAbsolutePath());
+ } else {
+ newArgsList.add(arg);
+ }
+ }
+
+ final Object[] newArgsArray = newArgsList.toArray();
final URL[] urls = new URL[2];
urls[0] = new File(grailsHome, "dist/grails-bootstrap-" + grailsVersion + ".jar").toURI().toURL();
File[] groovyJarCandidates = new File(grailsHome, "lib/org.codehaus.groovy/groovy-all/jars/").listFiles(new FilenameFilter() {
@@ -55,16 +74,8 @@ public boolean accept(final File dir, final String name) {
final URLClassLoader urlClassLoader = new URLClassLoader(urls);
final Class<?> loadClass = urlClassLoader.loadClass("org.codehaus.groovy.grails.cli.support.GrailsStarter");
final Method mainMethod = loadClass.getMethod("main", String[].class);
- final String[] args2 = new String[args.length];
- System.arraycopy(args, 0, args2, 0, args.length);
- for(int i = 0; i < args2.length; i++) {
- if("--conf".equals(args2[i]) && (i < (args2.length - 1))) {
- final File groovyStarterConf = new File(grailsHome, "conf/groovy-starter.conf");
- args2[i + 1] = groovyStarterConf.getAbsolutePath();
- break;
- }
- }
- mainMethod.invoke(null, new Object[]{args2});
+
+ mainMethod.invoke(null, new Object[]{newArgsArray});
}
public static void extract(final File zip, final File dest) throws IOException {
Please sign in to comment.
Something went wrong with that request. Please try again.