Hello, every one.

I have a problem to add excludes to scala-maven-plugin. There are two scala files:Spark_1.6.1.scala and Spark_2.0.1.scala in src/main/scala/test. I want to exclude Spark_1.6.1.scala when compilation, so I write a pom.xml with the following setups. But it doesn't work.

May I do something incorrectly? How to add excludes correctly ?

在pom.xml文件中,引入scala-maven-plugin,将一部分文件排除编译工作:

scala-maven-plugin不支持完全模式匹配,仅支持/test/scala/和 /main/scala下的模式匹配。故而,在配置文件中需要配置成按包名路径的模式。

Sorry, it was my fault. I didn't realize that /test/ cannot be a part of exclude pattern; patterns only are applied to path inside /test/scala/ or /main/scala. 

<excludes>
<exclude>**/com/excludes_package/**</exclude>
<exclude>**/com/excludes_package/excludes_package_1/**</exclude>
<exclude>**/com/excludes_package/excludes_package_2/**</exclude>
</excludes>

此外incremental模式下貌似不支持excludes,需要注释掉。Java的compiler中也需要加入exclude,否则在build中Java build阶段会报错。

<!-- mixed Java/Scala projects, see https://davidb.github.io/scala-maven-plugin/example_java.html -->
<plugin>
<!-- see http://davidb.github.com/scala-maven-plugin -->
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.2.2</version>
<executions>
<execution>
<id>eclipse-add-source</id>
<goals>
<goal>add-source</goal>
</goals>
</execution>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile-first</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
<execution>
<id>attach-scaladocs</id>
<phase>verify</phase>
<goals>
<goal>doc-jar</goal>
</goals>
</execution>
</executions>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<!-- <recompileMode>incremental</recompileMode> <!-- here -->
<useZincServer>true</useZincServer> -->
<args>
<arg>-unchecked</arg>
<arg>-deprecation</arg>
<arg>-feature</arg>
<arg>-language:postfixOps</arg>
</args>
<jvmArgs>
<jvmArg>-Xms1024m</jvmArg>
<jvmArg>-Xmx1024m</jvmArg>
<jvmArg>-XX:ReservedCodeCacheSize=${CodeCacheSize}</jvmArg>
</jvmArgs>
<javacArgs>
<javacArg>-source</javacArg>
<javacArg>${java.version}</javacArg>
<javacArg>-target</javacArg>
<javacArg>${java.version}</javacArg>
<javacArg>-Xlint:all,-serial,-path</javacArg>
</javacArgs>
<excludes> <!-- here -->
<exclude>**/com/excludes_package/**</exclude>
<exclude>**/com/excludes_package/excludes_package_1/**</exclude>
<exclude>**/com/excludes_package/excludes_package_2/**</exclude>
</excludes>
</configuration>
</plugin>
<!-- This plugin compiles Java files -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<encoding>UTF-8</encoding>
<maxmem>1024m</maxmem>
<fork>true</fork>
<compilerArgs>
<arg>-Xlint:all,-serial,-path</arg>
</compilerArgs>
<excludes> <!-- here -->
<exclude>**/com/excludes_package/**</exclude>
<exclude>**/com/excludes_package/excludes_package_1/**</exclude>
<exclude>**/com/excludes_package/excludes_package_2/**</exclude>
</excludes>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>

经验证:incremental模式下支持excludes,不需要注释掉。

<recompileMode>incremental</recompileMode>

最新文章

  1. XCodeGhost表明:为了安全,开发工具应该从官方网站下载
  2. dsfgsdfg
  3. Codeforces Round #342 (Div. 2) C. K-special Tables 构造
  4. vector C++ 详细用法
  5. Javascript之改变盒子颜色
  6. velocity语法
  7. CodeForce 339:A+B+C
  8. windows环境下nutch2.x 在eclipse中实现抓取数据存进mysql详细步骤
  9. Jquery 对话框确认
  10. 动态规划2-----hdu1069
  11. springmvc 访问时找不到配置文件
  12. selenium+python,解决selenium弹出新页面,无法定位元素的问题(报错:Unable to locate element:元素)
  13. Git原理与命令大全
  14. Elasticsearch.net项目实战
  15. SQL Server数据库————连接查询和分组查询
  16. 修改 jenkins 主目录
  17. 解决和排查 &quot;必须使用适当的属性和方法修改 User-Agent&quot; 错误时遇到的一些坑
  18. SAS DATA步读取数据
  19. windows下搭建Consul分布式系统和集群
  20. Liunx cannot remove `xxx&#39;: Operation not permitted

热门文章

  1. leetcode 566. 重塑矩阵 c++ 实现
  2. 使用wrk进行压力测试
  3. EAS开发报错 :数据库表 或 视图 不存在
  4. PL/SQL学习笔记之日期时间
  5. 关于Jenkins日志爆满的解决方法
  6. mac 使用笔记日志
  7. Android开发导出apk报错:Unable to build: the file dx.jar was not loaded from the SDK folder
  8. Android 看源码学 Binder
  9. Delphi目录监控、目录监听
  10. 修改maven镜像为阿里云,速度快