在Grails 2.3.x中运行本地插件?

时间:2014-02-16 10:58:22

标签: spring-mvc grails groovy grails-2.0

我有一个Grails插件,我想用Grails 2.3.x在本地运行。我所做的是打包插件文件夹并将其放入:

/lib/myPlugin-1.0.zip

现在我可以使用

compile ":myPlugin:1.0"

在我的BuildConfig.groovy文件的插件部分。

它在版本2.3之前的Grails中工作,但在2.3.x中它通过以下错误:

Resolve error obtaining dependencies: Could not find artifact org.grails.plugins:prerender:zip:1.0.4 in grailsCentral (http://repo.grails.org/grails/plugins)
org.eclipse.aether.resolution.DependencyResolutionException: Could not find artifact org.grails.plugins:prerender:zip:1.0.4 in grailsCentral (http://repo.grails.org/grails/plugins)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies(DefaultRepositorySystem.java:384)
    at org.codehaus.groovy.grails.resolve.maven.aether.AetherDependencyManager.resolveToResult(AetherDependencyManager.groovy:436)
    at org.codehaus.groovy.grails.resolve.maven.aether.AetherDependencyManager.resolve(AetherDependencyManager.groovy:347)
    at grails.util.BuildSettings.doResolve(BuildSettings.groovy:513)
    at grails.util.BuildSettings.doResolve(BuildSettings.groovy)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
    at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1086)
    at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1031)
    at groovy.lang.ExpandoMetaClass.invokeMethod(ExpandoMetaClass.java:1110)
    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:66)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallCurrent(CallSiteArray.java:49)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:133)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:145)
    at grails.util.BuildSettings$_getDefaultTestDependencies_closure14.doCall(BuildSettings.groovy:587)
    at grails.util.BuildSettings$_getDefaultTestDependencies_closure14.doCall(BuildSettings.groovy)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite$PogoCachedMethodSiteNoUnwrapNoCoerce.invoke(PogoMetaMethodSite.java:272)
    at org.codehaus.groovy.runtime.callsite.PogoMetaMethodSite.call(PogoMetaMethodSite.java:64)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112)
    at grails.util.BuildSettings.getDefaultTestDependencies(BuildSettings.groovy:581)
    at grails.util.BuildSettings.getTestDependencies(BuildSettings.groovy:562)
    at org.codehaus.groovy.grails.cli.support.ClasspathConfigurer.getClassLoaderUrls(ClasspathConfigurer.java:119)
    at org.codehaus.groovy.grails.cli.support.ClasspathConfigurer.configuredClassLoader(ClasspathConfigurer.java:70)
    at org.codehaus.groovy.grails.cli.GrailsScriptRunner.initializeState(GrailsScriptRunner.java:629)
    at org.codehaus.groovy.grails.cli.GrailsScriptRunner.callPluginOrGrailsScript(GrailsScriptRunner.java:413)
    at org.codehaus.groovy.grails.cli.GrailsScriptRunner.executeCommand(GrailsScriptRunner.java:378)
    at org.codehaus.groovy.grails.cli.GrailsScriptRunner.main(GrailsScriptRunner.java:226)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at org.codehaus.groovy.grails.cli.support.GrailsStarter.rootLoader(GrailsStarter.java:235)
    at org.codehaus.groovy.grails.cli.support.GrailsStarter.main(GrailsStarter.java:263)

1 个答案:

答案 0 :(得分:5)

您可以使用本地插件而不将其添加到lib文件夹中,只需将下面提到的行添加到您的应用BuildConfig.groovy文件中。

grails.plugin.location.myPlugin = "/home/user/plugins/myPlugin"

P.S。您需要添加compile "myPlugin:1.0"作为依赖项而不是插件。