2

I successfully converted an eclipse (Luna 4.4) Java project to Maven. To use JUnit, I added that as a maven dependency. Here is my resulting project structure as seen in eclipse:

enter image description here

I was expecting that adding JUnit would also create the src/test/Java source folder to hold my JUnit source code, but it's not there. Is this expected? Does one have to manually add these folders after a conversion from a Java project? I saw that when I created a new Maven project in eclipse and added the very same JUnit dependency, the test folder gets created automatically.

2
  • What's the problem with creating the folder manually? Afer it's created you just go to project's configuration and add the folder to Build Path. Commented Jun 20, 2015 at 20:19
  • BTW, your source folder isn't src/main/java as it is recommended by Maven's Standard Directory Layout. Commented Jun 21, 2015 at 8:54

1 Answer 1

4

The creation of test folder happens when you create a new maven project, it is not when you add the jUnit dependency. This is part of the "mvn archetype:generate" command.

So in your case, i would suggest you create a new maven project and copy the /src/ folder manually

Sign up to request clarification or add additional context in comments.

3 Comments

Creating "a new maven project and" (Eclipse-)importing "[his] existing java project" leads to two projects independent of each other, not to one Maven project containing his code, doesn't it?
@GeroldBroser Yes you are right, here "and" shouldn't be there. I meant to create a maven project and copy the src folder. The wordings have been updated to reflect it
The first part is correct now. Thanks for updating your answer. The last sentence still isn't: In Eclipse Luna (and in all previous versions, AFAIR) there are imports for Existing Projects into Workspace and Existing Maven Projects. There is not (and has never been) an import for Import existing (Java) Project as Maven Project. So, the most practical solution is the one with: Creating a new Maven projectCopying the src folder's content to src/main/javaImporting as Existing Maven Project into Eclipse.

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.