将依赖项目添加到 eclipse grails 项目在 run-app 上失败

发布于 2025-01-03 12:26:41 字数 773 浏览 0 评论 0原文

我一直在考虑使用 grails 构建模拟服务器框架,但在 STS 中配置它时遇到了麻烦。

基本要求是在自己的项目中拥有一个核心框架,该框架最终将成为 WAR 工件,然后对于每个被模拟的服务,将创建一个新的 jar 项目,其中包含服务配置(通常是 xml/json 响应和用于动态响应的 groovy 文件),它将作为依赖项拉入主 WAR 文件(在构建过程中使用配置文件)。

这个外部构建过程是使用 Maven 和配置文件很好地定义的。我已经对此进行了原型设计,并且所有这些都通过 Jenkins 等构建器运行起来。

我遇到的问题是使用本机 Eclipse 项目依赖项管理和 Eclipse Grails 支持来设置可用的 Eclipse 环境。我想要的是一个包含框架的标准 grails 项目,然后是一个包含服务配置文件的标准 groovy 项目,然后将后一个项目添加为前者的依赖项。然而,我发现,如果您执行此操作然后调用 run-app,则 groovy 项目中的类和资源不会包含在正在运行的应用程序中。我尝试过检查导出,但这没有任何区别。

到目前为止,我发现的唯一解决方法是使 groovy 项目 maven 工件成为 grails 应用程序中的依赖项,并在每次构建时将其引入。这涉及到每次在该项目中进行更改时将 groovy 项目打包并安装到本地存储库中的不良步骤。当然,这种方法的另一个主要缺点是我根本无法从动态更新中受益,并且 groovy 项目中的任何代码更改都需要重新启动 grails 应用程序。

有人用这种方法成功配置过eclipse吗?如果这是不可能的,是否有某种方法可以修改 grails 构建过程,以便通过相对路径包含其他项目?

I've been looking at using grails to build a mock server framework, but have been having troubles configuring it within STS.

The basic requirement is to have a core framework living in its own project, which will ultimately end up as a WAR artifact, and then for each service that's mocked a new jar project will be created containing the service configuration (typically xml/json responses and groovy files for dynamic responses), which will get pulled into the main WAR file as a dependency (using a profile during the build process).

This external build process is fairly well defined using Maven and profiles. I've prototyped this and it all hangs together running off a builder such as Jenkins.

What I'm having trouble with is setting up a usable eclipse environment using the native eclipse project dependency management and eclipse grails support. What I'd like to have is a standard grails project containing the framework, and then a standard groovy project containing the service configuration files and then add the latter project as a dependency to the former. What I've found however, is that if you do this and then invoke run-app, the classes and resources in the groovy project don't get included in the running application. I've tried checking export, but this doesn't make any difference.

The only workaround I've found so far, is to make the groovy project maven artifact a dependency within the grails application, and to pull this in on each build. This involves the undesirable step of packaging and installing the groovy project into the local repo each time a change is made in that project. The other major drawback to this approach of course is that I don't benefit at all from dynamic updates, and any code changes in the groovy project require a restart of the grails app.

Has anyone successfully configured eclipse in this way? If this isn't possible, is there some way of tinkering with the grails build process in order to include the other project through relative paths, say?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

荒人说梦 2025-01-10 12:26:41

从这个常见问题解答条目来看,推荐的方法是使用他们的插件架构。必须看看这是否能很好地与 Eclipse 配合使用。

http://grails.org/FAQ#Q:%20I'd%20like%20to %20implement%20a%20big%20project%20as%20multi%20modules%20with%20Grails,%20%20to%20做什么?

更新:

可以通过将条目添加到 BuildConfig.grails 以及插件的相对路径(例如

grails.plugin.location."my-plugin" = "../) 来让您的 grails 应用程序识别插件的扩展工作目录。 my-plugin"

使用 'package-plugin' 命令打包插件后,您的 grails 应用程序就可以调试插件中的 groovy 和 java 文件。它还会在应用程序重新启动后获取对插件的更改。这几乎就是我所追求的。

然而,关于如何使用 xml/json/groovy 文件(随你命名)的混合创建自定义资源结构并将它们包含在生成的插件中,这根本不直观。更不用说相对资源路径的陌生性了。我在某处读到,您可以使用 _install.groovy 自定义包含的内容和不包含的内容,但同样,如何执行此操作并不明显。我最担心的是这个项目应该可以被不精通技术的用户编辑,所以我真的只是想向他们展示一个干净的项目,没有所有这些 grails 脚手架。

我对这种方法的臃肿感到绝望。一个简单的常规项目有什么问题,它本来可以作为一个简单的 jar 包含在内?这似乎有点矫枉过正,尤其是对于像我这样的简单需求。

Judging by the this FAQ entry, the recommended approach would be to use their plugin architecture. Will have to see if this plays nicely with eclipse or not.

http://grails.org/FAQ#Q:%20I'd%20like%20to%20implement%20a%20big%20project%20as%20multi%20modules%20with%20Grails,%20What%20to%20do?

update:

It is possible to have your grails app recognise the expanded working directory of your plugin by adding an entry to BuildConfig.grails with the relative path to your plugin e.g.

grails.plugin.location."my-plugin" = "../my-plugin"

After packaging the plugin using the 'package-plugin' command, your grails app can then debug groovy and java files in your plugin. It will also pick up changes to the plugin following an app restart. So that's nearly what I'm after.

It is however not at all intuitive about how I'd go about creating a custom resource structure with a mix of xml/json/groovy files (you name it) and have these included in the resulting plugin. Not to mention the strangeness with relative resource paths. I read somewhere that you could customise what is and isn't included using _install.groovy, but again it's not obvious how to do this. My biggest concern is that this project should be editable by users that aren't hardcore tech savvy, so really I really I just want to present them with a clean project devoid of all of this grails scaffolding.

I despair at the bloatiness of this approach. What was wrong with a simple groovy project, which could have been included as a simple jar? It just seems like overkill, especially for simple requirements such as mine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文