Added option allowSplitPackages=true/false

This commit is contained in:
Andy Clement
2015-07-12 16:07:28 -07:00
parent f887a6a0bf
commit 51cce3c0d7
2 changed files with 23 additions and 9 deletions

View File

@@ -71,6 +71,15 @@ public class GlobalConfiguration {
*/
public static boolean explainMode = false;
/**
* Once a type is found to be reloadable or not (based on whether it is accessible as a .class file on the disk
* rather than packaged in a jar), that decision is remembered and all types from the same package are treated in
* the same way without repeating the costly lookup. This option enables that behaviour to be turned OFF and then
* you can have some files in a package that are in a jar and are not reloadable and some types that are in the same
* package but on disk that will be reloadable.
*/
public static boolean allowSplitPackages = false;
/**
* Global control for runtime logging
*/
@@ -105,9 +114,8 @@ public class GlobalConfiguration {
public final static boolean logNonInterceptedReflectiveCalls = false;
/**
* Holds a list of fully qualified paths to jars that should be 'watched' for changes. Types
* within these jars will be made reloadable. Set via option 'watchJars' which
* takes a colon separated list of jars.
* Holds a list of fully qualified paths to jars that should be 'watched' for changes. Types within these jars will
* be made reloadable. Set via option 'watchJars' which takes a colon separated list of jars.
*/
public static String[] jarsToWatch = null;
@@ -227,6 +235,9 @@ public class GlobalConfiguration {
specifiedCaching = true;
isCaching = kv.substring(equals + 1).equalsIgnoreCase("true");
}
else if (key.equals("allowSplitPackages")) {
allowSplitPackages = kv.substring(equals + 1).equalsIgnoreCase("true");
}
else if (key.equals("debugplugins")) {
debugPlugins = true;
}
@@ -349,12 +360,14 @@ public class GlobalConfiguration {
try {
String userhome = System.getProperty("user.home");
if (userhome != null) {
cacheDir = new StringBuilder(userhome).append(File.separator).append(".grails").toString();
cacheDir = new StringBuilder(userhome).append(File.separator).append(
".grails").toString();
new File(cacheDir).mkdir();
}
}
catch (Throwable t) {
System.err.println("looks like user.home is not set, or cannot write to it: cannot create cache.");
System.err.println(
"looks like user.home is not set, or cannot write to it: cannot create cache.");
t.printStackTrace(System.err);
}
}
@@ -400,8 +413,9 @@ public class GlobalConfiguration {
}
else {
if (!cacheDirFile.isDirectory()) {
System.err.println("Caching deactivated: unable to use specified cache area, it is not a directory: "
+ cacheDirFile);
System.err.println(
"Caching deactivated: unable to use specified cache area, it is not a directory: "
+ cacheDirFile);
isCaching = false;
}
}

View File

@@ -655,7 +655,7 @@ public class TypeRegistry {
}
int lastSlashPos = slashedName.lastIndexOf('/');
String packageName = lastSlashPos == -1 ? null : slashedName.substring(0, lastSlashPos);
if (packageName != null) {
if (packageName != null && !GlobalConfiguration.allowSplitPackages) {
// is it something we already know about?
for (String foundPackageName : packagesFound) {
if (packageName.equals(foundPackageName)) {
@@ -714,7 +714,7 @@ public class TypeRegistry {
}
}
}
if (packageName != null) {
if (packageName != null && !GlobalConfiguration.allowSplitPackages) {
if (reloadable) {
packagesFound.add(packageName);
}