[GRADLE-1289] Provide a "create-project" command to create a skeleton project directory. Created: 05/Jan/11 Updated: 02/Sep/13 Resolved: 01/May/13 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | None |
Fix Version/s: | 1.7-rc-1 |
Type: | New Feature | ||
Reporter: | Paul Cager | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 43 |
Description |
Please see http://gradle.1045684.n5.nabble.com/Gradle-first-steps-and-create-project-td3315373.html It would be good to have some way of conveniently creating a skeleton project (similar to the way "grails create-app" works, for example). This would create the directory structure and maybe an example "HelloWorld" app for the user to customise. You'd probably need separate options for Java, Groovy and Scala programs (the link above mentions some options). |
Comments |
Comment by Leonard Brünings [ 24/Mar/11 ] |
The Script below will create the src file structure for a new project based on the used plugins. build.gradle apply plugin: 'java' apply plugin: 'groovy' apply plugin: 'scala' task initProjectStructure () << { project.sourceSets.all*.allSource.sourceTrees.srcDirs.flatten().each { dir -> dir.mkdirs() } } improved version, call from cmdline task initProject () << { if (hasProperty(initPlugins)) { initPlugins.split(',').each { plug -> project.apply { plugin(plug.trim()) } } } project.sourceSets.all*.allSource.sourceTrees.srcDirs.flatten().each { dir -> dir.mkdirs() } } You could execute this with gradle.bat initProject -PinitPlugins=Java,Groovy,Scala |
Comment by Keith Koski [ 07/Aug/11 ] |
I tried improved version with 1.0-milestone-4. It fails with "Could not find property 'sourceSets' on root project 'fff'." |
Comment by Peter Niederwieser [ 12/Aug/11 ] |
Have a look at the Templates plugin: https://launchpad.net/gradle-templates |
Comment by Steve Olsen [ 17/Sep/11 ] |
I've been looking for this capability everywhere. Maven does this, why not Gradle? |
Comment by Adam Murdoch [ 18/Sep/11 ] |
@steve, there's no good reason, other than we haven't gotten around to it yet. Hopefully soon after Gradle 1.0 is released, we will tackle this problem. |
Comment by mark petrovic [ 25/Aug/12 ] |
I'm interested in this feature, which will really help newcomers get started quickly in creating new projects. |
Comment by Lukas Bradley [ 26/Sep/12 ] |
I've updated Leonard's script above to work with 1.2. apply plugin: 'java' task initProject () << { if (hasProperty(initPlugins)) { initPlugins.split(',').each { plug -> project.apply { plugin(plug.trim()) } } } project.sourceSets*.allSource.srcDirTrees.flatten().dir.each { dir -> dir.mkdirs() } } |
Comment by Michael Peterson [ 01/Apr/13 ] |
I'm new to gradle, but none of the above examples work for me as written. For just Java, you have to issue this cmd: gradle initProject -PinitPlugins=java (Note: lowercase 'j') or change this line: } to: and then just do: from the cmd line +1 for getting this feature added quickly. |
Comment by Adam Murdoch [ 01/May/13 ] |
Gradle 1.6 and 1.7 add some support for setting up a new Gradle build using the `build-setup` plugin. This initial support is very basic and we want to grow it in future releases, but I've marked this issue as 'fixed'. If you find problems or have suggestions for improvements to this build initialization support, please feel free to raise new issues via the forums. You can find out more about our plans in this design spec: https://github.com/gradle/gradle/blob/master/design-docs/build-initialisation.md |
Comment by Marcel Overdijk [ 25/Aug/13 ] |
Looking at the build-setup plugin, am I right there is support (yet) for custom templates? |
Comment by Adam Murdoch [ 02/Sep/13 ] |
@Marcel, that's correct. The plan is to add support for this over time. |