Skip to content

Commit

Permalink
Merge branch '3.1.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher committed Mar 1, 2016
2 parents ee61ecc + 176f68c commit 57df0a1
Show file tree
Hide file tree
Showing 82 changed files with 2,543 additions and 1,605 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ env:
- secure: M2WGEzaA4K64HCuNaXbEsg9aKg9Uo5VJOUBSiNmBQQfracqDWoPW6BlC+uD8dqBkFG4z3L4rJWnPoUNDZrqIUmInNLXGQrlkmfHTrAvCs6V+Jj4ilIRfc/bZnasoTmLxT4PPFZGCLcRJ3QwAJ+36EOZPDcXPXpN0hw4hB1hOx9Q=
- secure: Frvf9gLJ/pfy3SWMm9LXdprO/snMFfDO9pTd1bl2GN3QBmkF40G20NzoFI6jbYeyg+gwJQmnC6NVi/KDAkJ/EBO05Xk/qMKwWWsASgdDzdnUNTynFPH0zcnv64d6qZAaLWeH/gWQPZ+99zmbVzFqSNDggEo+cPBm9QjqJ608Yx4=
- secure: JM8mzEz6+UtRnG68vbitVoPzcrSHbEIa0z7Nfhu3RKMDOmQgfGNIF+ZDZPAa/tYpNBTJWKjeIJc8opCfd1p1+s6ISc7B29ymulQ3ztwFWcetunrSmxl8H96aqzjc+82DO6huj4Tzi0u2MADnh9wVm+A1+tcqLjpaLGmskMlvdbw=
- secure: ICWgIGwHFH37nlY9k094qnnKy0tW2XDSOtGsvHb65AxsPsXB1zqj7Qd76Fboo1xFGQGpg+S6AHekY6Ch1prNOpkpPHw35UaQzaRqUxFUhfZYiD0rlmvzKrvKTesrFLy4LJwrTzGCQrViYgqfHvCeQ3r53wWff6nu8uFmMOPmGNY=
script: ./travis-build.sh
install: /bin/true
after_failure: ./travis-after-failure.sh
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ ext {
commonsCollectionsVersion = "3.2.1"
commonsIOVersion = "2.2"
commonsLangVersion = "2.6"
datastoreVersion = "5.0.0.RELEASE"
datastoreVersion = "5.0.2.RELEASE"
gantVersion = "1.9.6"
gdocEngineVersion = "1.0.1"
groovyVersion = System.getenv('CI_GROOVY_VERSION') ?: "2.4.5"
groovyVersion = System.getenv('CI_GROOVY_VERSION') ?: "2.4.6"
ivyVersion = "2.3.0"
jansiVersion = "1.11"
jlineVersion = "2.12"
Expand All @@ -44,7 +44,7 @@ ext {
reactorVersion = '2.0.6.RELEASE'

spockVersion = '1.0-groovy-2.4'
springBootVersion = "1.3.1.RELEASE"
springBootVersion = "1.3.2.RELEASE"
springLoadedVersion = "1.2.5.RELEASE"
springLoadedCommonOptions = "-Xverify:none -Dspringloaded.synchronize=true -Djdk.reflect.allowGetCallerClass=true"
springVersion = "4.2.4.RELEASE"
Expand Down
18 changes: 10 additions & 8 deletions grails-bom/plugins.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
hibernate=4.3.10.7
hibernate4=5.0.0
mongodb=5.0.0
cassandra=5.0.0
neo4j=5.0.0
hibernate3=5.0.2
hibernate4=5.0.2
hibernate5=5.0.2
mongodb=5.0.2
cassandra=5.0.2
neo4j=5.0.2
cache=3.0.2
asset-pipeline=3.0.15
scaffolding=3.2.0
fields=2.1.1
scaffolding=3.2.1
fields=2.1.2
geb=1.0.1
views-json=1.0.0
views-markup=1.0.0
views-json=1.0.3
views-markup=1.0.3
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ trait ModelBuilder {

@Override
Map<String, Object> asMap() {
[ className: className, fullName: fullName, propertyName: propertyName, modelName: propertyName, packageName: packageName, packagePath: packagePath, simpleName: simpleName, lowerCaseName: lowerCaseName]
(Map<String,Object>) [ className: className, fullName: fullName, propertyName: propertyName, modelName: propertyName, packageName: packageName, packagePath: packagePath, simpleName: simpleName, lowerCaseName: lowerCaseName]
}
}

Expand Down
59 changes: 57 additions & 2 deletions grails-bootstrap/src/main/groovy/grails/io/IOUtils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,32 @@ class IOUtils extends SpringIOUtils {
return new URL("$rootPath/")
}
throw new IllegalStateException("Root classpath resource not found! Check your disk permissions")
}


/**
* This method differs from {@link #findRootResource(java.lang.Class)} in that it will find the root URL where to load resources defined in src/main/resources
*
* At development time this with be build/main/resources, but in production it will be relative to the class.
*
* @param targetClass
* @param path
* @return
*/
static URL findRootResourcesURL(Class targetClass) {
def pathToClassFile = '/' + targetClass.name.replace(".", "/") + ".class"
def classRes = targetClass.getResource(pathToClassFile)
if(classRes) {
String rootPath = classRes.toString() - pathToClassFile
if(rootPath.endsWith(BuildSettings.BUILD_CLASSES_PATH)) {
rootPath = rootPath.replace('/build/classes/', '/build/resources/')
}
else {
rootPath = "$rootPath/"
}
return new URL(rootPath)
}
return null
}

/**
Expand All @@ -180,6 +205,7 @@ class IOUtils extends SpringIOUtils {
}
/**
* Finds a URL within a JAR relative (from the root) to the given class
*
* @param targetClass
* @param path
* @return
Expand All @@ -197,6 +223,7 @@ class IOUtils extends SpringIOUtils {
return null
}


@Memoized
public static File findApplicationDirectoryFile() {
def directory = findApplicationDirectory()
Expand All @@ -210,6 +237,32 @@ class IOUtils extends SpringIOUtils {
return null
}

/**
* Finds the application directory for the given class
*
* @param targetClass The target class
* @return The application directory or null if it can't be found
*/
public static File findApplicationDirectoryFile(Class targetClass) {

def rootResource = findRootResource(targetClass)
if(rootResource != null) {

try {
def rootFile = new UrlResource(rootResource).file.canonicalFile
def rootPath = rootFile.path
def buildClassespath = BuildSettings.BUILD_CLASSES_PATH.replace('/', File.separator)
if(rootPath.contains(buildClassespath)) {
return new File(rootPath - buildClassespath)

}
} catch (FileNotFoundException fnfe) {
return null
}
}
return null
}

@Memoized
public static String findApplicationDirectory() {
if(applicationDirectory) {
Expand Down Expand Up @@ -241,8 +294,10 @@ class IOUtils extends SpringIOUtils {
if(classResource) {
def file = new UrlResource(classResource).getFile()
def path = file.canonicalPath
if(path.contains(BuildSettings.BUILD_CLASSES_PATH)) {
location = path.substring(0, path.indexOf(BuildSettings.BUILD_CLASSES_PATH) - 1)

def buildClassespath = BuildSettings.BUILD_CLASSES_PATH.replace('/', File.separator)
if(path.contains(buildClassespath)) {
location = path.substring(0, path.indexOf(buildClassespath) - 1)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,11 @@ class BuildSettings {
*/
public static final String BUILD_CLASSES_PATH = "build/classes/main"

/**
* The path to the build resources directory
*/
public static final String BUILD_RESOURCES_PATH = "build/resources/main"

public static final File SETTINGS_FILE = new File("${System.getProperty('user.home')}/.grails/settings.groovy")

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,11 @@ public static boolean isWarDeployed() {
if(loadedLocation != null && loadedLocation.getPath().contains("/WEB-INF/classes")) {
return true;
}
// Workaround for weblogic who repacks files from 'classes' into a new jar under lib/
if (loadedLocation != null && loadedLocation.getPath().contains("_wl_cls_gen.jar!/")) {
return true;
}
return false;

}

/**
Expand Down
5 changes: 5 additions & 0 deletions grails-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ dependencies {
compile("org.springframework:spring-context:${springVersion}") {
exclude group: 'commons-logging', module:'commons-logging'
}
testCompile("org.springframework:spring-jdbc:${springVersion}") {
exclude group: 'commons-logging', module:'commons-logging'
}
testRuntime 'com.h2database:h2:1.3.176'

provided("org.springframework:spring-test:${springVersion}") {
exclude group: 'commons-logging', module:'commons-logging'
}
Expand Down
88 changes: 50 additions & 38 deletions grails-core/src/main/groovy/grails/boot/GrailsApp.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.grails.compiler.injection.GrailsAwareInjectionOperation
import org.grails.core.util.BeanCreationProfilingPostProcessor
import org.grails.io.watch.DirectoryWatcher
import org.grails.io.watch.FileExtensionFileChangeListener
import org.grails.plugins.BinaryGrailsPlugin
import org.grails.plugins.support.WatchPattern
import org.grails.spring.beans.factory.OptimizedAutowireCapableBeanFactory
import org.springframework.beans.factory.support.DefaultListableBeanFactory
Expand Down Expand Up @@ -119,57 +120,65 @@ class GrailsApp extends SpringApplication {
@Override
void onNew(File file, List<String> extensions) {
changedFiles << file.canonicalFile
// For some bizarro reason Windows fires onNew events even for files that have
// just been modified and not created
if(System.getProperty("os.name").toLowerCase().indexOf("windows") != -1) {
return
}
newFiles << file.canonicalFile
}
})

def pluginManager = applicationContext.getBean(GrailsPluginManager)
def pluginManagerListener = createPluginManagerListener(applicationContext)
directoryWatcher.addListener(pluginManagerListener)

File baseDir = new File(location).canonicalFile

String baseDirPath = baseDir.canonicalPath
List<File> watchBaseDirectories = [baseDir]
def parentDir = baseDir.parentFile
File settingsFile = new File(parentDir, "settings.gradle")

if(settingsFile.exists()) {
def cc = new CompilerConfiguration()
cc.scriptBaseClass = SettingsFile.name
def binding = new Binding()
def shell = new GroovyShell(Thread.currentThread().contextClassLoader, binding, cc)
try {
shell.evaluate(settingsFile)
} catch (Throwable e) {
// ignore
}
def projectPaths = binding.getVariables().get('projectPaths')
if(projectPaths) {
for(path in projectPaths) {
if(path) {

def pathStr = path.toString()
if(pathStr.startsWith(':')) {
pathStr = pathStr.substring(1)
}
watchBaseDirectories << new File(parentDir, pathStr)
}
for(GrailsPlugin plugin in pluginManager.allPlugins) {
if(plugin instanceof BinaryGrailsPlugin) {
BinaryGrailsPlugin binaryGrailsPlugin = (BinaryGrailsPlugin)plugin
def pluginDirectory = binaryGrailsPlugin.projectDirectory
if(pluginDirectory != null) {
watchBaseDirectories << pluginDirectory
}
}
}

def locationLength = location.length() + 1
def pluginManager = applicationContext.getBean(GrailsPluginManager)

for(GrailsPlugin plugin in pluginManager.allPlugins) {
for(WatchPattern wp in plugin.watchedResourcePatterns) {
for(watchBase in watchBaseDirectories) {
if(wp.file) {
def resolvedPath = new File(watchBase, wp.file.path.substring(locationLength))
directoryWatcher.addWatchFile(resolvedPath)
}
else if(wp.directory && wp.extension) {
def watchedResourcePatterns = plugin.getWatchedResourcePatterns()
if(watchedResourcePatterns != null) {

for(WatchPattern wp in new ArrayList<WatchPattern>(watchedResourcePatterns)) {
boolean first = true
for(watchBase in watchBaseDirectories) {
if(!first) {
if(wp.file != null) {
String relativePath = wp.file.canonicalPath - baseDirPath
File watchFile = new File(watchBase, relativePath)
// the base project will already been in the list of watch patterns, but we add any subprojects here
plugin.watchedResourcePatterns.add(new WatchPattern(file: watchFile, extension: wp.extension))
}
else if(wp.directory != null) {
String relativePath = wp.directory.canonicalPath - baseDirPath
File watchDir = new File(watchBase, relativePath)
// the base project will already been in the list of watch patterns, but we add any subprojects here
plugin.watchedResourcePatterns.add(new WatchPattern(directory: watchDir, extension: wp.extension))
}
}
first = false
if(wp.file) {
def resolvedPath = new File(watchBase, wp.file.path.substring(locationLength))
directoryWatcher.addWatchFile(resolvedPath)
}
else if(wp.directory && wp.extension) {

def resolvedPath = new File(watchBase, wp.directory.path.substring(locationLength))
directoryWatcher.addWatchDirectory(resolvedPath, wp.extension)
def resolvedPath = new File(watchBase, wp.directory.path.substring(locationLength))
directoryWatcher.addWatchDirectory(resolvedPath, wp.extension)
}
}
}
}
Expand Down Expand Up @@ -204,7 +213,8 @@ class GrailsApp extends SpringApplication {
def changedFile = uniqueChangedFiles[0]
changedFile = changedFile.canonicalFile
// Groovy files within the 'conf' directory are not compiled
if(changedFile.path.contains('/grails-app/conf/')) {
String confPath = "${File.pathSeparator}grails-app${File.pathSeparator}conf${File.pathSeparator}"
if(changedFile.path.contains(confPath)) {
pluginManager.informOfFileChange(changedFile)
}
else {
Expand Down Expand Up @@ -245,8 +255,10 @@ class GrailsApp extends SpringApplication {
protected void recompile(File changedFile, CompilerConfiguration compilerConfig, String location) {
File appDir = null
def changedPath = changedFile.path
if (changedPath.contains('/grails-app')) {
appDir = new File(changedPath.substring(0, changedPath.indexOf('/grails-app')))

String grailsAppDir = "${File.separator}grails-app"
if (changedPath.contains(grailsAppDir)) {
appDir = new File(changedPath.substring(0, changedPath.indexOf(grailsAppDir)))
}
def baseFileLocation = appDir?.absolutePath ?: location
compilerConfig.setTargetDirectory(new File(baseFileLocation, BuildSettings.BUILD_CLASSES_PATH))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,12 @@ class GrailsApplicationPostProcessor implements BeanDefinitionRegistryPostProces
protected void performGrailsInitializationSequence() {
pluginManager.doArtefactConfiguration()
grailsApplication.initialise()
// register plugin provided classes first, this gives the oppurtunity
// for application classes to override those provided by a plugin
pluginManager.registerProvidedArtefacts(grailsApplication)
for(cls in classes) {
grailsApplication.addArtefact(cls)
}
pluginManager.registerProvidedArtefacts(grailsApplication)
}

protected void loadApplicationConfig() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class GrailsAutoConfiguration implements GrailsApplicationClass, ApplicationCont
*/
Collection<Package> packages() {
def thisPackage = getClass().package
thisPackage ? [ thisPackage ] : []
thisPackage ? [ thisPackage ] : new ArrayList<Package>()
}

/**
Expand Down
2 changes: 1 addition & 1 deletion grails-core/src/main/groovy/grails/plugins/Plugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,6 @@ abstract class Plugin implements GrailsApplicationLifeCycle, GrailsApplicationAw
def bb = new BeanBuilder(null, grailsApplication.classLoader)
bb.beans beanDefinitions
bb.registerBeans((BeanDefinitionRegistry)applicationContext)
new MapBasedSmartPropertyOverrideConfigurer(grailsApplication).postProcessBeanFactory(((ConfigurableApplicationContext)applicationContext).beanFactory)
new MapBasedSmartPropertyOverrideConfigurer(grailsApplication: grailsApplication).postProcessBeanFactory(((ConfigurableApplicationContext)applicationContext).beanFactory)
}
}
Loading

0 comments on commit 57df0a1

Please sign in to comment.