3

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: enter image description here

2 Answers 2

2

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>
Sign up to request clarification or add additional context in comments.

Comments

1

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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.