Skip to content
Advertisement

How to create Java gradle project

How to create Java Gradle project from command line?

It should create standard maven folder layout like on the picture below.

Java Gradle created with Eclipse plugin

UPDATE:

.1. From http://www.gradle.org/docs/current/userguide/tutorial_java_projects.html I need to create file build.gradle with 2 lines

apply plugin: 'java'
apply plugin: 'eclipse'

.2. Add to build.gradle task below, than execute gradle create-dirs

task "create-dirs" << {
   sourceSets*.java.srcDirs*.each { it.mkdirs() }
   sourceSets*.resources.srcDirs*.each { it.mkdirs() }
}

.3. Then run gradle eclipse (or corresponding string to other IDE plugin configured)

So is there way to do it in one command?

Advertisement

Answer

To create a Java project: create a new project directory, jump into it and execute

gradle init --type java-library

Source folders and a Gradle build file (including a wrapper) will be build.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement