How to configure gradle with testng, package already imported but getting error?
<p>I am newbie towards Gradle. I am able to run my test cases through testng but unable to run with Gradle from eclipse.</p>

<p>Following is the <strong>build.gradle</strong></p>

<pre><code>apply plugin: 'java'

apply plugin: 'eclipse'

group = 'selenium.webdriver.qa'

repositories {
    // Use 'jcenter' for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

dependencies {
    // The production code uses the SLF4J logging API at compile time
    compile 'org.slf4j:slf4j-api:1.7.21'

testCompile 'junit:junit:4.12'

repositories {
    mavenCentral()
}

dependencies {
    testCompile 'org.testng:testng:6.9.4'
    compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '2.+'
    compile group: 'org.seleniumhq.selenium', name: 'selenium-server', version: '2.+'
    compile group: 'junit', name: 'junit', version: '4.+'
    compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.+'
    compile group: 'ch.qos.logback', name: 'logback-core', version: '1.0.+'
    compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.0.+'
}

test {
    useTestNG(){
        include "com.mca.automation.script.SanityTestScript"
    }
}

test.testLogging {
    showStandardStreams = true
}
</code></pre>

<p>When i run the test class. It shows following error:</p>

<pre><code>D:\Project\SanityTestScript.java:4: error: package org.testng does not exist
import org.testng.Assert;
                 ^
D:\Project\SanityTestScript.java:5: error: package org.testng.annotations does not exist
import org.testng.annotations.AfterTest;
                             ^
D:\Project\SanityTestScript.java:6: error: package org.testng.annotations does not exist
import org.testng.annotations.BeforeTest;
                             ^
D:\Project\SanityTestScript.java:7: error: package org.testng.annotations does not exist
import org.testng.annotations.Test;
                             ^
D:\Project\SanityTestScript.java:18: error: cannot find symbol
    @BeforeTest
     ^
  symbol:   class BeforeTest
  location: class MCA_SanityTestScript
D:\Project\SanityTestScript.java:24: error: cannot find symbol
    @Test
     ^
  symbol:   class Test
  location: class MCA_SanityTestScript
D:\Project\SanityTestScript.java:51: error: cannot find symbol
    @AfterTest
     ^
  symbol:   class AfterTest
  location: class MCA_SanityTestScript
D:\Project\SanityTestScript.java:48: error: cannot find symbol
        Assert.assertTrue(expEvent.equalsOnActiveUntilDate(actualEvent));
        ^
  symbol:   variable Assert
  location: class SanityTestScript
8 errors
 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
&gt; Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
</code></pre>

<p>I am not able to understand, exactly what i am doing wrong. Even the testng package is already imported. Using Eclipse, so testng library added to project.</p>