Skip to content

Commit c37267b

Browse files
committed
No longer throw an exception if both plugin yml and groovy exist at runtime because it should be prevented in GrailsPluginGradlePlugin
1 parent ee2bfda commit c37267b

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

grails-core/src/main/groovy/org/grails/plugins/AbstractGrailsPlugin.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,14 @@ public boolean isEnabled(String[] profiles) {
125125
}
126126

127127
protected Resource readPluginConfiguration(Class<?> pluginClass) {
128-
Resource ymlUrlResource = getConfigurationResource(pluginClass, PLUGIN_YML_PATH);
129-
Resource groovyUrlResource = getConfigurationResource(pluginClass, PLUGIN_GROOVY_PATH);
128+
Resource ymlResource = getConfigurationResource(pluginClass, PLUGIN_YML_PATH);
129+
Resource groovyResource = getConfigurationResource(pluginClass, PLUGIN_GROOVY_PATH);
130130

131-
Boolean groovyUrlResourceExists = groovyUrlResource != null && groovyUrlResource.exists();
132-
133-
if(ymlUrlResource != null && ymlUrlResource.exists()) {
134-
if (groovyUrlResourceExists) {
135-
throw new RuntimeException("A plugin may define a plugin.yml or a plugin.groovy, but not both");
136-
}
137-
return ymlUrlResource;
131+
if(ymlResource != null && ymlResource.exists()) {
132+
return ymlResource;
138133
}
139-
if(groovyUrlResourceExists) {
140-
return groovyUrlResource;
134+
if(groovyResource != null && groovyResource.exists()) {
135+
return groovyResource;
141136
}
142137
return null;
143138
}

grails-core/src/test/groovy/org/codehaus/groovy/grails/plugins/BinaryPluginSpec.groovy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,16 @@ class BinaryPluginSpec extends Specification {
5151
cssResource == null
5252
}
5353

54-
def "Test plugin with both plugin.yml and plugin.groovy throws exception"() {
54+
//This should never occur because the GrailsPluginGradlePlugin.groovy should catch it
55+
def "Test plugin with both plugin.yml and plugin.groovy, yml is used"() {
5556
when:
5657
def descriptor = new BinaryGrailsPluginDescriptor(new ByteArrayResource(testBinary.getBytes('UTF-8')), ['org.codehaus.groovy.grails.plugins.TestBinaryResource'])
5758
MockConfigBinaryGrailsPlugin.YAML_EXISTS = true
5859
MockConfigBinaryGrailsPlugin.GROOVY_EXISTS = true
59-
new MockConfigBinaryGrailsPlugin(descriptor)
60+
def binaryPlugin = new MockConfigBinaryGrailsPlugin(descriptor)
6061

6162
then:
62-
thrown(RuntimeException)
63+
binaryPlugin.propertySource.getProperty('foo') == "bar"
6364
}
6465

6566
def "Test plugin with only plugin.yml"() {

0 commit comments

Comments
 (0)