groovy hadoop jar with gradle - package not exist error
<p>I was trying to create a groovy jar with Gradle 2.12 . The groovy file has import statements as below and I put this file in <code>src/main/groovy</code></p>

<p>The first two import are java files, which inturn have <code>org.apache.hadoop</code> imports statements. I put these two files in <code>src/main/java</code></p>

<pre><code>import StartsWithCountMapper
import StartsWithCountReducer
import org.apache.hadoop.conf.Configured
import org.apache.hadoop.fs.Path
import org.apache.hadoop.io.IntWritable
import org.apache.hadoop.io.LongWritable
import org.apache.hadoop.io.Text
import org.apache.hadoop.mapreduce.Job
import org.apache.hadoop.mapreduce.Mapper
import org.apache.hadoop.mapreduce.Reducer
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat
import org.apache.hadoop.util.Tool
import org.apache.hadoop.util.ToolRunner
</code></pre>

<p>And below is my build.gradle file (using <a href="https://stackoverflow.com/questions/9749032/create-a-groovy-executable-jar-with-gradle">this</a>)</p>

<pre><code>apply plugin: 'groovy'
apply plugin: 'application'
version = '1.0'
mainClassName='CountGroovyJob'

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.0.0'
    compile 'org.apache.hadoop:hadoop-common:2.7.1'

}

task Createjar(type: Jar,dependsOn:[':compileJava',':compileGroovy']) {
    from files(sourceSets.main.output.classesDir)
    from configurations.runtime.asFileTree.files.collect { zipTree(it) }

    manifest {
        attributes 'Main-Class': mainClassName
    }
}
</code></pre>

<p>I have tried to compile with below also, by putting them in dependencies</p>

<pre><code>     compile 'org.apache.hadoop:hadoop-client:2.0.0-mr1-cdh4.0.1'
    compile 'org.apache.hadoop:hadoop-core:1.2.1'
    compile 'org.apache.hadoop:hadoop-hdfs:2.7.1'
</code></pre>

<p>but I keep on receiving this error: </p>

<pre><code>/Users/../../../gradle/buildSrc/src/main/java/StartsWithCountMapper.java:5: error: package org.apache.hadoop.io does not exist
import org.apache.hadoop.io.IntWritable;
                           ^
/Users/../../../gradle/buildSrc/src/main/java/StartsWithCountMapper.java:6: error: package org.apache.hadoop.io does not exist
import org.apache.hadoop.io.LongWritable;
                           ^
/Users/../../../gradle/buildSrc/src/main/java/StartsWithCountMapper.java:7: error: package org.apache.hadoop.io does not exist
import org.apache.hadoop.io.Text;
</code></pre>

<p>how can I compile and create a jar with all those import statements in groovy and java files?</p>

<p><strong>EDIT</strong>
to include buildscrip{}</p>

<pre><code>apply plugin: 'groovy'
apply plugin: 'application'
version = '1.0'
mainClassName='CountGroovyJob'

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.codehaus.groovy:groovy-all:2.0.0'
    compile 'org.apache.hadoop:hadoop-common:2.7.1'

}

task Createjar(type: Jar,dependsOn:[':compileJava',':compileGroovy']) {
    from files(sourceSets.main.output.classesDir)
    from configurations.runtime.asFileTree.files.collect { zipTree(it) }

    manifest {
        attributes 'Main-Class': mainClassName
    }
}

buildscript{
    repositories {
        mavenCentral()
    }

    dependencies {
        compile 'org.codehaus.groovy:groovy-all:2.0.0'
        compile 'org.apache.hadoop:hadoop-common:2.7.1'
    }
}
</code></pre>

<p>folder structure :</p>

<pre><code> grad-proj
 |
 +-- build.gradle
 |    
 +-- src
    |  
    +-- main
       |
       +-- groovy
       |
       +-- java
</code></pre>