在 IntelliJ 的 Java 项目中使用 .gdsl 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41062514/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 05:39:52  来源:igfitidea点击:

Use .gdsl file in a Java project in IntelliJ

javaintellij-ideajenkinsgroovyjenkins-pipeline

提问by Michael Lihs

I have a file pipeline.gdslthat contains the Syntax for my Jenkins Pipeline DSL. Following this blog postI put the file into the /srcfolder of my Java project. When I now edit my Jenkinsfile(residing in the root folder of my project), I don't get any code completion / syntax explanation as I would expect.

我有一个pipeline.gdsl包含 Jenkins Pipeline DSL 语法的文件。在这篇博文之后,我将文件放入/src我的 Java 项目的文件夹中。当我现在编辑我的Jenkinsfile(驻留在我的项目的根文件夹中)时,我没有像预期的那样得到任何代码完成/语法解释。

My project is a Java / Gradle project and I cannot make a Groovy project out of it. Is there some other way to make IntelliJ aware of the .gdslfile and provide code completion?

我的项目是一个 Java/Gradle 项目,我不能用它来制作 Groovy 项目。有没有其他方法可以让 IntelliJ 知道.gdsl文件并提供代码完成?

采纳答案by Michael Lihs

The problem was, that /srcwas not marked as a source root folder in my project. Creating a folder /src/main/groovy, putting the file in there and marking it as a sources root (right click on the folder -> Mark directory as -> Sources Root) did the trick.

问题是,它/src没有在我的项目中标记为源根文件夹。创建一个文件夹/src/main/groovy,将文件放入其中并将其标记为源根目录(右键单击该文件夹 -> 将目录标记为 -> 源根目录)即可解决问题。