Scala closures filename

compiler-construction, scala

Solution

Set the `max-classfile-name` parameter on the scala compiler invocation to shorten the file names.

In a POM, to get file names no longer than 144 characters (Crypt FS size limit) the configuration looks like

 <plugin>
     <groupId>org.scala-tools</groupId>
     <artifactId>maven-scala-plugin</artifactId>
     <configuration>
         <scalaVersion>2.9.2</scalaVersion>
         <args>
              <arg>-Xmax-classfile-name</arg>
              <arg>144</arg>
         </args>
     </configuration>
 </plugin>

Compiler source setting reference link (will become obsolete)

Problem

I have a problem due to the length of filename that the compilers give to one of my closures inside a Scala class, using Scala 2.9.2 CurrencyInitializer$$anonfun$com$gottex$gottware$server$startup$initializers$impl$currency$CurrencyInitializer$$updateDepositEquivalentBonds$1.class The problem I have with this filename is that I am uploading a folder contains all my compiled classes through a Linux server through an SSH gui and this fails. ``` private def updateDepositEquivalentBonds(currency: Currency) { val depositEquivalentBonds = gottwareDataSource.space.readAllWithCurrency(classOf[DepositEquivalentBondImpl], currency) for (depositEquivalentBond <- depositEquivalentBonds) depositEquivalentBond.updateFromDeposit(gottwareDataSource.space) if (depositEquivalentBonds.length > 0) { gottwareDataSource.space.writeMultiple(depositEquivalentBonds, Lease.FOREVER, UpdateModifiers.UPDATE_OR_WRITE | UpdateModifiers.NO_RETURN_VALUE) gottwareDataSource.space.writeMultiple(AskBidSpread.newInstances(depositEquivalentBonds.toArray[SecurityImpl]), Lease.FOREVER, UpdateModifiers.UPDATE_OR_WRITE | UpdateModifiers .NO_RETURN_VALUE) } } ``` Surprisingly, this is the code that produce the long filename. Is there something I can do on the compiler to prevent this to happen?

Original source