Building Java projects

A quick start document for Java projects


//following is wrong
some-var

//use
someVar

//This is correct
ext {
 hadoopgroup = 'org.apache.hadoop'
 hadoopname = 'hadoop-core'
 hadoopversion = '1.2.1'
 
 hadoopdependency="${hadoopgroup}:${hadoopname}:${hadoopversion}"
 guavadependency= 'com.google.guava:guava:27.0.1-jre'
}

//This is wrong
ext {
 hadoopgroup = 'org.apache.hadoop'
 hadoopname = 'hadoop-core'
 hadoopversion = '1.2.1'
 
 hadoopdependency="$(hadoopgroup):$(hadoopname):$(hadoopversion)"
 guavadependency= 'com.google.guava:guava:27.0.1-jre'
}

Notice the "()" vs "{}"

How do I start a build using gradle plugin in eclipse?

Search for: How do I start a build using gradle plugin in eclipse?


Go to Gradle tasks tab near the console
Locate build
Locate the assemble task
right click
Run the task

> Task :compileJava
> Task :processResources NO-SOURCE
> Task :classes
> Task :jar
> Task :assemble

BUILD SUCCESSFUL in 3s
3 actionable tasks: 3 executed

plugins {
    id 'java'
}

ext {
 hadoopgroup = 'org.apache.hadoop'
 hadoopname = 'hadoop-core'
 hadoopversion = '1.2.1'
 
 hadoopdependency="${hadoopgroup}:${hadoopname}:${hadoopversion}"
 guavadependency= 'com.google.guava:guava:27.0.1-jre'
}

repositories {
    jcenter()
}

dependencies {
    //implementation '$(hadoop-dependency);$(guava-dependency)'

    // Use JUnit test framework
    //testImplementation 'junit:junit:4.12'
}

task testTask {
   println 'test task configuration'
   println hadoopdependency
   println tasks
   doLast {
      println 'test task execution. changed';
   }
}


assemble {
 dependsOn testTask
}

//correct, assuming hadoopdependency is initialized as a string
implementation hadoopdependency

//this is equivalent to
implementation(hadoopdependency)

//wrong
implementation '${hadoopdependency}'

//May the $ sign is valid only in string initializaitons

Wonder where Gradle keeps the downloaded dependency jar files

Search for: Wonder where Gradle keeps the downloaded dependency jar files

Here is an overview of using the Gradle Plugin: Vogella.com

What is Refresh Gradle Project in eclipse?

Search for: What is Refresh Gradle Project in eclipse?

Right click and look for this menu item under "Gradle"

This menu item will, not sure what else it does, but will download the dependencies into the Gradle installation cache directory and attaches them as external libraries to the eclipse project.


/srs/main/java
..../com.ai.learning.bigdata.mapreduce

Next question comes where and what are the output directories for java gradle plugin

Search for: Next question comes where and what are the output directories for java gradle plugin

Javaplugin is again for a quick ref is here

Here is another key read for building java projects

what is $buildDir in gradle?

Search for: what is $buildDir in gradle?

Interesting that definition is sitting on the Project class. See the docs here


projectDir/build

You have to press F5 to refresh the eclipse IDE to see the build directory gone.


plugins {
    id 'java'
}

ext {
 hadoopgroup = 'org.apache.hadoop'
 hadoopname = 'hadoop-core'
 hadoopversion = '1.2.1'
 
 hadoopdependency="${hadoopgroup}:${hadoopname}:${hadoopversion}"
}

repositories {
    jcenter()
}
dependencies {
    implementation hadoopdependency
}
task testTask {
   println 'test task configuration'
   println hadoopdependency
   println tasks
   doLast {
      println 'test task execution. changed';
   }
}


assemble {
 dependsOn testTask
}

There are some testing lines in there. the testTask for example. You can delete that.

Here is the MapReduce on GitHub

is there a way to run MapReduce in Eclipse without installing HadoopCore?

Search for: is there a way to run MapReduce in Eclipse without installing HadoopCore?