I created a Java project and used Gradle to structure it with a source folder and a build folder with generated files.
Then I checked in the project using Git and checked it out on another computer. But on this second computer, I can't run this Java project since my src/
folder is not selected as a Source folder. How can I do this? should I have done anything different on the project setup using Gradle?
My build.gradle
just contains these lines:
apply plugin: 'eclipse'
apply plugin: 'java'
When I try to run my computer on my second computer I get this error message:
Selection does not contain a main type
but it runs well on my first computer.
Right-click the "java" directory and select Build Path | Use As Source Folder.
It is important to add the GRADLE_USER_HOME variable in Eclipse: Window->Preferences->Java->Build Path->Classpath Variable. Set it to the path of the ~/. gradle folder in your home directory (e.g. /home/<user_name>/. gradle/ (Unix) or C:\Users\<user_name>\.
A source folder is marked by Eclipse as containing java sources. Then, when you compile your project Eclipse will look for your source code into all your source folders. You can make any folder become a source folder adding it to the java build path.
By default, the Java plugin assumes that production sources are located under src/main/java/
. If they are located under src/
, you'll have to let Gradle know:
sourceSets {
main {
java {
srcDirs = ["src"]
}
}
}
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