为子项目交叉编译具有不同crossScalaVersions的聚合项目 [英] Cross-compiling aggregate projects with different crossScalaVersions for subprojects

查看:35
本文介绍了为子项目交叉编译具有不同crossScalaVersions的聚合项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个项目,有几个子项目可以在 Scala 2.10 和 2.11 下编译,一个子项目只能在 2.10 下编译(实际上是 Scala-Virtualized 2.10.2),一个子项目只能在 2.11 下编译.有没有一种简单的方法来创建一个聚合项目,该项目为 2.10 和 2.11 交叉构建所有可能的子项目?或者,为 2.10 和 2.11 设置不同的默认项目?

We have a project with several subprojects which can compile under both Scala 2.10 and 2.11, one subproject which only compiles under 2.10 (actually, Scala-Virtualized 2.10.2) and one subproject which only compiles under 2.11. Is there a simple way to create an aggregate project which cross-builds all possible subprojects for both 2.10 and 2.11? Or, alternately, to have different default projects for 2.10 and 2.11?

特别是,这里是当前的 Build.scala.如果我将 lmsBackend 添加到 root,我得到

In particular, here is current Build.scala. If I add lmsBackend to root, I get

> show scalaVersion
[info] common/*:scalaVersion
[info]  2.10.4
[info] lms-backend/*:scalaVersion
[info]  2.10.2
[info] meta/*:scalaVersion
[info]  2.10.4
[info] community-edition/*:scalaVersion
[info]  2.10.4
[info] core/*:scalaVersion
[info]  2.10.4
[info] scalan/*:scalaVersion
[info]  2.10.4
> show crossScalaVersions
[info] common/*:crossScalaVersions
[info]  List(2.10.4, 2.11.5)
[info] lms-backend/*:crossScalaVersions
[info]  List(2.10.2)
[info] meta/*:crossScalaVersions
[info]  List(2.10.4, 2.11.5)
[info] community-edition/*:crossScalaVersions
[info]  List(2.10.4, 2.11.5)
[info] core/*:crossScalaVersions
[info]  List(2.10.4, 2.11.5)
[info] scalan/*:crossScalaVersions
[info]  List(2.10.4, 2.11.5)

SBT 能够在这个聚合项目上很好地运行 updatecompile 等.然而,一旦我尝试任何交叉构建,事情就会崩溃:

SBT is able to run update, compile, etc. fine on this aggregate project. However, once I try any cross-building, things break:

> +update
[info] Setting version to 2.10.4
[info] Reapplying settings...
[info] Set current project to scalan (in build file:/home/aromanov/IdeaProjects/scalan-lite/)
...
[info] Updating {file:/home/aromanov/IdeaProjects/scalan-lite/}lms-backend...
[info] Resolving org.scala-lang.virtualized#scala-library;2.10.4 ...
[warn]  module not found: org.scala-lang.virtualized#scala-library;2.10.4
...
[info] Resolving org.scala-lang.virtualized#scala-compiler;2.10.4 ...
[warn]  module not found: org.scala-lang.virtualized#scala-compiler;2.10.4
...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: org.scala-lang.virtualized#scala-library;2.10.4: not found
[warn]  :: org.scala-lang.virtualized#scala-compiler;2.10.4: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn] 
[warn]  Note: Unresolved dependencies path:
[warn]      org.scala-lang.virtualized:scala-library:2.10.4 ((sbt.Classpaths) Defaults.scala#L1169)
[warn]        +- com.huawei.scalan:lms-backend_2.10:0.2.6-SNAPSHOT
[warn]      org.scala-lang.virtualized:scala-compiler:2.10.4
[warn]        +- com.huawei.scalan:lms-backend_2.10:0.2.6-SNAPSHOT
[trace] Stack trace suppressed: run last lms-backend/*:update for the full output.
[error] (lms-backend/*:update) sbt.ResolveException: unresolved dependency: org.scala-lang.virtualized#scala-library;2.10.4: not found
[error] unresolved dependency: org.scala-lang.virtualized#scala-compiler;2.10.4: not found
[error] Total time: 2 s, completed Jan 28, 2015 1:33:49 PM

show scalaVersion 现在显示所有子项目的 2.10.4.有没有什么办法可以在聚合项目中包含lms-backend并且仍然避免这个问题?

show scalaVersion now shows 2.10.4 for all subprojects. Is there any way to include lms-backend in the aggregate project and still avoid this problem?

推荐答案

我有一个 类似问题.我的问题有一个额外的类路径依赖复杂性(dependsOn),而不仅仅是聚合,但是我的问题的一个解决方案很好地解决了这个问题.

I had a similar question. My question had an additional complication of classpath dependencies (dependsOn), rather than just aggregation, but one solution for my problem fixes this one quite well.

sbt-doge,一个看似可爱的 GitHub 项目,取代了 的实现+ 及其可互换的前缀之一:很多、如此、如此、非常.

sbt-doge, a deceptively cutesy GitHub project, replaces the implementation of + with one of its interchangeable prefixes: much, so, such, very.

+ cross building operator 的当前实现没有考虑子项目的 crossScalaVersions.在修复之前,这里有一个替代实现.

Current implementation of + cross building operator does not take in account for the crossScalaVersions of the sub projects. Until that's fixed, here's an alternative implementation of it.

该项目的创建者是 SBT 的主要贡献者之一.

The creator of the project is one of the main contributors to SBT.

添加

addSbtPlugin("com.eed3si9n" % "sbt-doge" % "0.1.3")

project/plugins.sbt.

然后

> very compile

这篇关于为子项目交叉编译具有不同crossScalaVersions的聚合项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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