Gradle script is not compiling java class

128 views
Skip to first unread message

Chandrashekhar Kotekar

unread,
Sep 11, 2013, 9:45:17 AM9/11/13
to cascadi...@googlegroups.com
I am trying to use Cascading in my Hadoop project. I am trying to implement first example given inEnterprise Data Workflows with Cascading book. I have written java class which containsCascading related code and I have another build.graddle file which is supposed to compile that java class and build jar file out of it.

My folder structure is as follows :

  • main_folder

    • impatient

      • Main.java
      • build.gradle

My build.gradle file looks as below :


apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'

archivesBaseName = 'impatient'
repositories {
    mavenLocal()
    mavenCentral()
    mavenRepo name: 'conjars', url: 'http://conjars.org/repo/'
}
ext.cascadingVersion = '2.1.0'
dependencies {
    compile( group: 'cascading', name: 'cascading-core', version: cascadingVersion )
    compile( group: 'cascading', name: 'cascading-hadoop', version: cascadingVersion )
}
jar {
    description = "Assembles a Hadoop ready jar file"
    doFirst {
        into( 'lib' ) {
            from configurations.compile
        }
    }
    manifest {
        attributes( "Main-Class": "impatient/Main" )
    }
}

When I run gradle clean jar command from command prompt, I get build successful message. I tried to run this jar file using

hadoop jar impatient.jar <input file path> <output file path>

command but then it gives me Exception in thread "main" java.lang.ClassNotFoundException: impatient.Main exception.

So I checked contentes of jar file and found that that jar does not contain impatient/Main.class file.

Please note that I do not know anything about gradle.

Request someone to please tell me if there is anything wrong with gradle script or I am making some mistake.

Thanks !!!

Paco Nathan

unread,
Sep 11, 2013, 11:37:15 AM9/11/13
to cascadi...@googlegroups.com
It will probably work best to start out with the GitHub repo used in that part of the book:

Then iterate from that base to try out new code.

In terms of potential issues in your build script, providing a GitHub gist of your build is a good approach, to help others troubleshoot. However, if you're not familiar with Gradle then it's probably best to start with a known working example.

FWIW, admittedly Gradle is not my favorite build system :)



--
You received this message because you are subscribed to the Google Groups "cascading-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cascading-use...@googlegroups.com.
To post to this group, send email to cascadi...@googlegroups.com.
Visit this group at http://groups.google.com/group/cascading-user.
For more options, visit https://groups.google.com/groups/opt_out.

Joe Posner

unread,
Sep 11, 2013, 12:42:13 PM9/11/13
to cascadi...@googlegroups.com
Like Paco mentioned it's easiest to start with cloning the repo and
modifying it from there. Gradle, like Maven, expects a standardized
directory structure and the layout you have doesn't match that
standard.

Chandrashekhar Kotekar

unread,
Sep 11, 2013, 1:12:05 PM9/11/13
to cascadi...@googlegroups.com
@Paco and Joe,

Thanks for your answers. I read more about Gradle and yes, its similar to Maven (which makes me wonder why another build tool? another build tool means one more learning curve and this makes developer's life more difficult).

So I moved my java class inside "src/main/java/impatient" folder and then gradle script worked perfectly. My problem is resolved now. 

Thanks again for answers and your valuable time.


Regards,
Chandrash3khar Kotekar
Mobile - 8884631122


You received this message because you are subscribed to a topic in the Google Groups "cascading-user" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cascading-user/OnI0C9JhfXk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cascading-use...@googlegroups.com.

Chris K Wensel

unread,
Sep 11, 2013, 4:34:11 PM9/11/13
to cascadi...@googlegroups.com
there is no reason you can't use Maven or Ant or Ivy etc for your project.

we use Gradle fwiw.

ckw
Reply all
Reply to author
Forward
0 new messages