139.223 No copy test resources 关注
I have resource files (xml, sql) in my source directories. IDEA copies
those when I do a build.
I also have resource files in my test source directory. IDEA does not
copy them. Why is that?
Resource files under test source directory should go to separate test output path, not into production output path. Do you mean reasources are not copied into _test output_ path?
You are correct, they should go into the test output path.
They are not.
This is a problem.
On 11/5/14 4:56 AM, Alexander Chernikov wrote:
Sorry, can't reproduce by now.
I expect, Settings dialog / Compiler / "Resource patterns" are correct?
Maybe you can attach a sample project to show the problem?
I have a similar problem.
I've defined a test and an integration-test folder. Since IntelliJ 14 it copies only the resource files from test into the build folder, but the resources from integration-test are missing.
Is there any difference in IDEA settings for these two directories? Some difference in their appearance in Project tree view, or different settings in Project Strcuture dialog?
Afaik everything is the same. This has worked in IntelliJ 13 without a flaw, I just changed the IDE ?:|
I made a screenshot:
Everything works fine if I run the test with gradle on the command line
Sorry, still can't reproduce. Maybe some gradle-specific. Will show this case to colleagues, maybe they'll get some idea.
Max, there were changes in that area https://youtrack.jetbrains.com/issue/IDEA-126986#comment=27-764027
Please check this issue: https://youtrack.jetbrains.com/issue/IDEA-91952. Does it describe your problem?
I've seen some stuff going on about this topic, but at this point I don't really have a clue what to do.
So I assembled a demo project with a failing test to reproduce the behavior.
Btw. I've seen that this is about EAP, but I'm using 14.0.1 139.225 - Sorry for using the wrong thread :)
Max, if you run tests as JUnit, IDEA's Make is executed, but not Gradle's :build task. And Make is not aware of the custom behavior you specified in build script, that's why resources are not copied.
If you run Gradle :test task, recources are not copied either, because
doesn't force :integrationTest to run after :test, it just specifies task ordering in case both tasks are executed.
Try to change the above line to
Thus you'll get the expected behavior.
Hope I've clarified your question.
Good luck :)
the intention was that test should not depend on integrationTest.
I'm curious why this worked with IDEA 13 and is not working anymore with IDEA 14 with the same Gradle config.
inheritOutputDirs = true seems to set the IDEA output dir correct, but doesn't help with the integration test resource when running the integration test as a junit test within IDEA.
You know, gradle supports multiple source sets(with different classpath) per one project.
But, unfortunately, the information about custom source sets does not exposed by gradle tooling api which IDEA uses to get project information.
You can find related gradle issue at https://issues.gradle.org/browse/GRADLE-2680
Using some heuristic, IDEA 13 are able to resolve directories cofigured by custom source set as source/resources or test-sources/test-resources directories.
That's why it works for simple cases. But actually it was a workaround, I think IDEA should imports custom source sets as a separate IDEA modules to be able to configure right classpaths.
This will be addressed in v14.1
Since v14 IDEA gradle integration performs resources compilation based on configuration imported from gradle to support resource filtering, inclusion/exclusion, rename etc.
But, as I wrote above, IDEA still can not work properly with custom source sets and can use only built-in ("main" and "test") gradle source sets configuration.
So, if you want to have "src/integration-test/resources" in test classpath in IDEA you could add the following code:
But be careful, in this case, you need to rename src/integration-test/resources/application-test.properties to avoid file name clashes, otherwise application-test.properties comes from different folders (src/integration-test/resources or src/test/resources) will overwrite each other.
thanks for your explanation, I got it now :)
Looking forward for IDEA 14.1 then.. (maybe I"ll apply your suggested workaround until it's ready)