Gradle
  1. Gradle
  2. GRADLE-1289

Provide a "create-project" command to create a skeleton project directory.

    Details

    • Type: New Feature New Feature
    • Status: Resolved Resolved
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.7-rc-1

      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).

        Activity

        Hide
        Lukas Bradley
        added a comment -

        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()
        	}
        }
        
        Show
        Lukas Bradley
        added a comment - 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() } }
        Hide
        Michael Peterson
        added a comment - - edited

        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:
        initPlugins.split(',').each { plug -> project.apply

        { plugin(plug.trim()) }

        }

        to:
        project.apply

        { plugin('java') }

        and then just do:
        gradle initProject

        from the cmd line

        +1 for getting this feature added quickly.

        Show
        Michael Peterson
        added a comment - - edited 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: initPlugins.split(',').each { plug -> project.apply { plugin(plug.trim()) } } to: project.apply { plugin('java') } and then just do: gradle initProject from the cmd line +1 for getting this feature added quickly.
        Hide
        Adam Murdoch
        added a comment -

        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

        Show
        Adam Murdoch
        added a comment - 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
        Hide
        Marcel Overdijk
        added a comment -

        Looking at the build-setup plugin, am I right there is support (yet) for custom templates?

        Show
        Marcel Overdijk
        added a comment - Looking at the build-setup plugin, am I right there is support (yet) for custom templates?
        Hide
        Adam Murdoch
        added a comment -

        @Marcel, that's correct. The plan is to add support for this over time.

        Show
        Adam Murdoch
        added a comment - @Marcel, that's correct. The plan is to add support for this over time.

          People

          • Assignee:
            Unassigned
            Reporter:
            Paul Cager
          • Votes:
            43 Vote for this issue
            Watchers:
            34 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: