简体   繁体   English

如何设置Intellij复制资源目录,而不仅仅是目录内容?

[英]How can I set Intellij to copy resource directories and not just the directory content?

I'd like to set a folder in my Intellij project as a test resource folder and have the Intellij IDE copy the whole folder to my output directory and keep the top level folder in place. 我想在Intellij项目中将一个文件夹设置为测试资源文件夹,并让Intellij IDE将整个文件夹复制到我的输出目录中,并保留顶层文件夹。

For example, here's a basic project structure: 例如,这是一个基本的项目结构:

src/
 - stack/
  - overflow/
   - question/
    - SomeClass.java
tst/
 - stack/
  - overflow/
   - question/
    - SomeClassTest.java
files/
 - testfile.txt
 - testdoc.doc
 - testpdf.pdf
test-configuration/
 - default.properties
 - test-configuration.xml

Should compile and create an output directory like: 应该编译并创建一个输出目录,如:

out/
 - stack/
  - overflow/
   - question/
    - SomeClass.class
 - test-configuration/
  - default.properties
  - test-configuration.xml
 - files/
  - testfile.txt
  - testdoc.doc
  - testpdf.pdf

The problem is, just marking the test-configuration or files directories as Test Resources Root (or Resources Root ) folders, always produces the following output directory structure: 问题是,仅将test-configurationfiles目录标记为Test Resources Root (或Resources Root )文件夹,总是会产生以下输出目录结构:

out/
 - stack/
  - overflow/
   - question/
    - SomeClass.class
 - default.properties
 - test-configuration.xml
 - testfile.txt
 - testdoc.doc
 - testpdf.pdf

Intellij seems to only copy the contents of the resource folders and not the whole directory. Intellij似乎只复制资源文件夹的内容,而不是整个目录。 Is there a way to set Intellij to copy the root directory to maintain the directory structure in the output? 有没有一种方法可以设置Intellij复制根目录以维护输出中的目录结构?

No, there is no such way. 不,没有这样的方法。 A resource root is just that: a directory the contents of which is copied to the root of the output directory. 资源根目录就是:目录的内容被复制到输出目录的目录。 If you need to have additional structure, you need to create a "resources" directory, mark it as a resource root, and move your "test-configuration" and "files" directories into it. 如果需要其他结构,则需要创建“资源”目录,将其标记为资源根目录,然后将“测试配置”和“文件”目录移入其中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM