I have a new Gradle guy who try to create a Java project by gradle build configuration file.
I had a build.gradle in my project folder /example with content:
apply plugin: 'java'
However, after I built the project
gradle build
I didn't see my src/main/java and src/test/java anymore.
How can I create a project layout of java with gradle configuration file ?
To quickly create a new Java project you can use an Init gradle plugin (as it was mentioned in the comments). This plugin is shipped with Gradle by default and you can run it's init task just from the command line. This task will create project layout and even with the build.gradle and settings.gradle files. You just have to call this task and provide a project type you want to create as task's argument:
gradle init --type java-library
in the folder, there you want to create your project. But if you already has a build.gradle file there, the task will be skipped, so, you have to do it in some empty project. Just calling the build task won't create any layout for you.
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