2014-04-29 56 views
0

我想讓我的Grails應用程序(myapp)使用我正在開發的名爲grails-myapp-auth的插件。具有連字符名稱的Grails插件的命名約定

我使用標準的Grails任務創建插件:

grails create-plugin myapp-auth 

然後就開始發展了。

myapp的`BuildConfig.groovy我指定的插件通過本地位置:

grails.plugin.location.myapp-auth = '../../../myapp-auth' 

但是這給了我:

| Error WARNING: Inline plugins for [myapp] cannot be read due to error: startup failed: 
/home/myuser/sandbox/eclipse/workspace/myapp/myapp/grails-app/conf/BuildConfig.groovy: 4: 
(grails.plugin.location.myapp - auth) is a binary expression, but it should be a variable expression at line: 4 column: 39. File: /home/myuser/sandbox/eclipse/workspace/myapp/myapp/grails-app/conf/BuildConfig.groovy @ line 4, column 39. 
    grails.plugin.location.myapp-auth = '../../../myapp-auth' 

所以看起來Grails是試圖評估配置爲二進制表達式,如下所示:

<Some Value>     - <Another Value> = <Yet Another Value> 
grails.plugin.location.myapp - auth   = '../../../myapp-auth' 

我該怎麼做 解決這個問題。如果可能的話,我想保留名爲myapp-auth的插件,但如果絕對需要,可以在我的鼻子上放一個衣服針,並將其縮短到只有myappauth

回答

2

使用單引號:

grails.plugin.location.'myapp-auth' = '../../../myapp-auth' 
+3

是正確的。細化一下,在Groovy中,如果你有類似plugin.location.myapp-auth ='../../../myapp-auth'的連字符,則連字符被解釋爲減法運算符。您正在從「plugin.location.myapp」的值中減去「auth」的值。我希望這是有道理的。 –

+1

感謝@JeffScottBrown的解釋。 :) – dmahapatro