Can "gradle init" be more intuitive?


(rafaljaw) #1

I’m trying to create new project using build init plugin. That’s what I did:

c:\svn>gradle init

It turns out gradle puts configuration files directly in c:\svn directory, which is not what I would expect. I think it should either ask you for the name of the project, or you should use it like this:

c:\svn>gradle init my-project

this is how the output should look like: c:\

  • svn

  • my-project

  • build.gradle

  • settings.gradle

After that we can add new projects to this multi-module root:

c:\svn\my-project>gradle init --type java-library my-core

and the output I expect is: c:\

  • svn

  • my-project

  • my-core

  • src

  • main

  • test

  • build.gradle

  • settings.gradle

  • build.gradle

  • settings.gradle

To me the way this plugin works now is counterintuitive and should be improved. Why it was designed differently? Shouldn’t it be more similar to maven archetype plugin?


(René Groeschke) #2

Hello,

thanks for your valuable feedback. As listed in the release notes, the gradle init task is still considered “incubating” and in active development. Usually the build.gradle file of a project is located directly in the project folder. In your 2nd expected output, you have two settings.gradle and two build.gradle files on root level above those two project directories. What I can think of is, that gradle might provide support for adding an subproject to an existing multiproject build. Triggering “gradle init --type --java-library my-core” in a gradle multiproject root directory would add a subfolder ‘my-core’ with an according build.gradle file and add this my-core project to the multiproject build by adding an “include ‘:my-core’” to the setttings.gradle file.

cheers, René


(rafaljaw) #3

Sorry, I lost the formatting. Here’s what I’d like to get in second example (like you said - I’d like to have support for adding new subproject to existing multiproject).


(rafaljaw) #4

And are we trying to find better name than “gradle init”? I’m always trying ‘gradle create’ first and then google for the correct name:)


(René Groeschke) #5

you can format your code very easy by putting it into <code> tags.


(René Groeschke) #6

We don’t thought about renaming it as we just renamed it from setupBuild to init. “init” seems very concise to me and is also used in other projects (e.g. “git init”)


(rafaljaw) #7

I will still love it and use it even if it will be called “gradle init” forever! But still I have to add my two cents - we need those discussions now, when it’s still in incubator:) Please look at these:

grails create-app my-app griffon create-app my-app rails new my-app

That’s why it seems to me that ‘gradle create’ would be better if I’m creating new project (we can always create alias for gradle init).

Personally I think ‘gradle init’ is good name when I’m converting maven project into gradle project. ‘Chapter 47. Build Init Plugin’ is definitely better than ‘Chapter 47. Build Setup Plugin’ (we probably can’t call it ‘Gradle Archetype Plugin’ nor ‘Gradle Skeleton Plugin’)

On the other hand… maybe ‘gradle init’ should be split into two separete plugins? Right now it does two things: creates new project and converts existing ant/maven project. Maybe it is perfectly fine, maybe it needs rethinking - I don’t know. I wish there was more people involved!