Reputation: 571
I am adding new integration-test for a project. However, I am using vscode, and each time I open Java files under integration-test folder, I got a warning "*.java isn't on the classpath. Only syntax errors will be reported".
I had tried Add A Class-Path Entry To The Manifest, Additional Classpath Elements , etc. However, they couldn't help me to solve it.
How do I add folder integration-test
into classpath? (.classpath is auto-genrated, I tried to modify it directly, but each time vscode re-open current project will rewrite the content). I hope any java files inside integration-test
folder will just behave like the ones inside main
or test
folder. Especially I hope those test files could work with Java Test Runner extension.
Note: I didn't mean to load any resources from integration-test
folder. I am hoping I could create, edit any Java files inside integration-test
folder like all the Java files in main
or test
folder. Inside integration-test
, it is just like a test
folder, had a java
folder etc. Right now, vscode will not auto-complete the package path for me when I used intellisense to autocomplete class
snippet, and vscode can't recognize any public class that's already in src/main/java/com...
.
Current folder structure inside src
:
Upvotes: 3
Views: 9176
Reputation: 14956
You can also add new test resource folders.
<build>
<testResources>
<testResource>
<directory>${project.basedir}/src/test/resources</directory>
</testResource>
<testResource>
<directory>${project.basedir}/src/integration-test/resources</directory>
</testResource>
</testResources>
</build>
Upvotes: 1
Reputation: 33384
Mark the directory as a resources directory using maven-resources-plugin:
<project>
...
<name>My Resources Plugin Practice Project</name>
...
<build>
...
<resources>
<resource>
<directory>src/integration-test/resources</directory>
</resource>
</resources>
...
</build>
...
</project>
Upvotes: 1