Skip to content

Commit 59fc5ca

Browse files
Integrates sbt-org-policies plugin (#9)
1 parent 0b774fa commit 59fc5ca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3978
-3757
lines changed

.scalafmt.conf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
style = defaultWithAlign
2+
maxColumn = 100
3+
4+
continuationIndent.callSite = 2
5+
6+
newlines {
7+
sometimesBeforeColonInMethodReturnType = false
8+
}
9+
10+
align {
11+
arrowEnumeratorGenerator = false
12+
ifWhileOpenParen = false
13+
openParenCallSite = false
14+
openParenDefnSite = false
15+
}
16+
17+
docstrings = JavaDoc
18+
19+
rewrite {
20+
rules = [SortImports, RedundantBraces]
21+
redundantBraces.maxLines = 1
22+
}
23+

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#Scala Exercises - Functional Programming Principles library
2-
1+
# Scala Exercises - Functional Programming Principles library
32
------------------------
43

54
This repository hosts a library for the first course of the [Scala MOOC](https://www.coursera.org/specializations/scala) ("Functional Programming Principles in Scala").
@@ -43,7 +42,7 @@ evaluator.secretKey="secretKey"
4342
sbt -mem 1500 run
4443
~~~
4544

46-
## About Scala exercises
45+
## About Scala exercises
4746

4847
"Scala Exercises" brings exercises for the Stdlib, Cats, Shapeless and many other great libraries for Scala to your browser. Offering hundreds of solvable exercises organized into several categories covering the basics of the Scala language and it's most important libraries.
4948

@@ -54,7 +53,7 @@ Scala Exercises is available at [scala-exercises.org](https://scala-exercises.or
5453
Contributions welcome! Please join our [Gitter channel](https://gitter.im/scala-exercises/scala-exercises)
5554
to get involved, or visit our [GitHub site](https://github.com/scala-exercises).
5655

57-
##License
56+
## License
5857

5958
Copyright (C) 2015-2016 47 Degrees, LLC.
6059
Reactive, scalable software solutions.

build.sbt

Lines changed: 17 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,22 @@
1+
val scalaExerciesV = "0.4.0-SNAPSHOT"
2+
3+
def dep(artifactId: String) = "org.scala-exercises" %% artifactId % scalaExerciesV
4+
15
lazy val `scala-tutorial` = (project in file("."))
2-
.enablePlugins(ExerciseCompilerPlugin)
3-
.settings(publishSettings:_*)
4-
.settings(
5-
organization := "org.scala-exercises",
6-
name := "exercises-scalatutorial",
7-
scalaVersion := "2.11.8",
8-
version := "0.3.0-SNAPSHOT",
9-
resolvers ++= Seq(
10-
Resolver.sonatypeRepo("snapshots"),
11-
Resolver.sonatypeRepo("releases")
12-
),
13-
libraryDependencies ++= Seq(
14-
"org.scalatest" %% "scalatest" % "2.2.4",
15-
"org.scala-exercises" %% "exercise-compiler" % "0.3.0-SNAPSHOT",
16-
"org.scala-exercises" %% "definitions" % "0.3.0-SNAPSHOT",
17-
"org.scalacheck" %% "scalacheck" % "1.12.5",
18-
"com.github.alexarchambault" %% "scalacheck-shapeless_1.12" % "0.3.1",
19-
compilerPlugin("org.spire-math" %% "kind-projector" % "0.7.1")
20-
)
6+
.enablePlugins(ExerciseCompilerPlugin)
7+
.settings(
8+
name := "exercises-scalatutorial",
9+
libraryDependencies ++= Seq(
10+
dep("exercise-compiler"),
11+
dep("definitions"),
12+
%%("scalatest"),
13+
%%("scalacheck"),
14+
%%("scheckShapeless")
2115
)
16+
)
2217

2318
// Distribution
2419

25-
lazy val gpgFolder = sys.env.getOrElse("PGP_FOLDER", ".")
26-
27-
lazy val publishSettings = Seq(
28-
organizationName := "Scala Exercises",
29-
organizationHomepage := Some(new URL("http://scala-exercises.org")),
30-
startYear := Some(2016),
31-
description := "Scala Exercises: The path to enlightenment",
32-
homepage := Some(url("http://scala-exercises.org")),
33-
pgpPassphrase := Some(sys.env.getOrElse("PGP_PASSPHRASE", "").toCharArray),
34-
pgpPublicRing := file(s"$gpgFolder/pubring.gpg"),
35-
pgpSecretRing := file(s"$gpgFolder/secring.gpg"),
36-
credentials += Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", sys.env.getOrElse("PUBLISH_USERNAME", ""), sys.env.getOrElse("PUBLISH_PASSWORD", "")),
37-
scmInfo := Some(ScmInfo(url("https://github.com/scala-exercises/exercises-scalatutorial"), "https://github.com/scala-exercises/exercises-scalatutorial.git")),
38-
licenses := Seq("Apache License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")),
39-
publishMavenStyle := true,
40-
publishArtifact in Test := false,
41-
pomIncludeRepository := Function.const(false),
42-
publishTo := {
43-
val nexus = "https://oss.sonatype.org/"
44-
if (isSnapshot.value)
45-
Some("Snapshots" at nexus + "content/repositories/snapshots")
46-
else
47-
Some("Releases" at nexus + "service/local/staging/deploy/maven2")
48-
}
49-
)
20+
pgpPassphrase := Some(getEnvVar("PGP_PASSPHRASE").getOrElse("").toCharArray)
21+
pgpPublicRing := file(s"$gpgFolder/pubring.gpg")
22+
pgpSecretRing := file(s"$gpgFolder/secring.gpg")

project/ProjectPlugin.scala

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import de.heikoseeberger.sbtheader.HeaderPattern
2+
import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport._
3+
import sbt.Keys._
4+
import sbt._
5+
import sbtorgpolicies._
6+
import sbtorgpolicies.model._
7+
import sbtorgpolicies.OrgPoliciesPlugin.autoImport._
8+
9+
object ProjectPlugin extends AutoPlugin {
10+
11+
override def trigger: PluginTrigger = allRequirements
12+
13+
override def requires: Plugins = plugins.JvmPlugin && OrgPoliciesPlugin
14+
15+
override def projectSettings: Seq[Def.Setting[_]] =
16+
Seq(
17+
description := "Scala Exercises: The path to enlightenment",
18+
startYear := Option(2016),
19+
orgGithubSetting := GitHubSettings(
20+
organization = "scala-exercises",
21+
project = name.value,
22+
organizationName = "Scala Exercises",
23+
groupId = "org.scala-exercises",
24+
organizationHomePage = url("https://www.scala-exercises.org"),
25+
organizationEmail = "hello@47deg.com"
26+
),
27+
orgLicenseSetting := ApacheLicense,
28+
scalaVersion := "2.11.8",
29+
scalaOrganization := "org.scala-lang",
30+
crossScalaVersions := Seq("2.11.8"),
31+
resolvers ++= Seq(
32+
Resolver.mavenLocal,
33+
Resolver.sonatypeRepo("snapshots"),
34+
Resolver.sonatypeRepo("releases")
35+
),
36+
scalacOptions := sbtorgpolicies.model.scalacCommonOptions,
37+
headers := Map(
38+
"scala" -> (HeaderPattern.cStyleBlockComment,
39+
s"""|/*
40+
| * scala-exercises - ${name.value}
41+
| * Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
42+
| */
43+
|
44+
|""".stripMargin)
45+
)
46+
)
47+
}

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version = 0.13.8
1+
sbt.version=0.13.13

project/plugins.sbt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
resolvers += Resolver.sonatypeRepo("snapshots")
2-
addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.3.0-SNAPSHOT", "0.13", "2.10")
3-
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
1+
resolvers ++= Seq(
2+
Resolver.sonatypeRepo("snapshots")
3+
)
4+
5+
addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.4.0-SNAPSHOT", "0.13", "2.10")
6+
addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.3.2")

src/main/scala/scalatutorial/ScalaTutorial.scala

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
1+
/*
2+
* scala-exercises - exercises-scalatutorial
3+
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
4+
*/
5+
16
package scalatutorial
27

38
import org.scalaexercises.definitions.Library
49

510
import sections._
611

712
/** Quickly learn Scala through an interactive tutorial based on the first two courses of the Scala MOOCs.
8-
*
9-
* @param name scala_tutorial
10-
*/
13+
*
14+
* @param name scala_tutorial
15+
*/
1116
object ScalaTutorial extends Library {
12-
val owner = "scala-exercises"
13-
val repository = "exercises-scalatutorial"
17+
val owner = "scala-exercises"
18+
val repository = "exercises-scalatutorial"
1419
override val color = Some("#f26527")
15-
val logoPath = "scala-tutorial"
20+
val logoPath = "scala-tutorial"
1621

1722
val sections = List(
1823
TermsAndTypes,
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
1+
/*
2+
* scala-exercises - exercises-scalatutorial
3+
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
4+
*/
5+
16
package scalatutorial.aux
27

38
class BankAccount {
49

510
private var balance = 0
611

7-
def deposit(amount: Int): Unit = {
12+
def deposit(amount: Int): Unit =
813
if (amount > 0) balance = balance + amount
9-
}
1014

1115
def withdraw(amount: Int): Int =
1216
if (0 < amount && amount <= balance) {
13-
balance = balance - amount
14-
balance
17+
balance = balance - amount
18+
balance
1519
} else throw new Error("insufficient funds")
16-
}
20+
}
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* scala-exercises - exercises-scalatutorial
3+
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
4+
*/
5+
16
package scalatutorial.aux
27

38
abstract class IntSet {
@@ -7,17 +12,17 @@ abstract class IntSet {
712

813
object Empty extends IntSet {
914
def contains(x: Int): Boolean = false
10-
def incl(x: Int): IntSet = new NonEmpty(x, Empty, Empty)
15+
def incl(x: Int): IntSet = new NonEmpty(x, Empty, Empty)
1116
}
1217
class NonEmpty(elem: Int, left: IntSet, right: IntSet) extends IntSet {
1318

1419
def contains(x: Int): Boolean =
1520
if (x < elem) left contains x
16-
else if (x > elem) right contains x
21+
else if (x > elem) right contains x
1722
else true
1823

1924
def incl(x: Int): IntSet =
2025
if (x < elem) new NonEmpty(elem, left incl x, right)
2126
else if (x > elem) new NonEmpty(elem, left, right incl x)
2227
else this
23-
}
28+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*
2+
* scala-exercises - exercises-scalatutorial
3+
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
4+
*/
5+
16
package scalatutorial.aux
27

38
case class Note(name: String, duration: String, octave: Int)

0 commit comments

Comments
 (0)