Skip to content

Commit

Permalink
Scaffold - working example of empty scala project
Browse files Browse the repository at this point in the history
  • Loading branch information
marcinwadon committed Jul 7, 2022
1 parent 1f83de8 commit 5d848fe
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .jvmopts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-Dfile.encoding=UTF8
-Xms1G
-Xmx5G
-XX:ReservedCodeCacheSize=500M
-XX:+TieredCompilation
-XX:+UseParallelGC
10 changes: 10 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
rules = [
OrganizeImports
]

OrganizeImports {
groupedImports = Merge
coalesceToWildcardImportThreshold = 3
groups = ["re:javax?\\.", "cats.", "scala.", "org.acme.", "*"]
removeUnused = true
}
24 changes: 24 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version=2.0.0

style = default
project.git = true

maxColumn = 120
newlines.alwaysBeforeTopLevelStatements = true
continuationIndent.defnSite = 2
continuationIndent.callSite = 2
newlines.penalizeSingleSelectMultiArgList = false
includeCurlyBraceInSelectChains = false
align.openParenCallSite = false
danglingParentheses = true
newlines.avoidAfterYield = false

align = some

rewrite.rules = [
AvoidInfix
RedundantBraces
RedundantParens
AsciiSortImports
PreferCurlyFors
]
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# State channel - examples

```bash
sbt "stateChannel/run"
```
55 changes: 55 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import Dependencies._

ThisBuild / scalaVersion := "2.13.8"
ThisBuild / organization := "org.acme"
ThisBuild / organizationName := "acme"

ThisBuild / evictionErrorLevel := Level.Warn
ThisBuild / scalafixDependencies += Libraries.organizeImports

resolvers += Resolver.sonatypeRepo("snapshots")

val scalafixCommonSettings = inConfig(IntegrationTest)(scalafixConfigSettings(IntegrationTest))

lazy val commonSettings = Seq(
scalacOptions ++= List("-Ymacro-annotations", "-Yrangepos", "-Wconf:cat=unused:info", "-language:reflectiveCalls"),
scalafmtOnCompile := true,
scalafixOnCompile := true,
resolvers ++= List(
Resolver.sonatypeRepo("snapshots")
)
)

ThisBuild / assemblyMergeStrategy := {
case "logback.xml" => MergeStrategy.first
case x if x.contains("io.netty.versions.properties") => MergeStrategy.discard
case PathList(xs @ _*) if xs.last == "module-info.class" => MergeStrategy.first
case x => (assembly / assemblyMergeStrategy).value(x)
}

Global / fork := true
Global / cancelable := true
Global / onChangedBuildSource := ReloadOnSourceChanges

lazy val root = (project in file("."))
.settings(
name := "acme"
)
.aggregate(stateChannel)

lazy val stateChannel = (project in file("modules/state-channel"))
.enablePlugins(AshScriptPlugin)
.enablePlugins(JavaAppPackaging)
.settings(
name := "acme-state-channel",
Defaults.itSettings,
scalafixCommonSettings,
commonSettings,
libraryDependencies ++= Seq(
CompilerPlugin.kindProjector,
CompilerPlugin.betterMonadicFor,
CompilerPlugin.semanticDB
)
)

addCommandAlias("runLinter", ";scalafixAll --rules OrganizeImports")
7 changes: 7 additions & 0 deletions modules/state-channel/src/main/scala/org/acme/Main.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.acme

object Main {

def main(args: Array[String]) =
println("Hello, world")
}
33 changes: 33 additions & 0 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sbt._

object Dependencies {

object V {
val betterMonadicFor = "0.3.1"
val kindProjector = "0.13.2"
val organizeImports = "0.5.0"
val semanticDB = "4.5.9"
}

object Libraries {

// Scalafix rules
val organizeImports = "com.github.liancheng" %% "organize-imports" % V.organizeImports
}

object CompilerPlugin {

val betterMonadicFor = compilerPlugin(
"com.olegpy" %% "better-monadic-for" % V.betterMonadicFor
)

val kindProjector = compilerPlugin(
("org.typelevel" % "kind-projector" % V.kindProjector).cross(CrossVersion.full)
)

val semanticDB = compilerPlugin(
("org.scalameta" % "semanticdb-scalac" % V.semanticDB).cross(CrossVersion.full)
)
}

}
1 change: 1 addition & 0 deletions project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=1.6.2
8 changes: 8 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.3.3")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.8.1")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.0")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "1.2.0")
addSbtPlugin("org.jmotor.sbt" % "sbt-dependency-updates" % "1.2.2")
addDependencyTreePlugin
1 change: 1 addition & 0 deletions version.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ThisBuild / version := "0.1.0-SNAPSHOT"

0 comments on commit 5d848fe

Please sign in to comment.