Divije Narasimhachar
Divije Narasimhachar

Reputation: 379

Gradle build throwing error

I have created a sample gradle project on intellij.

I go to the project root folder and execute the following:

./gradlew installDist

I am getting this error:

FAILURE: Build failed with an exception.

  • What went wrong: Task 'installDist' not found in root project 'HelloWorld'.

  • Try: Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

    BUILD FAILED

Please please let me know the resolution for this. I have spent one hour on this with no resolution.

Upvotes: 1

Views: 7569

Answers (2)

wangsir
wangsir

Reputation: 382

I had the same problem with springboot application.Then i saw there is no install dir under build.

Then add id 'application' to build.gradle--plugs, it worked well.

This problem shows we dont know gradle no doubt.

Upvotes: 1

Roman Gordeev
Roman Gordeev

Reputation: 81

If you are going to try a gradle with a sample project, the best way to do it - not to use any IDE at all. First of all create a directory for your project and make it as a current directory by doing so

mkdir myapp
cd myapp

Then check if gradle is in your PATH by

gradle -v

You should see something like this

Gradle 2.12

Now you are ready to create your first gradle build script. You may do it in vim editor or what ever you want.

vim build.gradle

And just copy and paste following code in your build.gradle file

apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    testCompile 'junit:junit:4.11'
}

So you may try do build the empty project

gradle build

also you may want to add gradle wrapper

gradle wrapper

this command will add gradlw scripts and gradledirectory with wrapper binaries.

So you are ready to add the java code to your project. You should create folders defined in java-project layout

mkdir src
mkdir src/main
mkdir src/main/java
mkdir src/test
mkdir src/test/java

As a result you will get

myapp  # project root folder
└── src
    ├── main
    │   └── java        
    └── test
        └── java

And then just import this project in your IDE.

Upvotes: 1

Related Questions