Scala 2.12.8 macros with Maven - scala

I'm trying to use Scala Macros with Maven!
I found an old answer on Stackoverflow HERE but seems it doesn't work in my case.
I got an error at compile time even if in my code there isn't any macros!
Searching on google i didn't found a lot documentation about this feature used with maven. Unfortunately we are working on a legacy java project and for this reason we can't migrate to SBT.
I got the following error:
Error:scalac: Error: scala.tools.nsc.typechecker.Namers$Namer.enterDefaultGetters(Lscala/reflect/internal/Symbols$Symbol;Lscala/reflect/internal/Trees$DefDef;Lscala/collection/immutable/List;Lscala/collection/immutable/List;)V
java.lang.NoSuchMethodError: scala.tools.nsc.typechecker.Namers$Namer.enterDefaultGetters(Lscala/reflect/internal/Symbols$Symbol;Lscala/reflect/internal/Trees$DefDef;Lscala/collection/immutable/List;Lscala/collection/immutable/List;)V
at org.scalamacros.paradise.typechecker.Namers$Namer.$anonfun$finishSymbolNotExpandee$1(Namers.scala:282)
at org.scalamacros.paradise.typechecker.Namers$Namer.savingLock$1(Namers.scala:215)
at org.scalamacros.paradise.typechecker.Namers$Namer.finishSymbolNotExpandee(Namers.scala:219)
at org.scalamacros.paradise.typechecker.Namers$Namer.finishSymbolNotExpandee$(Namers.scala:211)
at org.scalamacros.paradise.typechecker.Namers$$anon$1.finishSymbolNotExpandee(Namers.scala:13)
at org.scalamacros.paradise.typechecker.Namers$Namer.finishSymbol(Namers.scala:183)
at org.scalamacros.paradise.typechecker.Namers$Namer.finishSymbol$(Namers.scala:166)
at org.scalamacros.paradise.typechecker.Namers$$anon$1.finishSymbol(Namers.scala:13)
at org.scalamacros.paradise.typechecker.Namers$Namer.dispatch$1(Namers.scala:35)
at org.scalamacros.paradise.typechecker.Namers$Namer.enterSym(Namers.scala:41)
at org.scalamacros.paradise.typechecker.Namers$Namer.enterSym$(Namers.scala:23)
at org.scalamacros.paradise.typechecker.Namers$$anon$1.enterSym(Namers.scala:13)
at org.scalamacros.paradise.typechecker.AnalyzerPlugins$MacroPlugin$.pluginsEnterSym(AnalyzerPlugins.scala:36)
at scala.tools.nsc.typechecker.AnalyzerPlugins$$anon$15.custom(AnalyzerPlugins.scala:461)
at scala.tools.nsc.typechecker.AnalyzerPlugins.$anonfun$invoke$3(AnalyzerPlugins.scala:403)
at scala.tools.nsc.typechecker.AnalyzerPlugins.invoke(AnalyzerPlugins.scala:403)
at scala.tools.nsc.typechecker.AnalyzerPlugins.pluginsEnterSym(AnalyzerPlugins.scala:455)
at scala.tools.nsc.typechecker.AnalyzerPlugins.pluginsEnterSym$(AnalyzerPlugins.scala:453)
at scala.tools.nsc.Global$$anon$1.pluginsEnterSym(Global.scala:458)
at scala.tools.nsc.typechecker.Namers$Namer.enterSym(Namers.scala:261)
at scala.tools.nsc.typechecker.Namers$Namer.enterSyntheticSym(Namers.scala:801)
at scala.tools.nsc.typechecker.Namers$Namer.$anonfun$addCopyMethod$1(Namers.scala:1749)
at scala.tools.nsc.typechecker.Namers$Namer.addCopyMethod(Namers.scala:1749)
at scala.tools.nsc.typechecker.Namers$Namer.$anonfun$templateSig$6(Namers.scala:1168)
at scala.tools.nsc.typechecker.Namers$Namer.templateSig(Namers.scala:1162)
at scala.tools.nsc.typechecker.Namers$Namer.classSig(Namers.scala:1187)
at scala.tools.nsc.typechecker.Namers$Namer.memberSig(Namers.scala:1798)
at scala.tools.nsc.typechecker.Namers$Namer.typeSig(Namers.scala:1761)
at scala.tools.nsc.typechecker.Namers$Namer$MonoTypeCompleter.completeImpl(Namers.scala:840)
at scala.tools.nsc.typechecker.Namers$LockingTypeCompleter.complete(Namers.scala:1958)
at scala.tools.nsc.typechecker.Namers$LockingTypeCompleter.complete$(Namers.scala:1956)
at scala.tools.nsc.typechecker.Namers$TypeCompleterBase.complete(Namers.scala:1951)
at scala.tools.nsc.typechecker.Namers$PolyTypeCompleter.completeImpl(Namers.scala:1991)
at scala.tools.nsc.typechecker.Namers$LockingTypeCompleter.complete(Namers.scala:1958)
at scala.tools.nsc.typechecker.Namers$LockingTypeCompleter.complete$(Namers.scala:1956)
at scala.tools.nsc.typechecker.Namers$PolyTypeCompleter.complete(Namers.scala:1970)
at scala.reflect.internal.Symbols$Symbol.info(Symbols.scala:1530)
at scala.reflect.internal.Symbols$Symbol.initialize(Symbols.scala:1678)
at scala.tools.nsc.typechecker.Typers$Typer.checkNotLocked$1(Typers.scala:306)
at scala.tools.nsc.typechecker.Typers$Typer.checkNonCyclic(Typers.scala:310)
at scala.tools.nsc.typechecker.Typers$Typer.checkNonCyclic(Typers.scala:328)
at scala.tools.nsc.typechecker.Typers$Typer.checkNonCyclic(Typers.scala:338)
at scala.tools.nsc.typechecker.Typers$Typer.typedValDefImpl(Typers.scala:2039)
at scala.tools.nsc.typechecker.Typers$Typer.typedValDef(Typers.scala:2024)
at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5494)
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5546)
at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5584)
at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5616)
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5557)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5562)
at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5647)
at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:3086)
at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$10(Typers.scala:3231)
at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3231)
at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1987)
at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1811)
at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5496)
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5546)
at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5584)
at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5616)
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5557)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5562)
at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5647)
at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:3086)
at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$10(Typers.scala:3231)
at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3231)
at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1987)
at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1811)
at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5496)
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5546)
at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5584)
at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5616)
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5557)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5562)
at scala.tools.nsc.typechecker.Typers$Typer.typedByValueExpr(Typers.scala:5647)
at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:3086)
at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$10(Typers.scala:3231)
at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3231)
at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:5207)
at scala.tools.nsc.typechecker.Typers$Typer.typedMemberDef$1(Typers.scala:5499)
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5546)
at scala.tools.nsc.typechecker.Typers$Typer.runTyper$1(Typers.scala:5584)
at scala.tools.nsc.typechecker.Typers$Typer.typedInternal(Typers.scala:5616)
at scala.tools.nsc.typechecker.Typers$Typer.body$2(Typers.scala:5557)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5562)
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5643)
at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.apply(Analyzer.scala:104)
at scala.tools.nsc.Global$GlobalPhase.$anonfun$applyPhase$1(Global.scala:436)
at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:429)
at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.$anonfun$run$1(Analyzer.scala:94)
at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.$anonfun$run$1$adapted(Analyzer.scala:93)
at scala.collection.Iterator.foreach(Iterator.scala:929)
at scala.collection.Iterator.foreach$(Iterator.scala:929)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1417)
at scala.tools.nsc.typechecker.Analyzer$typerFactory$$anon$3.run(Analyzer.scala:93)
at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1452)
at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1436)
at scala.tools.nsc.Global$Run.compileSources(Global.scala:1429)
at scala.tools.nsc.Global$Run.compile(Global.scala:1545)
at xsbt.CachedCompiler0.run(CompilerInterface.scala:130)
at xsbt.CachedCompiler0.run(CompilerInterface.scala:105)
at xsbt.CompilerInterface.run(CompilerInterface.scala:31)
at sun.reflect.GeneratedMethodAccessor11.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:237)
at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:111)
at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:90)
at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:40)
at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:35)
at org.jetbrains.jps.incremental.scala.remote.Main$.make(Main.scala:83)
at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:26)
at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
at sun.reflect.GeneratedMethodAccessor3.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)
Env:
Scala 2.12.8
JDK 1.8.0_152
POM:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<scala.version>2.12.8</scala.version>
</properties>
<repositories>
<repository>
<id>oss.sonatype.org</id>
<name>sonatype sapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-reflect</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>2.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.12</artifactId>
<version>3.0.7</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.4.6</version>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<args>
<arg>-target:jvm-1.8</arg>
<arg>-Xlint</arg>
<arg>-deprecation</arg>
<arg>-unchecked</arg>
<arg>-feature</arg>
<arg>-language:postfixOps</arg>
<arg>-language:implicitConversions</arg>
<arg>-language:higherKinds</arg>
<arg>-Xfatal-warnings</arg>
<arg>-Ywarn-unused-import</arg>
<arg>-Ywarn-inaccessible</arg>
<arg>-Ywarn-dead-code</arg>
<arg>-Ypartial-unification</arg>
</args>
<compilerPlugins>
<compilerPlugin>
<groupId>org.scala-lang.plugins</groupId>
<artifactId>macro-paradise_${scala.version}</artifactId>
<version>2.1.1</version>
</compilerPlugin>
</compilerPlugins>
</configuration>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Thanks for the support.

Try
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>scala_macros_maven_demo</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<properties>
<scala.version>2.12.8</scala.version>
<!-- <scala.version>2.13.0</scala.version>-->
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
</dependencies>
<modules>
<module>core</module>
<module>macros</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>4.1.0</version>
<configuration>
<!-- for Scala 2.12.8 -->
<compilerPlugins>
<!-- <compilerPlugin>-->
<!-- <groupId>org.scalamacros</groupId>-->
<!-- <artifactId>paradise_${scala.version}</artifactId>-->
<!-- <version>2.1.1</version>-->
<!-- </compilerPlugin>-->
<compilerPlugin>
<groupId>org.scalameta</groupId>
<artifactId>paradise_${scala.version}</artifactId>
<version>3.0.0-M11</version>
</compilerPlugin>
</compilerPlugins>
<!-- for Scala 2.13.0 -->
<!-- <args>-->
<!-- <arg>-Ymacro-annotations</arg>-->
<!-- </args>-->
</configuration>
</plugin>
</plugins>
</build>
</project>
macros/pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>scala_macros_maven_demo</artifactId>
<groupId>com.example</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>macros</artifactId>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-reflect</artifactId>
<version>${scala.version}</version>
</dependency>
</dependencies>
</project>
core/pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>scala_macros_maven_demo</artifactId>
<groupId>com.example</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>core</artifactId>
<dependencies>
<dependency>
<artifactId>macros</artifactId>
<groupId>com.example</groupId>
<version>1.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<configuration>
<launchers>
<launcher>
<id>launcher1</id>
<mainClass>com.example.App</mainClass>
</launcher>
</launchers>
</configuration>
</plugin>
</plugins>
</build>
</project>

Related

Spark Maven Project not running

I have recently downloaded Scala IDE for Eclipse for Spark/Scala project. For that, I have created a Maven project & added Spark-core dependencies. I then wrote a basic Spark code to create an RDD out of array & finally collect it. Upon running the code, it is giving me the error "java.lang.NoClassDefFoundError: com/fasterxml/jackson/module/paranamer/ParanamerAnnotationIntrospector" on the console.
Spark Code :
import org.apache.spark.SparkConf
import org.apache.spark.SparkContext
object Test {
def main(args : Array[String]) : Unit = {
println("Begining of the code")
val sparkConf = new SparkConf()
sparkConf.setAppName("New app")
sparkConf.setMaster("local")
val sc = new SparkContext(sparkConf)
val array = Array(1,2,3,4,5)
val arrayRDD = sc.parallelize(array, 2)
arrayRDD.collect
println("Ending of the code")
}
}
Maven Dependency :
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.talentorigin</groupId>
<artifactId>SparkCourse</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-core -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.12</artifactId>
<version>2.4.3</version>
</dependency>
</dependencies>
</project>
Console Error :
Exception in thread "main" java.lang.NoClassDefFoundError: com/fasterxml/jackson/module/paranamer/ParanamerAnnotationIntrospector
at org.apache.spark.rdd.RDDOperationScope$.<init>(RDDOperationScope.scala:82)
at org.apache.spark.rdd.RDDOperationScope$.<clinit>(RDDOperationScope.scala)
at org.apache.spark.SparkContext.withScope(SparkContext.scala:699)
at org.apache.spark.SparkContext.parallelize(SparkContext.scala:716)
at Test$.main(Test.scala:17)
at Test.main(Test.scala)
Caused by: java.lang.ClassNotFoundException: com.fasterxml.jackson.module.paranamer.ParanamerAnnotationIntrospector
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more
Problem Tag of Eclipse :
Failure to transfer com.fasterxml.jackson.module:jackson-module-paranamer:jar:2.7.9 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
Failure to transfer net.sf.py4j:py4j:jar:0.10.7 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced.
Missing artifact com.fasterxml.jackson.module:jackson-module-paranamer:jar:2.7.9
Missing artifact net.sf.py4j:py4j:jar:0.10.7
The container 'Maven Dependencies' references non existing library 'C:\Users\AniRudh\.m2\repository\com\fasterxml\jackson\module\jackson-module-paranamer\2.7.9\jackson-module-paranamer-2.7.9.jar'
I am a beginner in working with Maven.
Kindly help me resolving this issue.
I am sharing the complete pom file. You can update your pom file accordingly.
Include the following for the build to work:
Dependencies spark, scala others
Plugins
Sample spark-scala-maven project template Github link
Here is the complete pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.techknowera</groupId>
<artifactId>spark-batch</artifactId>
<version>1.0-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>Spark Batch And Streaming Application</description>
<inceptionYear>2019</inceptionYear>
<properties>
<scala.version>2.11</scala.version>
<scala.full.version>2.11.8</scala.full.version>
<spark.version>2.2.0</spark.version>
<java.version>1.8</java.version>
<jackson.version>2.6.5</jackson.version>
<scala.maven.plugin.version>3.2.2</scala.maven.plugin.version>
<maven.surefire.plugin.version>2.13</maven.surefire.plugin.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!--Scala dependencies-->
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.full.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.scalatest/scalatest -->
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_${scala.version}</artifactId>
<version>3.0.5</version>
</dependency>
<!--Apache Spark Dependencies-->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_${scala.version}</artifactId>
<version>${spark.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-sql -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-sql_${scala.version}</artifactId>
<version>${spark.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-hive -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-hive_${scala.version}</artifactId>
<version>${spark.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-yarn -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-yarn_${scala.version}</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>com.typesafe</groupId>
<artifactId>config</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>com.databricks</groupId>
<artifactId>spark-xml_${scala.version}</artifactId>
<version>0.4.1</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>
<!-- disable surefire -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.7</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<!-- enable scala test -->
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>2.0.0</version>
<configuration>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<junitxml>.</junitxml>
<filereports>TestSuite.txt</filereports>
</configuration>
<executions>
<execution>
<id>test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Antlr4 grammar, Eclipse and Maven. Cannot see generated classes on my code

Eclipse Oxygen.3a Release 4.7.3a
Maven
I have a project, with a lot of classes.
I tried to create an Antlr4 grammar, so I have my .g4 file on src/main/java/antlr4/mygrammar.g4.
Antlr4 does not generate generate anything.
My pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>wiz</groupId>
<artifactId>calculo</artifactId>
<version>0.0.1</version>
<name>calculo</name>
<description>Cálculo do Sistema de Folha de Pagamento</description>
<scm>
<connection>scm:git:https://github.com/zsoltherpai/fluent-jdbc.git</connection>
<developerConnection>scm:git:git#github.com:zsoltherpai/fluent-jdbc.git</developerConnection>
<url>https://github.com/zsoltherpai/fluent-jdbc</url>
</scm>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.codejargon</groupId>
<artifactId>fluentjdbc</artifactId>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4</artifactId>
<version>4.7.1</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>4.7.1</version>
<executions>
<execution>
<id>antlr</id>
<goals>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
What am I missing? Do I need to invoke manually something?
I have my .g4 file on src/main/java/antlr4/mygrammar.g4.
The ANTLR4 maven plug-in expects the grammars to be in src/main/antlr4, not src/main/java/antlr4.

Maven test doesn't run tests

I have a Scala project where I replaced SBT with maven.
I have the following pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>myProjectName</groupId>
<artifactId>my.package.myProjectName</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name></name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.apache.spark/spark-core_2.10 -->
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>1.6.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.scalatest/scalatest_2.11 -->
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.11</artifactId>
<version>3.0.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-testkit_2.11 -->
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-testkit_2.11</artifactId>
<version>2.4.14</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.typesafe.akka/akka-http-testkit_2.11 -->
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-http-testkit_2.11</artifactId>
<version>10.0.0</version>
</dependency>
</dependencies>
</project>
For clarity, I removed some of the dependencies in the text above.
The problem is that when I run mvn test none of my tests are executed.
The tests are located under src/test/scala/my/package.
They don't contain test in their names, but even if I add Test at the end of their names, they aren't run.
To compile and test scala sources you should add the scala-maven-plugin to your build.
<project>
...
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
...
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<!-- explicit scala version not recommended-->
<!-- usually inferred from scala-library dependency-->
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>
</plugins>
</build>
</project>

Casbah Maven dependency FAILS in Eclipse Scala-IDE?

I am trying to use Casbah - Scala toolkit for MonfoDB in Eclipse Scala-IDE Maven project.
Maven fails at Casbah dependency with the following errors:
Missing artifact com.mongodb.casbah:casbah_2.10.0:pom:2.5.0 pom.xml
Please help to fix this. What is wrong with this artifact? Why this artifact is missing? Should I add dependencies that Casbah itself depends on, such as MongoDB Java driver? My pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>scalamongo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>${project.artifactId}</name>
<description>My wonderfull scala app</description>
<inceptionYear>2010</inceptionYear>
<licenses>
<license>
<name>My License</name>
<url>http://....</url>
<distribution>repo</distribution>
</license>
</licenses>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<encoding>UTF-8</encoding>
<scala.tools.version>2.10</scala.tools.version>
<scala.version>2.10.0</scala.version>
</properties>
<dependencies>
<dependency>
<groupId>com.mongodb.casbah</groupId>
<artifactId>casbah_2.10.0</artifactId>
<version>2.5.0</version>
<scope>compile</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.specs2</groupId>
<artifactId>specs2_${scala.tools.version}</artifactId>
<version>1.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_${scala.tools.version}</artifactId>
<version>2.0.M6-SNAP8</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<!-- see http://davidb.github.com/scala-maven-plugin -->
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.1.3</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<args>
<arg>-make:transitive</arg>
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.13</version>
<configuration>
<useFile>false</useFile>
<disableXmlReport>true</disableXmlReport>
<!-- If you have classpath issue like NoDefClassError,... -->
<!-- useManifestOnlyJar>false</useManifestOnlyJar -->
<includes>
<include>**/*Test.*</include>
<include>**/*Suite.*</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
</project>
Just discovered that the following dependency works for Casbah:
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>casbah-core_2.10</artifactId>
<version>2.5.0</version>
</dependency>

Maven GWT (SmartGWT): How to organize my project to prevent long compilation

Dear StackOverflow Users,
I want to split my huge application written in SmartGWT, compiled by maven, into several subprojects, for example: common, custom-widgets, forms, custom-datasources, sites.
The main idea is: once subproject is compilated by GWT can be easy used in other sub-project to skip compilation again. (sorry for my english, but I think You got my point)
example subproject pom.xml is:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>eu.nanobeauty</groupId>
<artifactId>nanobeauty</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>common</artifactId>
<packaging>jar</packaging>
<name>nanoBeauty :: Common</name>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.version}</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Common.gwt.xml is :
<module>
<inherits name="com.google.gwt.user.User"/>
<inherits name="com.smartgwt.SmartGwtNoTheme"/>
<source path="common"/>
</module>
and the parent pom.xml is:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>eu.nanobeauty</groupId>
<artifactId>nanobeauty</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>nanoBeauty :: Parent</name>
<modules>
<module>datasources</module>
<!-- multimodule : each form different project -->
<module>forms</module>
<!-- multimodule : each site different project -->
<module>sites</module>
<module>common</module>
</modules>
<properties>
<gwt.version>2.5.0</gwt.version>
<smartgwt.version>3.1</smartgwt.version>
<java.version>1.6</java.version>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.war.plugin.version>2.1.1</maven.war.plugin.version>
</properties>
<repositories>
<repository>
<id>smartclient</id>
<url>http://smartclient.com/maven2</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.smartgwt</groupId>
<artifactId>smartgwt</artifactId>
<version>${smartgwt.version}</version>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId>
<version>${gwt.version}</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
After long night googling i found solution:
It cannot be done this way I want to achieve.
GWT needs source files to generate JS files. Main module pom.xml is ok and example .gwt.xml file above is also ok. Only change is in sub-module pom.xml files only goal is resources.
So for every submodule I need to setup pom.xml that looks like similar to:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>eu.nanobeauty</groupId>
<artifactId>nanobeauty</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>common</artifactId>
<packaging>jar</packaging>
<name>nanoBeauty :: Common</name>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt.version}</version>
<executions>
<execution>
<goals>
<goal>resources</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Based on this documents:
Resources goal
Multimodule project