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>

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

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

Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384

1 Answers1

6

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>

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

sksamuel
  • 16,154
  • 8
  • 60
  • 108
  • Maven 3 didn't know how to handle `-Xmax-classfile-name:50`: **[ERROR] scalac error: bad option: '-Xmax-classfile-name:50'**. I also got the same error when using a space and equals delimiter, i.e. rather than `:` between the option and the value. – Kevin Meredith Apr 17 '14 at 16:56
  • Maven just passes them to scalac. Try my updated answer. – sksamuel Apr 17 '14 at 17:07
  • Thanks, @monkjack. That worked. As a slight proposed edit, the argument to `-Xmax-classfile-name` needs to be between `~70` and some other number (I don't remember) – Kevin Meredith Apr 17 '14 at 17:17