Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch '2.1.x' into 2.2.x

Conflicts:
	grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/PluginInstallEngine.groovy
  • Loading branch information...
commit cd7aaed0fee598a6d8e3214565736525bc862afc 2 parents bd22ee3 + cc9c50f
@graemerocher graemerocher authored
View
56 ...s-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/PluginInstallEngine.groovy
@@ -221,12 +221,18 @@ class PluginInstallEngine {
* avoid errors about not being able to find the src folders AFTER
* the plugin has been uninstalled.
*/
- if (!inlinePlugins.find { it.key.endsWith(name) } ) {
- installPluginZipInternal name, version, zipFile, false, false, true
- } else {
- // Remove the plugin to prevent duplicate class compile errors with inline version.
- uninstallPlugin name, version
- }
+ if(!inlinePlugins.find {
+ def pluginName = it.key.toString()
+ if (pluginName.contains(':')) {
+ pluginName = pluginName.split(':')[-1]
+ }
+ return pluginName.equals(name)
+ } ) {
+ installPluginZipInternal name, version, zipFile, false, false, true
+ } else {
+ // Remove the plugin to prevent duplicate class compile errors with inline version.
+ uninstallPlugin name, version
+ }
}
/**
@@ -410,22 +416,28 @@ class PluginInstallEngine {
*/
protected boolean checkExistingPluginInstall(String name, version, File pluginZip, boolean isResolve = true) {
Resource currentInstall = pluginSettings.getPluginDirForName(name)
- def inlinePlugins = settings.config.grails.plugin.location
-
- if (!currentInstall?.exists()) {
- return false
- }
-
- /*
- * If the plugin to be installed is currently configured to be inline,
- * do not install it. This is because we want to use the inline over
- * the modified dependency artifact. The comparison to find the inline
- * plugin uses "endsWith", as inline plugins can be declared with a full
- * vector in settings.groovy (i.e. 'com.mycompany:my-plugin")
- */
- if (inlinePlugins.find { it.key.endsWith(name) } ) {
- return true
- }
+ def inlinePlugins = settings.config.grails.plugin.location
+
+ if (!currentInstall?.exists()) {
+ return false
+ }
+
+ /*
+ * If the plugin to be installed is currently configured to be inline,
+ * do not install it. This is because we want to use the inline over
+ * the modified dependency artifact. The comparison to find the inline
+ * plugin uses "endsWith", as inline plugins can be declared with a full
+ * vector in settings.groovy (i.e. 'com.mycompany:my-plugin")
+ */
+ if( inlinePlugins.find {
+ def pluginName = it.key.toString()
+ if (pluginName.contains(':')) {
+ pluginName = pluginName.split(':')[-1]
+ }
+ return pluginName.equals(name)
+ } ) {
+ return true
+ }
PluginBuildSettings pluginSettings = pluginSettings
def pluginDir = currentInstall.file.canonicalFile
View
17 grails-core/src/main/groovy/org/codehaus/groovy/grails/compiler/DirectoryWatcher.java
@@ -40,6 +40,7 @@
private List<FileChangeListener> listeners = new ArrayList<FileChangeListener>();
private Map<File, Long> lastModifiedMap = new ConcurrentHashMap<File, Long>();
+ private Map<File, Collection<String>> directoryToExtensionsMap = new ConcurrentHashMap<File, Collection<String>>();
private Map<File, Long> directoryWatch = new ConcurrentHashMap<File, Long>();
private boolean active = true;
private long sleepTime = 3000;
@@ -91,9 +92,20 @@ public void addWatchFile(File fileToWatch) {
* @param fileExtensions The extensions
*/
public void addWatchDirectory(File dir, List<String> fileExtensions) {
+ trackDirectoryExtensions(dir, fileExtensions);
cacheFilesForDirectory(dir, fileExtensions, false);
}
+ protected void trackDirectoryExtensions(File dir, List<String> fileExtensions) {
+ Collection<String> existingExtensions = directoryToExtensionsMap.get(dir);
+ if(existingExtensions == null) {
+ directoryToExtensionsMap.put(dir, fileExtensions);
+ }
+ else {
+ existingExtensions.addAll(fileExtensions);
+ }
+ }
+
/**
* Adds a directory to watch for the given file and extensions.
*
@@ -109,6 +121,7 @@ public void addWatchDirectory(File dir, String extension) {
else {
fileExtensions.add(extension);
}
+ trackDirectoryExtensions(dir, fileExtensions);
cacheFilesForDirectory(dir, fileExtensions, false);
}
@@ -168,6 +181,10 @@ private void checkForNewFiles() {
final Long currentTimestamp = directoryWatch.get(directory);
if (currentTimestamp < directory.lastModified()) {
+ Collection<String> extensions = directoryToExtensionsMap.get(directory);
+ if(extensions == null) {
+ extensions = this.extensions;
+ }
cacheFilesForDirectory(directory, extensions, true);
}
}
View
14 ...roovy/org/codehaus/groovy/grails/compiler/injection/DefaultGrailsDomainClassInjector.java
@@ -30,14 +30,7 @@
import org.codehaus.groovy.ast.MethodNode;
import org.codehaus.groovy.ast.Parameter;
import org.codehaus.groovy.ast.PropertyNode;
-import org.codehaus.groovy.ast.expr.ClassExpression;
-import org.codehaus.groovy.ast.expr.ConstantExpression;
-import org.codehaus.groovy.ast.expr.Expression;
-import org.codehaus.groovy.ast.expr.GStringExpression;
-import org.codehaus.groovy.ast.expr.ListExpression;
-import org.codehaus.groovy.ast.expr.MapEntryExpression;
-import org.codehaus.groovy.ast.expr.MapExpression;
-import org.codehaus.groovy.ast.expr.VariableExpression;
+import org.codehaus.groovy.ast.expr.*;
import org.codehaus.groovy.ast.stmt.ReturnStatement;
import org.codehaus.groovy.ast.stmt.Statement;
import org.codehaus.groovy.classgen.GeneratorContext;
@@ -192,9 +185,10 @@ private void injectToStringMethod(ClassNode classNode) {
classNode, "toString", classesWithInjectedToString);
if (!hasToString && !isEnum(classNode)) {
- GStringExpression ge = new GStringExpression(classNode.getName() + " : ${id}");
+ GStringExpression ge = new GStringExpression(classNode.getName() + " : ${id ? id : '(unsaved)'}");
ge.addString(new ConstantExpression(classNode.getName() + " : "));
- ge.addValue(new VariableExpression("id"));
+ VariableExpression idVariable = new VariableExpression("id");
+ ge.addValue(new TernaryExpression(new BooleanExpression(idVariable), idVariable, new ConstantExpression("(unsaved)")));
Statement s = new ReturnStatement(ge);
MethodNode mn = new MethodNode("toString", Modifier.PUBLIC, new ClassNode(String.class), new Parameter[0], new ClassNode[0], s);
classNode.addMethod(mn);
View
3  ...er/src/test/groovy/org/codehaus/groovy/grails/plugins/DomainClassGrailsPluginTests.groovy
@@ -70,6 +70,9 @@ class Parent2 {
void testToString() {
def instance = appCtx.getBean("ChildDomainClass").newInstance()
+
+ assertEquals('Child : (unsaved)', instance.toString())
+
instance.id = 1
assertEquals('Child : 1', instance.toString())
Please sign in to comment.
Something went wrong with that request. Please try again.