Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Adding Dependencies

Thomas Williams
Thomas Williams
9,447 Points

No gradlew file

No gradlew file is shown in my project window and in the terminal this seems to be confirmed with a 'No such file or directory' message on the ./gradlew command. Any ideas on why I have no gradlew file? Many thanks in advance.

Thomas Williams
Thomas Williams
9,447 Points

On creating the project I definitely had 'use default gradle wrapper' selected but there was an additional tick box before it which does not show in the video - 'create separate module per source set' which was ticked by default so i left it ticked. Not sure if this is related.

3 Answers

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

I agreed with you on previous question about Spark.

However I cannot reproduce gradlew absence problem. I tried many times and it appears always.

Sometimes you have to wait some seconds before it appears, but anyway it appears.

And this time it does not matter what ticks you mark or not.

And Judging by your other post, you've got the problem resolved, right ?

I was able to reproduce the gradlew absence problem. I am on a Window 10 PC not a MacOS, I have just started using IntelliJ and installed the Gradle Project, from course: https://teamtreehouse.com/library/adding-dependencies

Below: Microsoft Windows [Version 10.0.14393] (c) 2016 Microsoft Corporation. All rights reserved.

C:\Users\Owner\IdeaProjects\reviews>./gradlew '.' is not recognized as an internal or external command, operable program or batch file.

C:\Users\Owner\IdeaProjects\reviews>

Also note that there is NO $ sign in typing ./gradlew

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

Well on Windows we should run gradlew.bat file I believe, if you want to run gradle wrapper from project directory.

Because ./gradlew file is a Bash script for Unix-like systems, i.e. Mac and Linux.

So you have to open 'Command Prompt', get to project directory, and run gradlew.bat.

I don't have windows unfortunately.

And as far as I know we run commands with dot slash like ./gradlew ONLY in Unix-Like systems, because by default current directory is not in $PATH. (see this stack post for more if you want)

So all you have to do is in your command prompt run

C:\Users\Owner\IdeaProjects\reviews> gradlew.bat dependencies

Should work.

The other question would be : Do you see at all gradlew.bat file in explorer view in Intellijdea, like Craig does?

If you do, then file definitely should be there, and you have to post me a screenshot here of both your Command Prompt and Inteliijdea opened, to try to debug problem.

Thank you. Your solution worked!

Microsoft Windows [Version 10.0.14393] (c) 2016 Microsoft Corporation. All rights reserved.

C:\Users\Owner\IdeaProjects\reviews> gradlew.bat dependencies :dependencies


Root project

archives - Configuration for archive artifacts. No dependencies

compile - Dependencies for source set 'main'. --- org.apache.commons:commons-csv:1.3

compileClasspath - Compile classpath for source set 'main'. --- org.apache.commons:commons-csv:1.3

compileOnly - Compile dependencies for source set 'main'. --- org.apache.commons:commons-csv:1.3

default - Configuration for default artifacts. --- org.apache.commons:commons-csv:1.3

runtime - Runtime dependencies for source set 'main'. --- org.apache.commons:commons-csv:1.3

testCompile - Dependencies for source set 'test'. +--- org.apache.commons:commons-csv:1.3 --- junit:junit:4.11 --- org.hamcrest:hamcrest-core:1.3

testCompileClasspath - Compile classpath for source set 'test'. +--- org.apache.commons:commons-csv:1.3 --- junit:junit:4.11 --- org.hamcrest:hamcrest-core:1.3

testCompileOnly - Compile dependencies for source set 'test'. +--- org.apache.commons:commons-csv:1.3 --- junit:junit:4.11 --- org.hamcrest:hamcrest-core:1.3

testRuntime - Runtime dependencies for source set 'test'. +--- org.apache.commons:commons-csv:1.3 --- junit:junit:4.11 --- org.hamcrest:hamcrest-core:1.3

BUILD SUCCESSFUL

Total time: 2.861 secs C:\Users\Owner\IdeaProjects\reviews>

My problem was that gradle itself wasn't installed:

If you don't have homebrew:

xcode-select --install
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew doctor
brew install caskroom/cask/brew-cask

Then you can use brew to install gradle and create the gradlew file:

brew install gradle
gradle test
gradle wrapper