Scala and SBT Project
Get rid of build.sbt, place all the things into Build.scala and other scala files.
The best sample project is named as sillycat-graph. And I will also list my important configuration files.
build.properties
sbt.version=0.13.5
plugins.sbt - load the latest plugins
addSbtPlugin("io.spray" % "sbt-revolver" % "0.7.2")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.3.0")
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.2.0")
resolvers += "Sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
addSbtPlugin("com.github.mpeltonen" % "sbt-idea" % "1.7.0-SNAPSHOT")
Resolvers.scala - Place all the resolvers URLs here
import sbt._
object Resolvers {
val local = Resolver.defaultLocal
val maven = "MAVEN repo" at "http://repo1.maven.org/maven2"
val sonatype = "sonatype releases" at "https://oss.sonatype.org/content/repositories/releases/"
val sona_snap ="sonatype snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
val typsafe = "typesafe repo" at "http://repo.typesafe.com/typesafe/releases/"
val spary = "spray repo" at "http://repo.spray.io/"
val spary2 = "Spray repo second" at "http://repo.spray.cc/"
val akka = "Akka repo" at "http://repo.akka.io/releases/"
val myResolvers = Seq (local, maven, sonatype, sona_snap, typsafe, spary, spary2, akka)
}
Dependency.scala - all the jar dependencies
import sbt._
object Dependencies {
val neo4j_version = "2.1.3"
val neo4j = "org.neo4j" % "neo4j" % neo4j_version
val log4j = "log4j" % "log4j" % "1.2.17"
val baseDeps = Seq (
neo4j,
log4j
)
}
Build.scala - The final import file to build all the things together
import sbt._
import sbt.Keys._
import Resolvers._
import Dependencies._
import sbtassembly.Plugin._
import sbtassembly.AssemblyUtils._
import AssemblyKeys._
object BuildSettings {
val projectName = "sillycat-graph"
val buildSettings = Seq(
organization := "org.sillycat",
version := "1.0.0",
scalaVersion := "2.10.4",
crossScalaVersions := Seq("2.10.2", "2.10.3", "2.10.4", "2.11.0", "2.11.1", "2.11.2"),
scalacOptions ++= Seq()
)
}
object ApplicationBuild extends Build {
lazy val main = Project(
BuildSettings.projectName,
file("."),
settings = BuildSettings.buildSettings ++ assemblySettings
++
Seq(resolvers := myResolvers,
libraryDependencies ++= baseDeps,
mergeStrategy in assembly := mergeFirst
)
) settings(
mainClass in assembly := Some("com.sillycat.graph.app.ExecutorApp"),
excludedJars in assembly <<= (fullClasspath in assembly) map { cp =>
cp filter {_.data.getName == "compile-0.1.0.jar"}
},
artifact in (Compile, assembly) ~= { art =>
art.copy(`classifier` = Some("assembly"))
}
)
lazy val mergeFirst: String => MergeStrategy = {
case PathList("javax", "servlet", xs @ _*) => MergeStrategy.first
case PathList("org", "apache", "jasper", xs @ _*) => MergeStrategy.first
case PathList("org", "fusesource", xs @ _*) => MergeStrategy.first
case PathList("org", "apache", "commons", xs @ _*) => MergeStrategy.first
case PathList("org", "apache", "commons", "beanutils", xs @ _*) => MergeStrategy.first
case PathList("org", "apache", "commons", "collections", xs @ _*) => MergeStrategy.first
case PathList("com", "esotericsoftware", "minlog", xs @ _*) => MergeStrategy.first
case PathList("org", "eclipse", xs @ _*) => MergeStrategy.first
case PathList("META-INF", xs @ _*) =>
(xs map {_.toLowerCase}) match {
case ("changes.txt" :: Nil ) =>
MergeStrategy.discard
case ("manifest.mf" :: Nil) | ("eclipsef.rsa" :: Nil) | ("index.list" :: Nil) | ("dependencies" :: Nil) =>
MergeStrategy.discard
case ps @ (x :: xs) if ps.last.endsWith(".sf") || ps.last.endsWith(".dsa") || ps.last.endsWith("pom.properties") || ps.last.endsWith("pom.xml") =>
MergeStrategy.discard
case "plexus" :: xs =>
MergeStrategy.discard
case "services" :: xs =>
MergeStrategy.filterDistinctLines
case ("spring.schemas" :: Nil) | ("spring.handlers" :: Nil) =>
MergeStrategy.filterDistinctLines
case ps @ (x :: xs) if ps.last.endsWith(".jnilib") || ps.last.endsWith(".dll") =>
MergeStrategy.first
case ps @ (x :: xs) if ps.last.endsWith(".txt") =>
MergeStrategy.discard
case ("notice" :: Nil) | ("license" :: Nil) | ("mailcap" :: Nil )=>
MergeStrategy.discard
case _ => MergeStrategy.deduplicate
}
case "application.conf" => MergeStrategy.concat
case "about.html" => MergeStrategy.discard
case "plugin.properties" => MergeStrategy.first
case _ => MergeStrategy.first
}
}
Tags: sbt build.sbt Build.scala basic project
References:
https://github.com/sbt/sbt-assembly
http://www.scala-sbt.org/0.13/docs/Full-Def-Example.html
https://github.com/scalamacros/sbt-example
http://stackoverflow.com/questions/18325181/suppress-main-class-in-sbt-assembly
- 浏览: 2542905 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
发表评论
-
NodeJS12 and Zlib
2020-04-01 07:44 468NodeJS12 and Zlib It works as ... -
Traefik 2020(1)Introduction and Installation
2020-03-29 13:52 330Traefik 2020(1)Introduction and ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 428Private Registry 2020(1)No auth ... -
Buffer in NodeJS 12 and NodeJS 8
2020-02-25 06:43 377Buffer in NodeJS 12 and NodeJS ... -
NodeJS ENV Similar to JENV and PyENV
2020-02-25 05:14 468NodeJS ENV Similar to JENV and ... -
Prometheus HA 2020(3)AlertManager Cluster
2020-02-24 01:47 414Prometheus HA 2020(3)AlertManag ... -
Serverless with NodeJS and TencentCloud 2020(5)CRON and Settings
2020-02-24 01:46 332Serverless with NodeJS and Tenc ... -
GraphQL 2019(3)Connect to MySQL
2020-02-24 01:48 243GraphQL 2019(3)Connect to MySQL ... -
GraphQL 2019(2)GraphQL and Deploy to Tencent Cloud
2020-02-24 01:48 445GraphQL 2019(2)GraphQL and Depl ... -
GraphQL 2019(1)Apollo Basic
2020-02-19 01:36 321GraphQL 2019(1)Apollo Basic Cl ... -
Serverless with NodeJS and TencentCloud 2020(4)Multiple Handlers and Running wit
2020-02-19 01:19 307Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(3)Build Tree and Traverse Tree
2020-02-19 01:19 310Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(2)Trigger SCF in SCF
2020-02-19 01:18 286Serverless with NodeJS and Tenc ... -
Serverless with NodeJS and TencentCloud 2020(1)Running with Component
2020-02-19 01:17 303Serverless with NodeJS and Tenc ... -
NodeJS MySQL Library and npmjs
2020-02-07 06:21 282NodeJS MySQL Library and npmjs ... -
Python Library 2019(1)requests and aiohttp
2019-12-18 01:12 257Python Library 2019(1)requests ... -
NodeJS Installation 2019
2019-10-20 02:57 565NodeJS Installation 2019 Insta ... -
Monitor Tool 2019(2)Monit on Multiple Instances and Email Alerts
2019-10-18 10:57 257Monitor Tool 2019(2)Monit on Mu ... -
Sqlite Database 2019(1)Sqlite3 Installation and Docker phpsqliteadmin
2019-09-05 11:24 362Sqlite Database 2019(1)Sqlite3 ... -
Supervisor 2019(2)Ubuntu and Multiple Services
2019-08-19 10:53 366Supervisor 2019(2)Ubuntu and Mu ...
相关推荐
scala 编译工具 sbt 安装包。 Little or no configuration required for simple projects Scala-based build definition that can use the full flexibility of Scala code Accurate incremental recompilation ...
$ git clone https://github.com/sbt/sbt.git$ git clone https://github.com/arturopala/scala-sbt-workshop.git$ cd scala-sbt-workshop$ sbt初始设置仅包含/project/Build.scala文件。 练习:使用inspect和show...
### sbt + Scala + IDEA 安装配置及创建导入 sbt 项目的详细步骤 #### 一、环境搭建 本文档将详细介绍如何在 Windows 10 和 JDK 1.8 的环境下,搭建完整的 Scala + sbt + IntelliJ IDEA 开发环境。这对于初学者来...
Customize and configure SBT for your project, without changing your project’s existing structure ☆ 出版信息:☆ [作者信息] Shiti Saxena [出版机构] Packt Publishing [出版日期] 2013年09月11日 ...
7 步编写 Scala Mesos 框架这是一个模板。 应用此模板的结果是的准系统框架,使用进行构建并使用在单例集群上进行测试。... 构建定义在project/Build.scala ,框架实现在src/main/scala/ 。 编辑框架的配置文件( src
sbt-体面的scala CI 释放 sbt插件,像样的Scala // project/plugins.sbtaddSbtPlugin( " com.github.sideeffffect " % " sbt-decent-scala " % " 0.5.0 " )
在Scala编程中,我们经常使用SBT(Simple Build Tool)作为构建工具,它提供了项目管理和编译的功能。本教程将详细介绍如何在IntelliJ IDEA中使用SBT来构建一个基于AKKA框架的Scala程序。 首先,你需要确保已经安装...
2. **配置项目**: 安装插件后,可以通过`New` -> `Project`创建一个新项目,选择`Scala`项目类型,然后选择使用SBT构建系统。IDE会自动创建默认的`build.sbt`文件,这是SBT项目的核心配置文件。 3. **离线安装**: ...
开发者可以通过`build.sbt`或`project/build.properties`文件来配置项目信息和依赖关系。例如,`build.sbt`文件可以包含如下内容: ```scala name := "MyScalaProject" version := "1.0" scalaVersion := "2.12.8...
Eclipse是 Java Integrated Development Environment(IDE),而sbt是 Scala 的构建工具。要在Eclipse中创建sbt项目,需要安装sbt、创建项目结构、编写build.sbt文件、添加Eclipse支持插件等步骤。 一、安装sbt 在...
A tutorial about effectively building Scala projects, sbt in Action introduces the sbt tool with a simple project that establishes the fundamentals of running commands and tasks. Next, it shows you ...
sbt 是一种基于 Scala 的构建工具,相比 Maven 更加高效和方便。 下载和安装 sbt 首先,用户需要下载 sbt 的安装包并将其安装在本地。安装路径不能包含空格。然后,用户需要进入安装目录下的 conf 文件夹,并新建...
在实际开发中,这通常包含了Sbt的配置文件(如`build.sbt`和`project`目录),以及项目的源代码和其他资源。 总结,Sbt 0.13.15作为一个旧版本的Scala构建工具,依然具有实用价值,特别是对那些需要稳定性和向后...
- `project/Build.scala`: 对于更复杂的需求,可以在`project`目录下创建一个单独的Scala源文件,用于构建更复杂的构建定义。 4. **命令行使用**: - `sbt`: 启动SBT shell。 - `compile`: 编译项目源代码。 - `...
3. **project/Build.scala**: 对于更复杂的构建需求,可以使用此文件用完整的Scala代码自定义构建逻辑。 ### 4. 常用Sbt命令 1. `compile`: 编译项目源代码。 2. `test`: 执行所有测试。 3. `run`: 直接运行主类,...
`sbt-multi-project-example` 是一个针对 Scala 开发者的示例项目,它展示了如何在 Scala 中使用 sbt(Simple Build Tool)构建一个多项目的工程。sbt 是 Scala 社区广泛采用的构建工具,其灵活性和强大的功能使得...
sbt-heroku, 用于部署 Heroku Scala 应用程序的sbt插件 Plugin Plugin Plugin 这个插件用于在不向Git存储库推送的情况下直接部署 Scala 并直接播放应用程序。 这在从CI服务器部署时是很有用的。使用插件将以下内容...
此外,用户可能还会找到`project`目录,其中包含构建定义的更复杂版本,如`Build.scala`文件。 SBT的核心特性包括: 1. **自动化构建**:通过解析`build.sbt`文件,SBT自动管理项目的依赖,编译源代码,并生成可...
为了实现这一功能,开发者可能需要对 `sbt` 的配置文件 `build.sbt` 或者 `project/plugins.sbt` 进行相应的调整,添加或替换仓库配置。例如,可能需要在 `resolvers` 列表中添加阿里云的 Maven 仓库地址,如下所示...
5. **项目结构**:sbt遵循约定优于配置的原则,项目结构通常由`build.sbt`和`project`目录组成,其中`build.sbt`文件包含了项目的基本设置和任务定义,而`project`目录下则包含更复杂的构建配置。 6. **依赖管理**...