scala-maven-plugin excludes
Posted 苏轶然
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了scala-maven-plugin excludes相关的知识,希望对你有一定的参考价值。
<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>
以上是关于scala-maven-plugin excludes的主要内容,如果未能解决你的问题,请参考以下文章
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下的模式匹配。故而,在配置文件中需要配置成按包名路径的模式。