1

我有一个名为 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'
} 

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

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

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

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

| 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)。

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

谁能帮我这个?

我的 grails 版本是 2.2.3

非常感谢

坦率

4

1 回答 1

6

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

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

于 2013-08-14T17:53:16.653 回答