按惯例在GGTS中引用外部依赖关系 [英] Referencing external dependencies in GGTS by convention

查看:90
本文介绍了按惯例在GGTS中引用外部依赖关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在我的项目构建路径中通过约定引用依赖项?请允许我详细说明...



我正在使用Groovy / Grails工具套件(GGTS 3.0)。我在我的BuildConfig.groovy中引用了依赖关系:

 依赖关系{
compile'tgt:jaxb- utils:1.0'
}

引用的jar文件已成功从Artifactory回购 - 我可以在Ivy缓存中的本地文件系统上找到jar文件。当我运行任何grails目标( grails compile grails run-app grails run-测试),它工作正常 - 这意味着我从jar中导入类的代码没有问题。当我运行 grails war 时,被引用的jar文件被打包到构造的war中。



然而,这里是这篇文章的症结所在 - 项目构建路径没有默认或惯例地引用这个jar文件,所以从jar文件中导入类的java或groovy代码报告无法解析类... 错误。

一个解决方案是简单地将jar文件添加到lib文件夹并相应地更新构建路径,或修改构建路径以引用Ivy高速缓存文件夹中的jar文件。但是,我必须这样做,以此方式拉下所有/所有依赖项。 lib文件夹中的任何jar都会被保存到团队源代码库中,这似乎是浪费的空间,因为grails命令只需要BuildConfig.groovy中的依赖关系引用即可正常工作。

我在这里只是过于理想化(即 - 困难),还是有更好的方法来清理无法解析类。 。在我的IDE中的错误,而不必手动添加相关的jar文件到我的lib文件夹并更新我的构建路径?想法?

解决方案

Eclipse / STS / GGTS:如果您安装了Grails插件,您可以执行以下操作:



右键单击您的项目 - > Grails工具 - >刷新依赖项(或快捷键Alt + G,R)


How do I reference a dependency by convention within my project build path? Allow me to elaborate...

I'm using the Groovy/Grails Tool Suite (GGTS 3.0). I'm referencing the dependency as such in my BuildConfig.groovy:

dependencies {
    compile 'tgt:jaxb-utils:1.0'
}

The referenced jar file is successfully pulled down from the Artifactory repo - I can find the jar file on my local file system in the Ivy cache. When I run any grails targets (grails compile, grails run-app, grails run-tests), it works fine - meaning my code that imports the classes from the jar has no problems. When I run grails war, the referenced jar file is packed into the constructed war.

However, and here is the crux of this post - the project build path does not reference this jar file by default or convention, so my java or groovy code that imports the classes from the jar file reports a unable to resolve class ... error.

One solution is to simply add the jar file to the lib folder and update the build path accordingly, or modify the build path to reference the jar file in the Ivy cache folder. However, I'd have to do this for any/all dependencies pulled down in this way. Any jars in the lib folder will get saved to the team source code repository, and that seems like wasted space since the grails commands work fine with just the dependency reference in BuildConfig.groovy.

Am I just being too idealistic (ie - difficult) here, or is there a better way to clean up the unable to resolve class ... errors in my IDE without having to manually add the dependent jar files to my lib folder and update my build path? Ideas?

解决方案

Eclipse / STS / GGTS : If you have Grails plugin installed, you can do the following :

Right click on your project -> Grails Tools -> Refresh dependencies (or shortcut "Alt+G, R")

这篇关于按惯例在GGTS中引用外部依赖关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆