maven混合编译java&scala

步骤:

1. mvn 生成scala项目
mvn archetype:generate \
-DarchetypeGroupId=org.scala-tools.archetypes \
-DarchetypeArtifactId=scala-archetype-simple \
-DremoteRepositories=http://scala-tools.org/repo-releases
或 参考 笔记 《Idea+Maven创建scala项目》

2.添加java目录,添加完后,在IDEA中目录结构如下:
maven混合编译java&scala_第1张图片

3.修改pom.xml文件
删除:
maven混合编译java&scala_第2张图片
下增加maven插件:

org.codehaus.mojo
build-helper-maven-plugin
1.9.1

4.直接使用package打包,打包结果如下图:
maven混合编译java&scala_第3张图片

5.pom.xml文件示例:
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" >
4.0.0
com.tcl.bigdata.yhb
java-scala-practice
1.0-SNAPSHOT
${project.artifactId}
My wonderfull scala app
2010

2.10.4
1.4.1
2.2.0
0.98.7-hadoop2




scala-tools.org
Scala-Tools Maven2 Repository
http://scala-tools.org/repo-releases





org.apache.hbase
hbase-client
${hbase.version}


com.google.guava
guava


io.netty
netty




org.apache.hbase
hbase-server
${hbase.version}


org.mortbay.jetty
servlet-api-2.5


com.sun.jersey
jersey-core


com.sun.jersey
jersey-server




org.scala-lang
scala-library
${scala.version}


junit
junit
4.4
test


org.specs
specs
1.2.5
test


org.apache.spark
spark-core_2.10
${spark.version}


hadoop-client
org.apache.hadoop


hadoop-core
org.apache.hadoop


guava
com.google.guava




org.apache.spark
spark-sql_2.10
${spark.version}


org.apache.spark
spark-hive_2.10
${spark.version}


org.apache.spark
spark-mllib_2.10
${spark.version}


org.apache.hadoop
hadoop-client
${hadoop.version}


guava
com.google.guava




org.apache.hadoop
hadoop-common
${hadoop.version}


guava
com.google.guava




mysql
mysql-connector-java
5.1.37


com.google.guava
guava
14.0.1






org.scala-tools
maven-scala-plugin



compile
testCompile




${scala.version}

-target:jvm-1.7




org.apache.maven.plugins
maven-eclipse-plugin

true

ch.epfl.lamp.sdt.core.scalabuilder


ch.epfl.lamp.sdt.core.scalanature


org.eclipse.jdt.launching.JRE_CONTAINER
ch.epfl.lamp.sdt.launching.SCALA_CONTAINER




org.codehaus.mojo
build-helper-maven-plugin
1.9.1






org.scala-tools
maven-scala-plugin

${scala.version}






你可能感兴趣的:(编译工具)