English 中文(简体)
SBT: 原始受扶养人和项目班次
原标题:SBT: Plugin dependencies and project classpath
  • 时间:2011-10-26 22:10:46
  •  标签:
  • scala
  • sbt

• 如何增加对SBT p块的外部依赖,并在项目和原始类别上提供:

具体 我有一个简单的缩略语,可以操作我们测试小组的试样,进行一些员额处理。 简略版本:

import sbt._
import java.util.ArrayList
import Keys._
import org.testng._

object RunTestSuitesPlugin extends Plugin {
  lazy val runTestSuites = TaskKey[Unit]("run-test-suites", "runs TestNG test suites")
  lazy val testSuites = SettingKey[Seq[String]]("test-suites", "list of test suites to run")

  class JavaListWrapper[T](val seq: Seq[T]) {
    def toJavaList = seq.foldLeft(new java.util.ArrayList[T](seq.size)) { (al, e) => al.add(e); al }
  }
  implicit def listToJavaList[T](l: Seq[T]) = new JavaListWrapper(l)

  def runTestSuitesTask = runTestSuites <<= (target, streams, testSuites) map {
    (targetDirectory, taskStream, suites) =>
      import taskStream.log
      log.info("running test suites: " + suites)
      runSuites(suites)
  }

  private def runSuites(testSuites: Seq[String]) = {
    var tester = new TestNG
    tester.setTestSuites(testSuites.toJavaList)
    tester.run()
  }

  def testSuiteSettings = {
    inConfig(Compile)(Seq(
      runTestSuitesTask,
      testSuites := Seq("testsuites/mysuite.xml"),
      libraryDependencies += "org.testng" % "testng" % "5.14"))
  }
}

问题在于,当我把这一金字添加到一个项目中,并用run-test-appes加以管理时。 之后,它未能达到java.lang.NoClassDefFoundError:org/testng/NG,尽管show full-classpath显示testng.jar上下级。

因此,在执行假肢时使用的班次与我的项目中的班次有所不同,因此我如何在这两个地方出现假想的依赖?

最佳回答

在使用假肢的项目中,将试验国家直接添加到未管理的Jars>。

我没有找到任何资源来解释在草原处决期间SBT阶级路线的结构,因此,将非常赞赏任何解释为何有必要采取这一步骤的企图。

问题回答




相关问题
How to flatten a List of different types in Scala?

I have 4 elements:List[List[Object]] (Objects are different in each element) that I want to zip so that I can have a List[List[obj1],List[obj2],List[obj3],List[obj4]] I tried to zip them and I ...

To use or not to use Scala for new Java projects? [closed]

I m impressed with Twitter and investigating to use Scala for a new large scale web project with Hibernate and Wicket. What do you think about Scala, and should I use it instead of Java? EDIT: And, ...

Why does Scala create a ~/tmp directory when I run a script?

When I execute a Scala script from the command line, a directory named "tmp" is created in my home directory. It is always empty, so I simply deleted it without any apparent problem. Of course, when I ...

Include jar file in Scala interpreter

Is it possible to include a jar file run running the Scala interpreter? My code is working when I compile from scalac: scalac script.scala -classpath *.jar But I would like to be able to include a ...

Scala and tail recursion

There are various answers on Stack Overflow which explain the conditions under which tail recursion is possible in Scala. I understand the limitations and how and where I can take advantage of tail ...