Maven Intro

  1. I went through a maven example using this git repo on Ubuntu 16.04 https://github.com/LableOrg/java-maven-junit-helloworld

  2. Just clone the repo and go to directory where pom.xml is located
  3. To compile
    mvn compile
    
  4. To run compiled stuff
mvn exec:java -Dexec.mainClass="com.example.javamavenjunithelloworld.Hello"
mvn exec:java -Dexec.mainClass="com.example.javamavenjunithelloworld.HelloApp"
  1. MAVEN INTRO - packaging vs compiling vs ..
  2. Source and Target setup for MAVEN

JAVA building running and all other devops stuff

  1. JAVAC with depency
  2. JAR file
  3. CLASSPATHS IN JAVA

JAR

RUNTIME dependency management (assuming maven)

  • I created a fat jar from project and a non-fat jar (-> THE part which i modify). This allows me to have a very quickly packaged part for my own source code which has all the dependencys easily set out using maven. This solution comes from the fact that simply downloading all the jars using command:
     mvn dependency:copy-dependencies
    

    did not work likely due to some library ordering issuexs.

  • thus I this example pom for fat jar creation which I next included in my thin jars. The thin jars were built without adding extra libras like the second code snippet will show ~~~
4.0.0 org.apache.maven.plugins maven-shade-plugin 1.3.1 package shade MainClass *:* META-INF/*.SF META-INF/*.DSA META-INF/*.RSA org.apache.maven.plugins maven-compiler-plugin 1.8</source> 1.8 antsnamm spark-getting-started 1.0-SNAPSHOT 1.8 1.8 cloudera-repos Cloudera Repos https://repository.cloudera.com/artifactory/cloudera-repos/ maven-hadoop Hadoop Releases https://repository.cloudera.com/content/repositories/releases/ org.apache.spark spark-core_2.11 2.2.0.cloudera2 org.apache.spark spark-sql_2.11 2.2.0.cloudera2 args4j args4j 2.0.29
+ thin jar
4.0.0 antsnamm spark-getting-started 1.0-SNAPSHOT 1.8 1.8 cloudera-repos Cloudera Repos https://repository.cloudera.com/artifactory/cloudera-repos/ maven-hadoop Hadoop Releases https://repository.cloudera.com/content/repositories/releases/ org.apache.spark spark-core_2.11 2.2.0.cloudera2 org.apache.spark spark-sql_2.11 2.2.0.cloudera2 args4j args4j 2.0.29

~~~

  • I also had some issues when creating fat jars using the shaders plugin. Solution is available here as the second answer