File tree Expand file tree Collapse file tree 2 files changed +14
-10
lines changed
main/groovy/org/grails/plugins
test/groovy/org/codehaus/groovy/grails/plugins Expand file tree Collapse file tree 2 files changed +14
-10
lines changed Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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" () {
You can’t perform that action at this time.
0 commit comments