47

I just started reading "Pro Spring MVC with web flow" and it comes with a code sample that I want to follow.

  • What I want - I want to build the applications as it's done in the book, using Gradle
  • What is the problem - I have never used Gradle before and when I try to execute what I'm thinking I have to I get this error Task 'build' not found in root project
  • What have I done so far - Yesterday I downloaded Gradle from the official site and get it to work. Today when I actually tried to execute the steps from the book it turns out that the sample code comes with its own Gradle distribution and I executed it which I think followed to getting a second distribution of Gradle. However, I don't know if this may be a problem or not. now my directory with the sample code looks like this: enter image description here

Then it's written that I have to execute ../gradlew build which I execute like this and get the following: enter image description here

  • What have I tried - The only thing that came to my mind was to leave only the Gradle's stuff plus the appendixA-bookstore folder in case Gradle recognize all directories as different builds but no success.
  • What's the final result that I want to accomplish - First I want to figure out where is my mistake and how to build the sample application(s). And also it would be perfect if I actually can do this from my first Gradle setup which as I wrote did yesterday and what exactly should I do to use this sample code with my fresh and original Gradle setup?
John Smith
  • 7,243
  • 6
  • 49
  • 61
Leron
  • 9,546
  • 35
  • 156
  • 257

4 Answers4

37

You didn't do what you're being asked to do.

What is asked:

I have to execute ../gradlew build

What you do

cd ..
gradlew build

That's not the same thing.

The first one will use the gradlew command found in the .. directory (mdeinum...), and look for the build file to execute in the current directory, which is (for example) chapter1-bookstore.

The second one will execute the gradlew command found in the current directory (mdeinum...), and look for the build file to execute in the current directory, which is mdeinum....

So the build file executed is not the same.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • I'm not sure what are you suggesting me to do. The sample code comes in a `Zip` file which contains all the directories on the printscreen plus the `gradlew` batch file which I executed. It just so happened that I unziped the directory on the desktop so my path is `C:\Users\Xman\Desktop\mdeinum-pro-spring-mvc-code-5d01f03` and I see that I obviously don't get the instructions right but what I have to change to make this work? – Leron Dec 30 '12 at 18:13
  • Tried `C:\Users\Xman\Desktop\mdeinum-pro-spring-mvc-code-5d01f03\appendixA-bookstore\..\gradlew build` and few other modifications but no success, could you be more specific on how exactly to execute this? Sorry for being so newb. – Leron Dec 30 '12 at 18:41
13

run

gradle clean 

then try

gradle build 

it worked for me

Mani
  • 604
  • 7
  • 9
6

Check your file: settings.gradle for presence lines with included subprojects (for example: include chapter1-bookstore )

Milad Bahmanabadi
  • 946
  • 11
  • 27
Igor Guk
  • 61
  • 1
  • 1
0

If you are using gradle 7.5.1 then you need to run the command as -- $ gradle tasks

So in your case the task name would be the one found under chapter folders.