Skip to content

Commit 6033883

Browse files
committed
Revert "No longer throw an exception if both plugin yml and groovy exist at runtime because it should be prevented in GrailsPluginGradlePlugin"
This reverts commit c37267b.
1 parent 574e3a3 commit 6033883

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

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

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

125125
protected Resource readPluginConfiguration(Class<?> pluginClass) {
126-
Resource ymlResource = getConfigurationResource(pluginClass, PLUGIN_YML_PATH);
127-
Resource groovyResource = getConfigurationResource(pluginClass, PLUGIN_GROOVY_PATH);
126+
Resource ymlUrlResource = getConfigurationResource(pluginClass, PLUGIN_YML_PATH);
127+
Resource groovyUrlResource = getConfigurationResource(pluginClass, PLUGIN_GROOVY_PATH);
128128

129-
if(ymlResource != null && ymlResource.exists()) {
130-
return ymlResource;
129+
Boolean groovyUrlResourceExists = groovyUrlResource != null && groovyUrlResource.exists();
130+
131+
if(ymlUrlResource != null && ymlUrlResource.exists()) {
132+
if (groovyUrlResourceExists) {
133+
throw new RuntimeException("A plugin may define a plugin.yml or a plugin.groovy, but not both");
134+
}
135+
return ymlUrlResource;
131136
}
132-
if(groovyResource != null && groovyResource.exists()) {
133-
return groovyResource;
137+
if(groovyUrlResourceExists) {
138+
return groovyUrlResource;
134139
}
135140
return null;
136141
}

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

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

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"() {
54+
def "Test plugin with both plugin.yml and plugin.groovy throws exception"() {
5655
when:
5756
def descriptor = new BinaryGrailsPluginDescriptor(new ByteArrayResource(testBinary.getBytes('UTF-8')), ['org.codehaus.groovy.grails.plugins.TestBinaryResource'])
5857
MockConfigBinaryGrailsPlugin.YAML_EXISTS = true
5958
MockConfigBinaryGrailsPlugin.GROOVY_EXISTS = true
60-
def binaryPlugin = new MockConfigBinaryGrailsPlugin(descriptor)
59+
new MockConfigBinaryGrailsPlugin(descriptor)
6160

6261
then:
63-
binaryPlugin.propertySource.getProperty('foo') == "bar"
62+
thrown(RuntimeException)
6463
}
6564

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

0 commit comments

Comments
 (0)