Scala 闭包文件名

标签 scala compiler-construction

由于编译器使用 Scala 2.9.2 为我在 Scala 类中的一个闭包提供的文件名长度,我遇到了问题

CurrencyInitializer$$anonfun$com$gottex$gottware$server$startup$initializers$impl$currency$CurrencyInitializer$$updateDepositEquivalentBonds$1.class

我对这个文件名的问题是,我正在通过 SSH gui 通过 Linux 服务器上传一个包含我所有编译类的文件夹,但这失败了。

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)
}
  }

令人惊讶的是,这是产生长文件名的代码。我可以在编译器上做些什么来防止这种情况发生?

最佳答案

设置 max-classfile-name scala 编译器调用上的参数以缩短文件名。

在 POM 中,要获取不超过 144 个字符的文件名(Crypt FS 大小限制),配置如下

 <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>

编译源设置引用link (会过时)

关于Scala 闭包文件名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15524418/

相关文章:

scala - 基于原点的约束函数(路径依赖类型?类型生成?)

scala - 如何保存 TypeTag 然后稍后使用它将类型重新附加到 Any (Scala 2.10)

c++ - 如何为资源编译器设置输出文件夹

scala - Chisel:在 Windows 上编译 Chisel 库

json - 使用 Circe 展平嵌套 JSON 对象

scala - Scala的shebang行是什么,它不会破坏mimetype?

linux - 编译/链接 CUDA 和 CPP 源文件

c++ - 在线编译器工具执行所有操作还是只检查是否编译?

使用 Maven 编译器进行 JAVA 转换

performance - Delphi:为什么二进制字符串比较运算符 (=) 不使用 SameStr?