使用maven-scala-plugin指定Scalac编译时选项 [英] Specifying Scalac Compile-Time Option with maven-scala-plugin

查看:123
本文介绍了使用maven-scala-plugin指定Scalac编译时选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用maven-scala-plugin 2.15.2,我试图将Scala类文件的最大长度指定为"50"个字符.我在pom.xml中尝试了2个地方:

Using the maven-scala-plugin 2.15.2, I'm trying to specify the max length of a Scala Class File to "50" characters. I tried 2 places in my pom.xml:

    <build>
            <plugins>
                <plugin>
                    <groupId>org.scala-tools</groupId>
                    <artifactId>maven-scala-plugin</artifactId>
                    <version>2.15.2</version>
                    <executions>
                        <execution>
                            <id>scala-compile-first</id>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                            <phase>process-resources</phase>
                            <configuration>
                                <scalacArgs>   <-- Attempt #1 -->
                                    <scalacArg>-Xmax-classfile-name 50</scalacArg> 
                                </scalacArgs> 
                                <scalaVersion>${scalaVer}</scalaVersion>
                                <args>
                                    <arg>-make:transitive</arg>
                                    <arg>-dependencyfile</arg>
                                    <arg>${project.build.directory}/.scala_dependencies</arg>
<!-- Attempt #2 -->
                                </args>

                            </configuration>

我也运行了mvn compile -Xmax-classfile-name 50,但是Maven无法识别该选项并失败了.

I also ran mvn compile -Xmax-classfile-name 50, but Maven did not recognize the option and failed.

在哪里可以使用maven-scala-plugin指定此选项?

Where can I specify this option using the maven-scala-plugin?

推荐答案

configuration内使用args的位置应该是放置编译器参数的位置.您似乎还创建了scalacArgs,但是args被传递给了scalac.

Where you are using args inside configuration should be where you put your compiler args. You seem to have also created scalacArgs, but the args are passed to scalac.

我在插件中使用此选项将选项传递给编译器:

I use this in my plugin to pass options to the compiler:

<configuration> <args> <arg>-g:vars</arg> <arg>-Yrangepos</arg> <arg>-P:scoverage:dataDir:${coverage.data.dir}</arg> <arg>-Xmax-classfile-name</arg> <arg>70</arg> </args> <jvmArgs> <jvmArg>-Xms64m</jvmArg> <jvmArg>-Xmx1024m</jvmArg> </jvmArgs> <compilerPlugins> <compilerPlugin> <groupId>org.scoverage</groupId> <artifactId>scalac-scoverage-plugin_${scala.major}</artifactId> <version>${scoverage-plugin.version}</version> </compilerPlugin> </compilerPlugins> </configuration>

<configuration> <args> <arg>-g:vars</arg> <arg>-Yrangepos</arg> <arg>-P:scoverage:dataDir:${coverage.data.dir}</arg> <arg>-Xmax-classfile-name</arg> <arg>70</arg> </args> <jvmArgs> <jvmArg>-Xms64m</jvmArg> <jvmArg>-Xmx1024m</jvmArg> </jvmArgs> <compilerPlugins> <compilerPlugin> <groupId>org.scoverage</groupId> <artifactId>scalac-scoverage-plugin_${scala.major}</artifactId> <version>${scoverage-plugin.version}</version> </compilerPlugin> </compilerPlugins> </configuration>

http://scala-tools.org/mvnsites/maven-scala-plugin/example_compile.html#Compiler_Arguments

这篇关于使用maven-scala-plugin指定Scalac编译时选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆