I have created a Java project using Eclipse. Since I didn't do anything special, its folder structure is the default one that all Eclipse projects use:
Project
└── src
├── foo
│ └── MyClass.java
└── fooTests
└── MyTest.java
However, I would like to migrate this to the folder structure used by Maven and derivatives such as Gradle.
Project
└── src
├── main
│ └── foo
│ └── MyClass.java
└── test
└── foo
└── MyTest.java
However, there doesn't seem to be an obvious way to change my folder structure. The big issue seems to be what to do with the source folder. I tried to do this manually, but it tried to make the package for MyClass.java as main.foo
, which I obviously don't want. I haven't found a maven or gradle plugin that converts the structure automatically.
How do I go about changing my Eclipse project folder structure to a Maven/Gradle structure?
Maven project structure defines a folder in order to store all resources and files needed by a web application. Inside this folder you can put all the required files for a web application like jsp files, js files, html files, css files, template files, reports files, WEB-INF files (like web. xml), META-INF files, etc…
Whenever you make a project inside of Eclipse, Eclipse will auto-magically create a new folder in your workspace with the same name. Inside of that folder it will create two folders: bin, and src (source). The bin folder can be ignored. This is nothing more than the folder in which Eclipse stores the .
You can actually do all of this manually with minimal fuss.
src
folder and choose "Build Path" -> "Remove from Build Path"src
folder, create a main/java
foldermain/java
folder and choose "Build Path" -> "Use as Source Folder"test/java
Once you're done with the refactoring, your project will be structured in the Maven way. This will make things much simpler when you decide to actually start using Gradle and Maven for your project.
Note that Java will still display your src/main
folder separately in the project viewer. This is normal. Eclipse shows your source folder at top and then all other folders in the project view, which include the source folder parents.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With