本文整理汇总了Scala中sbt.plugins.JvmPlugin类的典型用法代码示例。如果您正苦于以下问题:Scala JvmPlugin类的具体用法?Scala JvmPlugin怎么用?Scala JvmPlugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JvmPlugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: Common
//设置package包名称以及导入依赖的类
import sbt.Keys._
import sbt._
import sbt.plugins.JvmPlugin
object Common extends AutoPlugin {
override def trigger = allRequirements
override def requires: sbt.Plugins = JvmPlugin
override def projectSettings = Seq(
organization := "fun.lambda",
version := "0.9",
resolvers += Resolver.typesafeRepo("releases"),
javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
scalacOptions ++= Seq(
"-encoding",
"UTF-8", // yes, this is 2 args
"-target:jvm-1.8",
"-deprecation",
"-feature",
"-unchecked",
"-Xlint",
"-Yno-adapted-args",
"-Ywarn-numeric-widen",
"-Xfatal-warnings"
),
scalacOptions in Test ++= Seq("-Yrangepos"),
autoAPIMappings := true
)
}
示例2: Common
//设置package包名称以及导入依赖的类
import sbt.Keys._
import sbt._
import sbt.plugins.JvmPlugin
object Common extends AutoPlugin {
override def trigger = allRequirements
override def requires: sbt.Plugins = JvmPlugin
override def projectSettings = Seq(
organization := "com.lightbend.restapi",
version := "1.0-SNAPSHOT",
resolvers += Resolver.typesafeRepo("releases"),
javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
scalacOptions ++= Seq(
"-encoding",
"UTF-8", // yes, this is 2 args
"-target:jvm-1.8",
"-deprecation",
"-feature",
"-unchecked",
"-Xlint",
"-Yno-adapted-args",
"-Ywarn-numeric-widen",
"-Xfatal-warnings"
),
scalacOptions in Test ++= Seq("-Yrangepos"),
autoAPIMappings := true
)
}
示例3: PackageUnidoc
//设置package包名称以及导入依赖的类
package com.thoughtworks.sbtBestPractice.publishUnidoc
import sbt.{Def, _}
import Keys._
import sbt.Defaults.{packageDocMappings, packageTaskSettings}
import sbt.plugins.JvmPlugin
import sbtunidoc.Plugin.UnidocKeys._
object PackageUnidoc extends AutoPlugin {
override def requires: Plugins = JvmPlugin
override def trigger: PluginTrigger = allRequirements
object autoImport {
val unidocProject = settingKey[Option[ProjectRef]](
"The project that defines a unidoc task. If this `unidocProject` setting is not None, packageDoc will use files generated from unidoc instead of per project doc")
}
import autoImport._
override def globalSettings: Seq[Def.Setting[_]] = {
unidocProject := None
}
override def projectSettings: Seq[Def.Setting[_]] = {
inConfig(Compile)(
packageTaskSettings(
packageDoc,
Def.taskDyn {
unidocProject.value match {
case None => packageDocMappings
case Some(p) => (unidoc in Compile in p).map(_.flatMap(Path.allSubpaths))
}
}
))
}
}
示例4: ScaladocFeatures
//设置package包名称以及导入依赖的类
package com.thoughtworks.sbtBestPractice.scalacOptions
import sbt._
import sbt.Keys._
import sbt.plugins.JvmPlugin
object ScaladocFeatures extends AutoPlugin {
override def requires = JvmPlugin
override def trigger = allRequirements
override val projectSettings = Seq(
scalacOptions in Compile in doc += "-groups",
scalacOptions in Compile in doc += "-diagrams",
scalacOptions in Compile in doc += "-implicits",
scalacOptions in Compile in doc ++= {
if (scalaBinaryVersion.value == "2.10") {
Seq()
} else {
Seq("-author")
}
}
)
}
示例5: Optimization
//设置package包名称以及导入依赖的类
package com.thoughtworks.sbtBestPractice.scalacOptions
import com.thoughtworks.sbtBestPractice.scalacOptions.ScalacWarnings.allRequirements
import sbt._
import sbt.Keys._
import sbt.plugins.JvmPlugin
object Optimization extends AutoPlugin {
override def requires: Plugins = JvmPlugin
override def trigger: PluginTrigger = noTrigger
override def buildSettings = Seq(
scalacOptions ++= {
import scala.math.Ordering.Implicits._
if (VersionNumber(scalaVersion.value).numbers < Seq(2L, 12L)) {
Seq("-optimize", "-Yinline-warnings")
} else {
Seq("-opt:l:project")
}
}
)
}
示例6: Common
//设置package包名称以及导入依赖的类
import sbt.Keys._
import sbt._
import sbt.plugins.JvmPlugin
object Common extends AutoPlugin {
override def trigger = allRequirements
override def requires = JvmPlugin
override def projectSettings = Seq(
resolvers += "Scalaz Bintray Repo" at {
"http://dl.bintray.com/scalaz/releases" // specs2 depends on scalaz-stream
},
scalacOptions ~= (_.filterNot(_ == "-Xfatal-warnings")),
fork in Test := true
)
}
object AnormGeneration {
def generateFunctionAdapter(dir: File): File = {
val out = dir / "FunctionAdapter.scala"
if (out exists) out else {
IO.writer[File](out, "", IO.defaultCharset, false) { w ?
w.append("""package anorm
def to[""")
(1 to i).foreach { j => w.append(s"T$j, ") }
w.append(s"R](f: Function$i[${types mkString ", "}, R]): ${types mkString " ~ "} => R = { case ${values mkString " ~ "} => f(${values mkString ", "}) }")
}
w.append("""
}""")
out
}
}
}
}
示例7: TestPlugin
//设置package包名称以及导入依赖的类
package com.trafficland.augmentsbt.testing
import sbt._
import sbt.Keys.{sourceDirectory, unmanagedSourceDirectories}
import sbt.plugins.JvmPlugin
import sbt.{AutoPlugin, Configuration, Def, Defaults, IntegrationTest, Test, inConfig}
object TestPlugin extends AutoPlugin {
import autoImport._
override def requires: Plugins = JvmPlugin
object autoImport {
val TestCommon: Configuration = config("testcommon").extend(Test)
}
override def projectConfigurations: Seq[Configuration] = Seq(IntegrationTest)
override def projectSettings: Seq[Def.Setting[_]] =
Defaults.itSettings ++
Seq(
sourceDirectory in TestCommon := (sourceDirectory in Test).value.getParentFile / "testcommon",
sourceDirectory in IntegrationTest := (sourceDirectory in Test).value.getParentFile / "it"
) ++
inConfig(IntegrationTest)(testCommonSettings) ++
inConfig(Test)(testCommonSettings)
lazy val testCommonSettings = Seq(
unmanagedSourceDirectories ++= unmanagedSourceDirectories.value.map(rebase(sourceDirectory.value, (sourceDirectory in TestCommon).value)).flatten
)
}
示例8: LogbackConfigurationPlugin
//设置package包名称以及导入依赖的类
package com.trafficland.augmentsbt.generators
import sbt._
import scala.collection.Seq
import java.io.File
import sbt.Keys._
import ConfigurationDirectory.autoImport._
import sbt.plugins.JvmPlugin
object LogbackConfigurationPlugin extends AutoPlugin with FileGenerator {
import autoImport._
override lazy val requires: Plugins = ConfigurationDirectory && JvmPlugin
object autoImport {
val generateLogbackConf: TaskKey[Seq[File]] = TaskKey[Seq[File]](
"generate-logback-conf",
"destructively generates a default logback configuration"
)
val generateLogbackTestConf: TaskKey[Seq[File]] = TaskKey[Seq[File]](
"generate-logback-test-conf",
"destructively generates a default logback test configuration that restarts log files and writes to STDOUT"
)
val logbackTargetFile: SettingKey[File] = SettingKey[File]("logback-target-file")
val logbackTestTargetFile: SettingKey[File] = SettingKey[File]("logback-test-target-file")
}
override lazy val projectSettings = Seq(
logbackTargetFile <<= confDirectory(_ / "logback.xml"),
logbackTestTargetFile <<= confDirectory(_ / "logback-test.xml"),
generateLogbackConf <<= (streams, normalizedName, logbackTargetFile) map { (out, name, tf) =>
generate(out, "logback.xml.template", normalizedNameModification(name), tf)
},
generateLogbackTestConf <<= (streams, normalizedName, logbackTestTargetFile) map { (out, name, tf) =>
generate(out, "logback-test.xml.template", normalizedNameModification(name), tf)
}
)
}
示例9: Common
//设置package包名称以及导入依赖的类
import sbt.Keys._
import sbt._
import sbt.plugins.JvmPlugin
object Common extends AutoPlugin {
override def trigger = allRequirements
override def requires: sbt.Plugins = JvmPlugin
override def projectSettings = Seq(
organization := "com.searchprod.restapi",
version := "1.0-SNAPSHOT",
resolvers += Resolver.typesafeRepo("releases"),
javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
scalacOptions ++= Seq(
"-encoding",
"UTF-8", // yes, this is 2 args
"-target:jvm-1.8",
"-deprecation",
"-feature",
"-unchecked",
"-Xlint",
"-Yno-adapted-args",
"-Ywarn-numeric-widen",
"-Xfatal-warnings"
),
scalacOptions in Test ++= Seq("-Yrangepos"),
autoAPIMappings := true
)
}
示例10: BuildEnvPlugin
//设置package包名称以及导入依赖的类
package sbtbuildenv
import sbt._
import sbt.Keys._
import sbt.plugins.JvmPlugin
object BuildEnvPlugin extends AutoPlugin {
// make sure it triggers automatically
override def trigger = AllRequirements
override def requires = JvmPlugin
object autoImport {
object BuildEnv extends Enumeration {
type BuildEnv = Value
val Production = Value("prod")
val Stage = Value("stage")
val Test = Value("test")
val Development = Value("dev")
}
val buildEnv = settingKey[BuildEnv.Value]("the current build environment")
}
import autoImport._
override def projectSettings: Seq[Setting[_]] = Seq(
buildEnv := {
sys.props
.get("env")
.orElse(sys.env.get("BUILD_ENV"))
.flatMap {
case "prod" => Some(BuildEnv.Production)
case "stage" => Some(BuildEnv.Stage)
case "test" => Some(BuildEnv.Test)
case "dev" => Some(BuildEnv.Development)
case _ => None
}
.getOrElse(BuildEnv.Development)
},
// give feed back
onLoadMessage := {
// depend on the old message as well
val defaultMessage = onLoadMessage.value
val env = buildEnv.value
s"""|$defaultMessage
|Running in build environment: $env""".stripMargin
}
)
}
示例11: Common
//设置package包名称以及导入依赖的类
import sbt.Keys._
import sbt._
import sbt.plugins.JvmPlugin
object Common extends AutoPlugin {
override def trigger = allRequirements
override def requires: sbt.Plugins = JvmPlugin
override def projectSettings = Seq(
organization := "com.lightbend.restapi",
version := "1.0-SNAPSHOT",
resolvers += Resolver.typesafeRepo("releases"),
javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
scalacOptions ++= Seq(
"-encoding", "UTF-8", // yes, this is 2 args
"-target:jvm-1.8",
"-deprecation",
"-feature",
"-unchecked",
"-Xlint",
"-Yno-adapted-args",
"-Ywarn-numeric-widen"
//"-Xfatal-warnings"
),
scalaVersion := "2.11.8",
scalacOptions in Test ++= Seq("-Yrangepos"),
autoAPIMappings := true
)
}
示例12: Common
//设置package包名称以及导入依赖的类
import sbt.Keys._
import sbt._
import sbt.plugins.JvmPlugin
object Common extends AutoPlugin {
override def trigger: PluginTrigger = allRequirements
override def requires: sbt.Plugins = JvmPlugin
override def projectSettings = Seq(
organization := "com.entea",
version := "1.0-SNAPSHOT",
resolvers ++= Seq(
Resolver.typesafeRepo("releases"),
Resolver.sonatypeRepo("releases"),
Resolver.jcenterRepo,
Resolver.bintrayRepo("scalaz-bintray", "releases")
),
scalaVersion := "2.12.2",
javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
scalacOptions ++= Seq(
//"-opt:l:project",
"-encoding", "UTF-8",
"-target:jvm-1.8",
"-deprecation",
"-feature",
"-unchecked",
"-Xlint",
"-Yno-adapted-args",
"-Ywarn-numeric-widen",
"-Xfuture"
),
scalacOptions in Test ++= Seq("-Yrangepos"),
autoAPIMappings := true
)
}
示例13: SbtrunfastPlugin
//设置package包名称以及导入依赖的类
package pl.tues.sbt.runfast
import sbt._
import sbt.Keys._
import sbt.plugins.JvmPlugin
object SbtrunfastPlugin extends AutoPlugin {
override def trigger = allRequirements
override def requires = JvmPlugin
object autoImport {
val runfastGenerate = taskKey[Option[File]]("Generates a runfast script in the target directory")
}
import autoImport._
override lazy val projectSettings = Seq(
runfastGenerate := (mainClass in Compile).value.map { main =>
val runfastFile = (target in Compile).value / "runfast.sh"
val classpath = (fullClasspath in Runtime).value.map(_.data).mkString(":")
IO.writeLines(runfastFile,
Seq(
"#!/bin/bash",
"",
s"""java -cp '${classpath}' '${main}' "[email protected]""""
)
)
(s"""chmod a+x ${runfastFile}""" !)
runfastFile
}
)
override lazy val buildSettings = Seq()
override lazy val globalSettings = Seq()
}
示例14: Common
//设置package包名称以及导入依赖的类
import sbt.{AutoPlugin, Resolver}
import sbt.plugins.JvmPlugin
import sbt.Keys._
import sbt.{Resolver, _}
object Common extends AutoPlugin {
override def trigger = allRequirements
override def requires = JvmPlugin
override def projectSettings = Seq(
scalaVersion := "2.11.8",
javacOptions ++= Seq("-source", "1.8", "-target", "1.8"),
scalacOptions ++= Seq(
"-encoding", "UTF-8", // yes, this is 2 args
"-deprecation",
"-feature",
"-unchecked",
"-Xlint",
"-Yno-adapted-args",
"-Ywarn-numeric-widen",
"-Xfatal-warnings"
),
resolvers ++= Seq(
"scalaz-bintray" at "http://dl.bintray.com/scalaz/releases",
Resolver.sonatypeRepo("releases"),
Resolver.sonatypeRepo("snapshots")),
libraryDependencies ++= Seq(
"javax.inject" % "javax.inject" % "1",
"joda-time" % "joda-time" % "2.9.2",
"org.joda" % "joda-convert" % "1.2",
"com.google.inject" % "guice" % "4.0"
),
scalacOptions in Test ++= Seq("-Yrangepos")
)
}
示例15: LagomOpenApiPlugin
//设置package包名称以及导入依赖的类
package com.lightbend.lagom.spec.sbt
import sbt.Keys._
import sbt.plugins.JvmPlugin
import sbt.{ AutoPlugin, File, _ }
object LagomOpenApiPlugin extends AutoPlugin {
object autoImport {
val lagomOpenAPIGenerateDescriptor = taskKey[Seq[File]]("Generate Lagom Descriptors from OpenAPI specs.")
}
import autoImport._
override def trigger = noTrigger
override def requires = JvmPlugin
override def projectSettings = inConfig(Compile)(openApiSettings) ++ inConfig(Test)(openApiSettings)
val openApiSettings = Seq(
sourceDirectory in lagomOpenAPIGenerateDescriptor := sourceDirectory.value / "openapi",
resourceDirectory in lagomOpenAPIGenerateDescriptor := sourceDirectory.value / "openapi",
target in lagomOpenAPIGenerateDescriptor :=
crossTarget.value / "openapi" / Defaults.nameForSrc(configuration.value.name),
lagomOpenAPIGenerateDescriptor := LagomOpenApiGenerator.lagomOpenAPIGenerateDescriptorTask().value,
sourceGenerators += Def.task { lagomOpenAPIGenerateDescriptor.value },
// TODO: review managedSources
managedSourceDirectories += (target in lagomOpenAPIGenerateDescriptor).value / "java",
unmanagedResourceDirectories += (resourceDirectory in lagomOpenAPIGenerateDescriptor).value,
watchSources in Defaults.ConfigGlobal ++= (sources in lagomOpenAPIGenerateDescriptor).value
) ++
inTask(lagomOpenAPIGenerateDescriptor)(
Seq(
includeFilter := GlobFilter("*.json") || GlobFilter("*.yaml"),
managedSourceDirectories := Nil,
unmanagedSourceDirectories := Seq(sourceDirectory.value),
sourceDirectories := unmanagedSourceDirectories.value ++ managedSourceDirectories.value,
unmanagedSources := Defaults.collectFiles(sourceDirectories, includeFilter, excludeFilter).value,
managedSources := Nil,
sources := managedSources.value ++ unmanagedSources.value,
managedResourceDirectories := Nil,
unmanagedResourceDirectories := Seq(resourceDirectory.value),
resourceDirectories := unmanagedResourceDirectories.value ++ managedResourceDirectories.value,
unmanagedResources := Defaults.collectFiles(resourceDirectories, includeFilter, excludeFilter).value,
managedResources := Nil,
resources := managedResources.value ++ unmanagedResources.value
)
)
}