3

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?

howlger
  • 31,050
  • 11
  • 59
  • 99

1 Answers1

1

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:

  1. 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
  2. In the build.gradle change id 'java-library' to id 'application'
  3. 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.

howlger
  • 31,050
  • 11
  • 59
  • 99
  • Thanks, can I change the jdk version after? – Pauler le one Jun 29 '22 at 22:32
  • Yes, a Java 17 JDK with Gradle 7.5-rc-3 works for me, but I don't know whether all combinations of Java and Gradle versions will work. After changing _Java home_ in the project properties _Gradle_, right-click the project and choose _Gradle > Refresh Gradle Project_. – howlger Jun 30 '22 at 08:26