Skip to content

Commit ff4ab4d

Browse files
Integrates sbt-org-policies plugin (#23)
1 parent 61875df commit ff4ab4d

19 files changed

+551
-435
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+

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,3 @@ after_success:
1515
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then
1616
sbt compile publishSigned;
1717
fi
18-
- if [ "$TRAVIS_PULL_REQUEST" = "true" ]; then
19-
echo "Not in master branch, skipping deploy and release";
20-
fi

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
#Scala Exercises - ScalaCheck library
2-
1+
# Scala Exercises - ScalaCheck library
32
------------------------
43

54
This repository hosts a content library for the [Scala Exercises](https://www.scala-exercises.org/) platform, including interactive exercises related to the [ScalaCheck](https://github.com/rickynils/scalacheck) testing library.
65

7-
## About Scala exercises
6+
## About Scala exercises
87

98
"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.
109

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

18-
##License
17+
## License
1918

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

build.sbt

Lines changed: 18 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,23 @@
1+
val scalaExerciesV = "0.4.0-SNAPSHOT"
2+
3+
def dep(artifactId: String) = "org.scala-exercises" %% artifactId % scalaExerciesV
4+
15
lazy val scalacheck = (project in file("."))
2-
.settings(publishSettings:_*)
3-
.enablePlugins(ExerciseCompilerPlugin)
4-
.settings(
5-
organization := "org.scala-exercises",
6-
name := "exercises-scalacheck",
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" % "3.0.1" exclude("org.scalacheck", "scalacheck"),
15-
"org.scala-exercises" %% "exercise-compiler" % version.value excludeAll ExclusionRule("com.github.alexarchambault"),
16-
"org.scala-exercises" %% "definitions" % version.value excludeAll ExclusionRule("com.github.alexarchambault"),
17-
"com.fortysevendeg" %% "scalacheck-datetime" % "0.2.0",
18-
"com.github.alexarchambault" %% "scalacheck-shapeless_1.13" % "1.1.3",
19-
compilerPlugin("org.spire-math" %% "kind-projector" % "0.9.0")
6+
.enablePlugins(ExerciseCompilerPlugin)
7+
.settings(
8+
name := "exercises-scalacheck",
9+
libraryDependencies ++= Seq(
10+
dep("exercise-compiler"),
11+
dep("definitions"),
12+
%%("scalatest"),
13+
%%("scalacheck"),
14+
%%("scheckShapeless"),
15+
"com.fortysevendeg" %% "scalacheck-datetime" % "0.2.0"
16+
)
2017
)
21-
)
2218

2319
// Distribution
2420

25-
lazy val gpgFolder = sys.env.getOrElse("PGP_FOLDER", ".")
26-
27-
lazy val publishSettings = Seq(
28-
organizationName := "Scala Exercises",
29-
organizationHomepage := Some(new URL("https://scala-exercises.org")),
30-
startYear := Some(2016),
31-
description := "Scala Exercises: The path to enlightenment",
32-
homepage := Some(url("https://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-scalacheck"), "https://github.com/scala-exercises/exercises-scalacheck.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-
)
21+
pgpPassphrase := Some(getEnvVar("PGP_PASSPHRASE").getOrElse("").toCharArray)
22+
pgpPublicRing := file(s"$gpgFolder/pubring.gpg")
23+
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

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

project/plugins.sbt

100755100644
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ resolvers ++= Seq(
22
Resolver.sonatypeRepo("snapshots")
33
)
44

5-
addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.3.0-SNAPSHOT", "0.13", "2.10")
6-
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
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/scalachecklib/ArbitrarySection.scala

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

38
import org.scalatest.Matchers
49
import org.scalatest.prop.Checkers
510

611
/** ==The `arbitrary` Generator==
7-
*
8-
* There is a special generator, `org.scalacheck.Arbitrary.arbitrary`, which generates arbitrary values of any
9-
* supported type.
10-
*
11-
* {{{
12-
* val evenInteger = Arbitrary.arbitrary[Int] suchThat (_ % 2 == 0)
13-
* val squares = for {
14-
* xs <- Arbitrary.arbitrary[List[Int]]
15-
* } yield xs.map(x => x*x)
16-
* }}}
17-
*
18-
* The `arbitrary` generator is the generator used by ScalaCheck when it generates values for ''property'' parameters.
19-
* Most of the times, you have to supply the type of the value to `arbitrary`, like above, since Scala often can't
20-
* infer the type automatically. You can use `arbitrary` for any type that has an implicit `Arbitrary` instance.
21-
* As mentioned earlier, ScalaCheck has default support for common types, but it is also possible to define your own
22-
* implicit `Arbitrary` instances for unsupported types. See the following implicit Arbitrary definition for booleans,
23-
* that comes from the ScalaCheck implementation.
24-
*
25-
* {{{
26-
* implicit lazy val arbBool: Arbitrary[Boolean] = Arbitrary(oneOf(true, false))
27-
* }}}
28-
*
29-
* @param name arbitrary
30-
*/
31-
object ArbitrarySection extends Checkers with Matchers with org.scalaexercises.definitions.Section {
12+
*
13+
* There is a special generator, `org.scalacheck.Arbitrary.arbitrary`, which generates arbitrary values of any
14+
* supported type.
15+
*
16+
* {{{
17+
* val evenInteger = Arbitrary.arbitrary[Int] suchThat (_ % 2 == 0)
18+
* val squares = for {
19+
* xs <- Arbitrary.arbitrary[List[Int]]
20+
* } yield xs.map(x => x*x)
21+
* }}}
22+
*
23+
* The `arbitrary` generator is the generator used by ScalaCheck when it generates values for ''property'' parameters.
24+
* Most of the times, you have to supply the type of the value to `arbitrary`, like above, since Scala often can't
25+
* infer the type automatically. You can use `arbitrary` for any type that has an implicit `Arbitrary` instance.
26+
* As mentioned earlier, ScalaCheck has default support for common types, but it is also possible to define your own
27+
* implicit `Arbitrary` instances for unsupported types. See the following implicit Arbitrary definition for booleans,
28+
* that comes from the ScalaCheck implementation.
29+
*
30+
* {{{
31+
* implicit lazy val arbBool: Arbitrary[Boolean] = Arbitrary(oneOf(true, false))
32+
* }}}
33+
*
34+
* @param name arbitrary
35+
*/
36+
object ArbitrarySection
37+
extends Checkers
38+
with Matchers
39+
with org.scalaexercises.definitions.Section {
3240

3341
import GeneratorsHelper._
3442

3543
/** Let's see an example where we're defining an `implicit` `arbitrary` instance for `Char`
36-
*/
44+
*/
3745
def implicitArbitraryChar(res0: Seq[Char]) = {
3846

3947
import org.scalacheck.Arbitrary
@@ -50,23 +58,23 @@ object ArbitrarySection extends Checkers with Matchers with org.scalaexercises.d
5058
}
5159

5260
/** This becomes more useful when we're dealing with our own data types.
53-
* We'll use the case class defined in the ''Generators Section'':
54-
*
55-
* {{{
56-
* case class Foo(intValue: Int, charValue: Char)
57-
* }}}
58-
*
59-
* Having an implicit `def` or `val` of our data type in the scope allow us to use the `forAll` method without
60-
* specifying the ''generator''
61-
*/
61+
* We'll use the case class defined in the ''Generators Section'':
62+
*
63+
* {{{
64+
* case class Foo(intValue: Int, charValue: Char)
65+
* }}}
66+
*
67+
* Having an implicit `def` or `val` of our data type in the scope allow us to use the `forAll` method without
68+
* specifying the ''generator''
69+
*/
6270
def implicitArbitraryCaseClass(res0: Boolean) = {
6371

6472
import org.scalacheck.Arbitrary
6573
import org.scalacheck.Gen
6674
import org.scalacheck.Prop.forAll
6775

6876
val fooGen = for {
69-
intValue <- Gen.posNum[Int]
77+
intValue <- Gen.posNum[Int]
7078
charValue <- Gen.alphaChar
7179
} yield Foo(intValue, charValue)
7280

@@ -78,7 +86,7 @@ object ArbitrarySection extends Checkers with Matchers with org.scalaexercises.d
7886
}
7987

8088
/** The `Arbitrary.arbitrary` method also returns a `Gen` object.
81-
*/
89+
*/
8290
def useArbitraryOnGen(res0: Int) = {
8391

8492
import org.scalacheck.Arbitrary

src/main/scala/scalachecklib/GeneratorsHelper.scala

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

38
object GeneratorsHelper {

0 commit comments

Comments
 (0)