Skip to content

Commit

Permalink
Merge branch '3.0.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher committed Jul 1, 2015
2 parents a304664 + 4f3b8be commit 529f080
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
13 changes: 11 additions & 2 deletions grails-core/src/main/groovy/grails/boot/GrailsApp.groovy
Expand Up @@ -40,6 +40,9 @@ class GrailsApp extends SpringApplication {

private final Log log = LogFactory.getLog(getClass())

private static boolean developmentModeActive = false
private static DirectoryWatcher directoryWatcher

@Override
ConfigurableApplicationContext run(String... args) {
def applicationContext = super.run(args)
Expand Down Expand Up @@ -82,7 +85,7 @@ class GrailsApp extends SpringApplication {
def location = environment.getReloadLocation()

if(location) {
DirectoryWatcher directoryWatcher = new DirectoryWatcher()
directoryWatcher = new DirectoryWatcher()
configureDirectoryWatcher(directoryWatcher, location)
Queue<File> changedFiles = new ConcurrentLinkedQueue<>()
Queue<File> newFiles = new ConcurrentLinkedQueue<>()
Expand Down Expand Up @@ -146,11 +149,12 @@ class GrailsApp extends SpringApplication {
}


developmentModeActive = true
Thread.start {
CompilerConfiguration compilerConfig = new CompilerConfiguration()
compilerConfig.setTargetDirectory(new File(location, "build/classes/main"))

while(true) {
while(developmentModeActive) {
// Workaround for some IDE / OS combos - 2 events (new + update) for the same file
def uniqueChangedFiles = changedFiles as Set
changedFiles.clear()
Expand Down Expand Up @@ -192,6 +196,11 @@ class GrailsApp extends SpringApplication {

}

static void setDevelopmentModeActive(boolean active) {
developmentModeActive = active
directoryWatcher.active = active
}

protected void recompile(File changedFile, CompilerConfiguration compilerConfig, String location) {
File appDir = null
def changedPath = changedFile.path
Expand Down
@@ -1,5 +1,6 @@
package grails.boot.config

import grails.boot.GrailsApp
import grails.config.Settings
import grails.core.DefaultGrailsApplication
import grails.core.GrailsApplication
Expand Down Expand Up @@ -238,8 +239,14 @@ class GrailsApplicationPostProcessor implements BeanDefinitionRegistryPostProces
ShutdownOperations.runOperations()
Holders.clear()
if(reloadingEnabled) {
GrailsSpringLoadedPlugin.unregister()
try {
GrailsSpringLoadedPlugin.unregister()
} catch (Throwable e) {
// ignore
}
}

GrailsApp.setDevelopmentModeActive(false)
}
}

Expand Down
Expand Up @@ -10,6 +10,7 @@
import org.springsource.loaded.agent.*;

import java.beans.Introspector;
import java.util.ArrayList;
import java.util.List;

/**
Expand Down Expand Up @@ -43,7 +44,7 @@ public void reloadEvent(String typename, Class<?> clazz, String encodedTimestamp

private static boolean unregistered = false;
public static void unregister() {
List<Plugin> globalPlugins = SpringLoadedPreProcessor.getGlobalPlugins();
List<Plugin> globalPlugins = new ArrayList<Plugin>(SpringLoadedPreProcessor.getGlobalPlugins());
for (Plugin globalPlugin : globalPlugins) {
Plugins.unregisterGlobalPlugin(globalPlugin);
}
Expand Down
Expand Up @@ -106,8 +106,13 @@ abstract class GroovyScriptCommand extends Script implements ProfileCommand, Pro
* @return The flag information, or null if it isn't set by the user
*/
def flag(String name) {
def value = commandLine?.undeclaredOptions?.get(name)
return value ?: null
if(commandLine.hasOption(name)) {
return commandLine.optionValue(name)
}
else {
def value = commandLine?.undeclaredOptions?.get(name)
return value ?: null
}
}

/**
Expand Down

0 comments on commit 529f080

Please sign in to comment.