When trying to create a gradle project in eclipse, the source folder, build.gradle and others are stored in a different folder called lib as a separate project. How can I make all the folders be within the project folder like in a normal java project?
CodePudding user response:
The problem is that the New Gradle Project dialog invokes the Gradle init
task with the hard-coded argument --type java-library
and that the project layout for Gradle versions higher than 6.6.1 has a lib
folder besides the main project folder for a project of the type java-library
(in contrast to in Gradle 6.6.1 or lower and in contrast to a project of the type application
independent of the Gradle version).
In the future, in the New Gradle Project dialog, the type application
should also be chooseable, to get a simple project structure like in the past. But this is not implemented yet:
Eclipse Buildship issue #1118: Add more project templates to New Gradle Project wizard
As a workaround do the following:
- In the New Gradle Project dialog on the second or third page, check Override workspace settings and
- choose as Specific Gradle version the version 6.6.1 and
- for Java home a Java 11 JDK
- In the
build.gradle
changeid 'java-library'
toid 'application'
- In Project > Properties: Gradle choose a higher Gradle version
The last two steps are only required to use a Gradle version higher than 6.6.1.