How to run Gradle Wrapper on Windows 7?
Asked Answered
U

3

11

I am trying to follow a tutorial on downloading, installing and running a Groovy app, and the instructions say that I can run the app via:

./gradlew myapp

I have installed Gradle on my Windows 7 machine under D:\gradle. If I run gradle -v I get:

------------------------------------------------------------
Gradle 1.11
------------------------------------------------------------

Build time:   2014-02-11 11:34:39 UTC
Build number: none
Revision:     a831fa866d46cbee94e61a09af15f9dd95987421

Groovy:       1.8.6
Ant:          Apache Ant(TM) version 1.9.2 compiled on July 8 2013
Ivy:          2.2.0
JVM:          1.7.0_51 (Oracle Corporation 24.51-b03)
OS:           Windows 7 6.1 amd64

So I know its installed correctly. But then when I run:

.\gradlew myapp

I get:

-bash: ./gradlew: No such file or directory

When I run:

gradlew myapp

I get:

-bash: gradlew: command not found

What is going on here?

Update

My directory structure:

D:\
    lazybones\
        0.7\
            lazybones-0.7\
                lazybones\
                    bin\
                        lazybones.bat
    my-template

When I go to my D:\ drive and run lazybones/0.7/lazybones-0.7/bin/lazybones.bat installPackageMyTemplate I get:

There is no command 'installPackageMyTemplate'
Undervalue answered 31/7, 2014 at 15:44 Comment(2)
Why are you running the bash script and not the Windows batch file?Sneaking
Thanks @JeffScottBrown (+1) - please see my update for what happens when I run the batch file...Undervalue
O
18

gradlew.bat is a batch script that bootstraps Gradle. It needs to be committed to source control along with the rest of the project. If your project doesn't have a gradlew.bat, you can generate one with gradle wrapper.

Onfre answered 31/7, 2014 at 15:58 Comment(11)
Thanks @Peter Niederwieser (+1) - actually the project just ships with a ZIP that contains batch and bash files (from Windows and Linux alike). Specifically, the project is an open source project called Lazybones. If you read the section called "Running it", you'll see that they recommend using GVM. Since I'm on Windows, GVM isn't really viable, so I took their 2nd suggestion to download the ZIP from Bintray. Any thoughts/ideas? Thanks again!Undervalue
If the project has a gradlew.bat, use that. Otherwise, use your local Gradle installation.Onfre
Thanks again @Peter Niederwieser (+1 again), but I don't think you understand. In my particular use case, what would I run gradle wrapper on? The extracted ZIP has a bin directory (containing batch/bash scripts) and a lib directory (containing the actual app JAR and all of its JAR lib dependencies)... But there's no java source code here, it's distributed as a compiled/packaged binary.Undervalue
Gradle is only needed to build Lazybones, not to run it.Onfre
Thanks again @Peter Niederwieser (+1) but are you absolutely sure?!? Check out this link from their docs where they show you running Lazybones via ./gradlew installTemplateSimpleJava. So it does look like they are using gradlew to run Lazybones, and it seems this is the only way to do so...Undervalue
Installing a template is not the same as running the tool. See Getting Started for how to bootstrap a Gradle build that allows to install templates. If that Gradle build does not have a gradlew.bat, you can generate one with gradle wrapper.Onfre
What about packaging templates? That's what I really need to be able to do. I am creating a new template and need to use LazyBones to ZIP it up properly.Undervalue
Same thing. Please refer to the documentation.Onfre
Thanks again @Peter Niederwiser (+1) - I'm not trying to be difficult here, but I feel like there's a big disconnect from what you are saying exists in the docs, and what's actually in there. Where in that link (the last one you posted) does it state that you bootstrap a Gradle build to package new templates?Undervalue
Just follow the getting started guide. What's so difficult about this? Quote: "That's why we try to make it as easy as possible to develop and publish templates. This guide explains how to go about both steps. The first thing you want to do is set up a build for your templates."Onfre
I've had the same problem as @IAmYourFaja. For me the disconnect was that (on Windows cmd) e.g., ./gradlew clean, would not run and return bash: .gradlew: command not found. This is despite gradlew.bat in that directory. The secret sauce for me was to run gradle wrapper prior to running any gradlew command.Plush
M
2

just run in the cmd

  • bash ./gradlew test
Mojica answered 11/11, 2018 at 14:44 Comment(0)
G
0

the gradlew command is generated by gradle. run gradle wrapper in the cmd. also the gradlew task should be added in the build.gradle file such as task wrapper(type: Wrapper) { enter code heregradleVersion = '3.1' }

Gaucherie answered 8/2, 2017 at 2:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.