我需要在声明性管道中启动一组动态测试.为了更好的可视化目的,我想为每个测试创建一个阶段.有办法吗?
创建我所知道的舞台的唯一方法是:
stage('foo') {
...
}
Run Code Online (Sandbox Code Playgroud)
我见过这个例子,但我没有使用声明性语法.
我有一个混合的Scala/Java项目,编译得不好.
当Java代码试图在同一个包中调用Scala代码时,就会出现问题.
当然,我有标准布局:
我看过其他类似的Stackoverflow问题,但这个问题有点过时了.这个问题也无济于事.
我还关注了scala-maven-plugin文档页面.
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.1.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
我尝试过关注这篇博文失败了.
使用从pom.xml导入的Scala插件的IDEA项目可以成功编译和运行我的项目.
这样做的正确方法是什么?Java代码是否被编译两次?首先是Scala插件和Java插件吗?
我有一个0.13.7 SBT项目,有几个子项目.
其中一个叫做webapp
,它有很多JUnit
测试webapp/src/test/java
.
运行时:
sbt webapp/test
Run Code Online (Sandbox Code Playgroud)
只ScalaTest
运行测试,但没有JUnit测试.
我的build.sbt
档案片段:
libraryDependencies ++= Seq(
"com.novocode" % "junit-interface" % "0.11" % Test
)
lazy val webapp = project
settings(
Seq(
projectDependencies ++= Seq(
....
"org.scalatest" %% "scalatest" % "2.2.2" % Test,
"junit" % "junit" % "4.11" % Test,
"com.novocode" % "junit-interface" % "0.11" % Test
)
): _*
)
Run Code Online (Sandbox Code Playgroud)
示例JUnit测试:
import org.junit.Test;
public class CodificadorBase64Test {
@Test
public void testPlain() {
byte b[] = …
Run Code Online (Sandbox Code Playgroud) 我是Akka Streams和Akka HTTP的新手.
我想生成一个简单的HTTP服务器,它可以从文件夹的内容生成一个zip文件并将其发送到客户端.
org.zeroturnaround.zip.ZipUtil使创建zip文件的任务变得非常简单,但它需要一个outputStream
.
这是我的解决方案(用Scala语言编写):
val os = new ByteArrayOutputStream()
ZipUtil.pack(myFolder, os)
HttpResponse(entity = HttpEntity(
MediaTypes.`application/zip`,
os.toByteArray))
Run Code Online (Sandbox Code Playgroud)
此解决方案有效,但将所有内容保留在内存中,因此无法扩展.
我认为解决这个问题的关键是使用这个:
val source = StreamConverters.asOutputStream()
Run Code Online (Sandbox Code Playgroud)
但不知道如何使用它.:-(
有什么帮助吗?
我有这些:
trait A[T]
class X
class Y
object B {
def method[H :< HList](h: H) = h.toList[A[_]]
}
Run Code Online (Sandbox Code Playgroud)
参数h
的method
永远是A [T]的HList,如新A [X] ::新A [Y] ::高抗扰度逻辑.
我想将HList转换为List [A [_]].
我怎么能用通用代码得到这个,因为trait HList没有toList方法()?
我想知道为什么有时我的构建速度要慢得多.
所以我决定测量长时间运行时间.
运行纯Scala代码时,很容易这样做:
def myMethod() = {
val initTime = System.currentTimeMillis
...
val elapsedTime = System.currentTimeMillis-initTime
}
Run Code Online (Sandbox Code Playgroud)
但是对于像packageBin
或者compile
,我的源代码无法改变的任务,我不知道如何测量它,因为我无法控制何时someTask.value
运行.
任何提示?
相关问题:
我有这门课:
case class Columna[T](nombre: String)
class Tabla {
def leeTodo[T](col: Columna[T], filtro: String, orderBy: String = "") = ...
def leeTodo[T0, T1](col0: Columna[T0], col1: Columna[T1], filtro: String, orderBy: String = "") = ...
def leeTodo[T0, T1, T2](col0: Columna[T0], col1: Columna[T1], col2: Columna[T2], filtro: String, orderBy: String = "") = ...
}
object admver extends Tabla {
}
Run Code Online (Sandbox Code Playgroud)
此代码用于使用Scala 2.10.4进行编译.现在,我正在尝试Scala 2.11.2,我收到此错误消息:
Error:(3, 8) in object admver, multiple overloaded alternatives of method leeTodo define default arguments.
The members with defaults are defined …
Run Code Online (Sandbox Code Playgroud) 假设我有这样的事情:
trait Cursor {
}
trait Column[T] {
def read(cusor: Cursor): T
}
trait ColumnReader {
def readColumns(columns: Product[Column[_]], cursor: Cursor): Iterable[Any] = {
for (column <- columns) yield column.read(cursor)
}
}
Run Code Online (Sandbox Code Playgroud)
readColumns()
API 的问题是我丢失了类型信息,即如果我有这个:
object columnString extends Column[String] {
def read(cursor: Cursor): String = ...
}
object columnInt extends Column[Int] {
def read(cursor: Cursor): Int = ...
}
Run Code Online (Sandbox Code Playgroud)
表达式如new ColumnReader().readColumns((columnString, columnInt))
返回Iterable[Any]
.我想返回类似的东西Tuple2[String, Int]
,但不知道如何.我丢失了对编译器有用的类型信息.
也许像Shapeless这样的图书馆可能会有用.
我确信Scala有一些工具来处理这样的问题.
有任何想法吗?
我正在尝试使用来自Shapeless的HList.
这是我的第一次尝试:
trait Column[T] {
val name: String
}
case class CV[T](col: Column[T], value: T)
object CV {
object columnCombinator extends Poly2 {
implicit def algo[A] = at[(String, String, String), CV[A]] { case ((suffix, separator, sql), cv) ?
(suffix, separator, if (sql == "") cv.col.name+suffix else sql+separator+cv.col.name+suffix)
}
}
def combine[A <: HList](columns: A, suffix: String, separator: String = " and ")
(implicit l: LeftFolder[A, (String, String, String), columnCombinator.type]): String =
columns.foldLeft((suffix, separator, ""))(columnCombinator)._3
}
Run Code Online (Sandbox Code Playgroud)
问题是我不知道foldLeft
这个例子中返回了什么.
我希望它返回(String, …
这个问题来自我之前的问题:HList#foldLeft()返回什么?
我有这种情况:
class Cursor {
}
trait Column[T] {
def read(c: Cursor, index: Int): T
}
object Columns {
object readColumn extends Poly2 {
implicit def a[A, B <: HList] = at[Column[A], (B, Cursor, Int)] { case (col, (values, cursor, index)) ?
(col.read(cursor, index) :: values, cursor, index+1)
}
}
def readColumns[A <: HList, B <: HList](c: Cursor, columns: A)(implicit l: RightFolder.Aux[A, (HNil.type, Cursor, Int), readColumn.type, (B, Cursor, Int)]): B =
columnas.foldRight((HNil, c, 0))(readColumn)._1
}
Run Code Online (Sandbox Code Playgroud)
此代码尝试读取多个列的值.
如果我打电话readColumns(cursor, new …
scala ×8
shapeless ×4
sbt ×2
akka ×1
akka-http ×1
akka-stream ×1
java ×1
jenkins ×1
junit ×1
maven ×1
overloading ×1
unit-testing ×1