Reputation: 607
I am using Eclipse with spring plugin installed. So when I create an mvc application it creates some folder structure and it uses maven for the same.
But my whole code base uses Gradle as build tool. Is there any way to create boilerplate spring-mvc application with Gradle only.
I have tried writing build.gradle for the same.
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'eclipse-wtp'
task initSourceFolders << {
sourceSets*.java.srcDirs*.each { it.mkdirs() }
sourceSets*.resources.srcDirs*.each { it.mkdirs() }
}
repositories {
mavenCentral()
}
dependencies {
//compile fileTree(dir: 'libs', include: '*.jar')
compile 'org.slf4j:slf4j-api:1.7.5'
compile 'org.slf4j:slf4j-log4j12:1.7.6'
compile 'log4j:log4j:1.2.17'
compile 'com.google.guava:guava:16.0'
providedCompile 'javax.servlet:servlet-api:2.5'
runtime 'javax.servlet:jstl:1.1.2'
testCompile "junit:junit:4.11"
}
On following command, it creates source folders for java - src/main and src/test. gradle initSourceFolders eclipse
and folder structure is as follows
My target folder structure is -
Is there any way to do so using gradle commands?
Upvotes: 0
Views: 1314
Reputation: 2927
Gradle is working on a init tasks similar to how maven allows you to boilerplate certain project types (spring mvc for example)
The feature is currently incubating (not ready for commercial release) but there are 3 project types including creating a project from a pom file that you may find of interest. http://www.gradle.org/docs/current/userguide/build_init_plugin.html
keep an eye on build init it should be added fairly soon.
Upvotes: 1