I am currently dealing with a project mixing both Java and Scala (Spark). And as if this was not enough, some of my dependencies import another versions of Spark and Scala (not retro-compatible)...
To sum up, here is what my dependency tree might look like:
myProjectA
\_ myLibB
| \_ spark 1.5.2 (excluded in my pom.xml)
| \_ scala 2.10.4 (excluded in my pom.xml)
\_ spark 2.2.0 (with Scala 2.11)
| \_ scala 2.11.7
\_ scala 2.11.11
\_ java 8
After one small modification on a map inside my project the compilation doesn't work anymore... FYI, the modification consisted in adding an element in a hard-coded map.
Hence, I am looking for a solution to compile my project. I am currently using this build configuration:
<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>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
I realized that this other configuration seems to work just fine even after the change that made the previous configuration bug (I replaced the scala-maven-plugin
with the maven-compiler-plugin
):
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Two questions:
- what is the difference between maven-compiler-plugin
and scala-maven-plugin
?
- can maven-compiler-plugin
compile efficiently Scala code/mixed Java-Scala code?