Grails内联(inplace)插件无法解析依赖项

时间:2013-08-14 17:04:24

标签: grails plugins dependencies

我有一个名为Media的插件,它应该处理图像大小调整等问题。

它有这些依赖性:

dependencies {
    compile group: 'org.ccil.cowan.tagsoup',
            name: 'tagsoup',
            version: '1.2'
    runtime group: 'org.codehaus.groovy.modules.http-builder',
            name: 'http-builder',
            version: '0.5.2'
    compile group: 'org.imgscalr',
            name: 'imgscalr-lib',
            version:'4.2'
    compile group: 'org.apache.tika',
            name:  'tika-core',
            version: '1.3'
} 

当我将插件作为独立应用程序运行时,一切正常。

比我创建了一个应用程序并将inplace插件依赖项添加到我的BuildConfig.groovy文件中。

// there is grails.project.dependency.resolution closure above
grails.plugin.location.Media = "../../plugins/Media";

当我运行app我的应用程序时,我收到此错误:

| Error Compilation error: startup failed:
/home/grails/plugins/Media/grails-app/controllers/frod/media/ImageServiceController.groovy: 14: unable to resolve class org.imgscalr.Scalr
@ line 14, column 1.
import org.imgscalr.Scalr
^

/home/grails/plugins/Media/src/groovy/frod/media/download/CachedContentDownloader.groovy: 3: unable to resolve class org.apache.http.HttpResponse
@ line 3, column 1.
import org.apache.http.HttpResponse
^

/home/grails/plugins/Media/src/groovy/frod/media/download/ContentDownloader.groovy: 3: unable to resolve class org.apache.http.HttpResponse
@ line 3, column 1.
import org.apache.http.HttpResponse
^

/home/grails/plugins/Media/src/groovy/frod/media/download/ContentDownloader.groovy: 4: unable to resolve class org.apache.http.client.HttpClient
@ line 4, column 1.
import org.apache.http.client.HttpClient
^

/home/grails/plugins/Media/src/groovy/frod/media/download/ContentDownloader.groovy: 6: unable to resolve class org.apache.http.impl.client.DefaultHttpClient
@ line 6, column 1.
import org.apache.http.impl.client.DefaultHttpClient
^

/home/grails/plugins/Media/src/groovy/frod/media/download/ContentDownloader.groovy: 5: unable to resolve class org.apache.http.client.methods.HttpGet
@ line 5, column 1.
import org.apache.http.client.methods.HttpGet
^

/home/grails/plugins/Media/src/groovy/frod/media/download/DownloadedContent.groovy: 3: unable to resolve class org.apache.http.HttpEntity
@ line 3, column 1.
import org.apache.http.HttpEntity
^

/home/grails/plugins/Media/src/groovy/frod/media/download/IContentDownloader.groovy: 3: unable to resolve class org.apache.http.HttpResponse
@ line 3, column 1.
import org.apache.http.HttpResponse
^

/home/grails/plugins/Media/src/groovy/frod/media/image/thumbnail/adjustment/crop/CropProcessor.groovy: 5: unable to resolve class org.imgscalr.Scalr
@ line 5, column 1.
import org.imgscalr.Scalr
^

/home/grails/plugins/Media/src/groovy/frod/media/image/thumbnail/adjustment/resize/IResizeAdjustment.groovy: 3: unable to resolve class org.imgscalr.Scalr
@ line 3, column 1.
import org.imgscalr.Scalr
^

/home/grails/plugins/Media/src/groovy/frod/media/image/thumbnail/adjustment/resize/IResizeAdjustment.groovy: 16: unable to resolve class Scalr.Mode
@ line 16, column 5.
public Scalr.Mode getMode();
^

/home/grails/plugins/Media/src/groovy/frod/media/image/thumbnail/adjustment/resize/IResizeAdjustment.groovy: 18: unable to resolve class Scalr.Method
@ line 18, column 5.
public Scalr.Method getMethod();
^
// and many others

正如您所看到的,它无法解决依赖关系(您可以看到http-builder imgscalr-lib)。

我google了很多,发现我可以尝试将legacyResolve设置为true。我尝试了所有这些设置(插件,应用程序,插件+应用程序)和相同的结果 - 上面的错误。

任何人都可以帮我吗?

我的Grails版本是2.2.3

非常感谢

1 个答案:

答案 0 :(得分:6)

依赖关系由Ivy解决,但这取决于可用的POM文件。当您使用内联插件时,情况并非如此,因为您只是指向插件源。您可以是冗余的,并将依赖项添加到应用程序的BuildConfig中,或者使用打包该插件的maven-install脚本并将其复制到本地Maven缓存中。

maven-install不太方便,因为每次在应用程序中需要更改插件时都必须重新运行它,但它更接近真正的安装过程。要使用像这样在本地发布的插件,请确保在BuildConfig.groovy中取消注释mavenLocal()并添加一个依赖项,就像您已经发布插件一样,例如: compile ':myplugin:0.1'