Skip to content

Commit a45aaad

Browse files
committed
Gradle - ensure build/resources/main is on the classpath in exploded mode
1 parent d0a9d22 commit a45aaad

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/GrailsPluginGradlePlugin.groovy

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,27 +78,23 @@ class GrailsPluginGradlePlugin extends GrailsGradlePlugin {
7878
*/
7979
@CompileStatic
8080
protected void configureExplodedDirConfiguration(Project project) {
81-
def configurationName = "exploded"
8281

8382
def allConfigurations = project.configurations
8483

85-
def explodedConfig = allConfigurations.create(configurationName)
86-
87-
def parent = allConfigurations.findByName('runtime')
84+
def runtimeConfiguration = allConfigurations.findByName('runtime')
8885
if(Environment.isDevelopmentRun()) {
89-
parent.artifacts.clear()
90-
}
91-
explodedConfig.extendsFrom(parent)
92-
// add the subproject classes as outputs
93-
def allTasks = project.tasks
94-
GroovyCompile groovyCompile = (GroovyCompile) allTasks.findByName('compileGroovy')
86+
def explodedConfig = allConfigurations.create('exploded')
87+
runtimeConfiguration.artifacts.clear()
88+
explodedConfig.extendsFrom(runtimeConfiguration)
89+
// add the subproject classes as outputs
90+
def allTasks = project.tasks
9591

96-
def allArtifacts = project.artifacts
97-
allArtifacts.add(configurationName, new ExplodedDir( groovyCompile.destinationDir, groovyCompile) )
92+
GroovyCompile groovyCompile = (GroovyCompile) allTasks.findByName('compileGroovy')
93+
ProcessResources processResources = (ProcessResources) allTasks.findByName("processResources")
9894

99-
// add the subproject resources as outputs
100-
ProcessResources processResources = (ProcessResources) allTasks.findByName("processResources")
101-
allArtifacts.add(configurationName, new ExplodedDir( processResources.destinationDir, processResources) )
95+
runtimeConfiguration.artifacts.add(new ExplodedDir( groovyCompile.destinationDir, groovyCompile, processResources) )
96+
explodedConfig.artifacts.add(new ExplodedDir( processResources.destinationDir, groovyCompile, processResources) )
97+
}
10298
}
10399

104100
@Override

grails-gradle-plugin/src/main/groovy/org/grails/gradle/plugin/core/PluginDefiner.groovy

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package org.grails.gradle.plugin.core
22

3+
import grails.util.BuildSettings
34
import grails.util.Environment
45
import groovy.transform.CompileStatic
56
import groovy.transform.PackageScope
67
import org.gradle.api.Project
78
import org.gradle.api.artifacts.Dependency
9+
import org.gradle.api.artifacts.ProjectDependency
810

911
/**
1012
* Makes it easier to define Grails plugins and also makes them aware of the development environment so that they can be run inline without creating a JAR
@@ -38,10 +40,14 @@ class PluginDefiner {
3840
else if(argArray[0] instanceof CharSequence) {
3941
String str = argArray[0].toString()
4042

41-
if(str.startsWith(':')) {
43+
if (str.startsWith(':')) {
4244
argArray[0] = "org.grails.plugins$str".toString()
4345
}
4446
}
47+
else if(Environment.isDevelopmentRun()&& (argArray[0] instanceof ProjectDependency)) {
48+
ProjectDependency pd = argArray[0]
49+
project.dependencies.add(name, project.files(new File(pd.dependencyProject.projectDir, BuildSettings.BUILD_RESOURCES_PATH)))
50+
}
4551
project.dependencies.add(name, *argArray )
4652
}
4753
}

0 commit comments

Comments
 (0)