How to fix the error: test source folder 'src/test/java' in project must have an output folder that is not also used for main source"?
Asked Answered
S

4

7

I have installed mahout and I have imported the existing maven project apache-mahout-distribution-0.12.2 to Eclipse IDE for Java Developers and can not build and I couldn't fix these problems. Please share me your knowledge!

Simeon answered 31/7, 2018 at 8:34 Comment(1)
This issue seems related: github.com/eclipse/eclipse.jdt.ls/issues/1635Dial
S
6

I had similar issue and had to type-in the name of the output folder directly in the .classpath as follows

<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>

Note that 'contains test source' on Java Build Path panel should be set to 'Yes'. Once I did that and refreshed the output became visible in the Java Build Path panel.

Stomato answered 10/1, 2019 at 2:59 Comment(0)
A
6

I had the same problem a couple of minutes ago. I tried some options as listed below and nothing happened:

  • Changing the output folder specific for test class
  • Changing the option 'Contains test sources' from no to yes and vice-versa
  • Excluding all source folders on build path

My solution: I removed the project from my workspace and a new one was created.

enter image description here

enter image description here

Furthermore infomation about Test Source configuration at Eclipse, https://www.eclipse.org/eclipse/news/4.8/jdt.php#jdt-test-sources

Antecedent answered 16/7, 2020 at 20:41 Comment(2)
What you mean by I removed from workspace and new one was created, who creates it? Mystical powers?Strata
I removed and created manually a new one.Antecedent
F
2

I had this problem and solved it as follows:

  1. Right-click on project, Properties -> Java Build Path -> Source
  2. Tick the "Allow output folders for source folders" checkbox
  3. Now you can double-click on "Output folder" and set it per source folder path.
Frog answered 21/9, 2022 at 14:28 Comment(0)
H
-1

Surely it will be enough to open project's Java Build Path, focus the src/test/java folder and set its output folder as <project>/target/test-classes.

Hid answered 31/7, 2018 at 9:48 Comment(2)
There is no separate output folder for test sources in my version.Porscheporsena
@SridharSarnobat Strange that Jan Hrabowski's answer worked for you, and not mine, while both of them are doing the same in different ways.Hid

© 2022 - 2024 — McMap. All rights reserved.