Permalink
Browse files

Integrates sbt-org-policies plugin (#23)

  • Loading branch information...
juanpedromoreno committed Mar 28, 2017
1 parent 61875df commit ff4ab4dc3c779acf4230327f6328f16ad4dd64d9
@@ -0,0 +1,23 @@
style = defaultWithAlign
maxColumn = 100

continuationIndent.callSite = 2

newlines {
sometimesBeforeColonInMethodReturnType = false
}

align {
arrowEnumeratorGenerator = false
ifWhileOpenParen = false
openParenCallSite = false
openParenDefnSite = false
}

docstrings = JavaDoc

rewrite {
rules = [SortImports, RedundantBraces]
redundantBraces.maxLines = 1
}

@@ -15,6 +15,3 @@ after_success:
- if [ "$TRAVIS_BRANCH" = "master" -a "$TRAVIS_PULL_REQUEST" = "false" ]; then
sbt compile publishSigned;
fi
- if [ "$TRAVIS_PULL_REQUEST" = "true" ]; then
echo "Not in master branch, skipping deploy and release";
fi
@@ -1,10 +1,9 @@
#Scala Exercises - ScalaCheck library

# Scala Exercises - ScalaCheck library
------------------------

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.

## About Scala exercises
## About Scala exercises

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

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

##License
## License

Copyright (C) 2015-2016 47 Degrees, LLC.
Reactive, scalable software solutions.
@@ -1,49 +1,23 @@
val scalaExerciesV = "0.4.0-SNAPSHOT"

def dep(artifactId: String) = "org.scala-exercises" %% artifactId % scalaExerciesV

lazy val scalacheck = (project in file("."))
.settings(publishSettings:_*)
.enablePlugins(ExerciseCompilerPlugin)
.settings(
organization := "org.scala-exercises",
name := "exercises-scalacheck",
scalaVersion := "2.11.8",
version := "0.3.0-SNAPSHOT",
resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots"),
Resolver.sonatypeRepo("releases")
),
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.1" exclude("org.scalacheck", "scalacheck"),
"org.scala-exercises" %% "exercise-compiler" % version.value excludeAll ExclusionRule("com.github.alexarchambault"),
"org.scala-exercises" %% "definitions" % version.value excludeAll ExclusionRule("com.github.alexarchambault"),
"com.fortysevendeg" %% "scalacheck-datetime" % "0.2.0",
"com.github.alexarchambault" %% "scalacheck-shapeless_1.13" % "1.1.3",
compilerPlugin("org.spire-math" %% "kind-projector" % "0.9.0")
.enablePlugins(ExerciseCompilerPlugin)
.settings(
name := "exercises-scalacheck",
libraryDependencies ++= Seq(
dep("exercise-compiler"),
dep("definitions"),
%%("scalatest"),
%%("scalacheck"),
%%("scheckShapeless"),
"com.fortysevendeg" %% "scalacheck-datetime" % "0.2.0"
)
)
)

// Distribution

lazy val gpgFolder = sys.env.getOrElse("PGP_FOLDER", ".")

lazy val publishSettings = Seq(
organizationName := "Scala Exercises",
organizationHomepage := Some(new URL("https://scala-exercises.org")),
startYear := Some(2016),
description := "Scala Exercises: The path to enlightenment",
homepage := Some(url("https://scala-exercises.org")),
pgpPassphrase := Some(sys.env.getOrElse("PGP_PASSPHRASE", "").toCharArray),
pgpPublicRing := file(s"$gpgFolder/pubring.gpg"),
pgpSecretRing := file(s"$gpgFolder/secring.gpg"),
credentials += Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", sys.env.getOrElse("PUBLISH_USERNAME", ""), sys.env.getOrElse("PUBLISH_PASSWORD", "")),
scmInfo := Some(ScmInfo(url("https://github.com/scala-exercises/exercises-scalacheck"), "https://github.com/scala-exercises/exercises-scalacheck.git")),
licenses := Seq("Apache License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")),
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := Function.const(false),
publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("Snapshots" at nexus + "content/repositories/snapshots")
else
Some("Releases" at nexus + "service/local/staging/deploy/maven2")
}
)
pgpPassphrase := Some(getEnvVar("PGP_PASSPHRASE").getOrElse("").toCharArray)
pgpPublicRing := file(s"$gpgFolder/pubring.gpg")
pgpSecretRing := file(s"$gpgFolder/secring.gpg")
@@ -0,0 +1,47 @@
import de.heikoseeberger.sbtheader.HeaderPattern
import de.heikoseeberger.sbtheader.HeaderPlugin.autoImport._
import sbt.Keys._
import sbt._
import sbtorgpolicies._
import sbtorgpolicies.model._
import sbtorgpolicies.OrgPoliciesPlugin.autoImport._

object ProjectPlugin extends AutoPlugin {

override def trigger: PluginTrigger = allRequirements

override def requires: Plugins = plugins.JvmPlugin && OrgPoliciesPlugin

override def projectSettings: Seq[Def.Setting[_]] =
Seq(
description := "Scala Exercises: The path to enlightenment",
startYear := Option(2016),
orgGithubSetting := GitHubSettings(
organization = "scala-exercises",
project = name.value,
organizationName = "Scala Exercises",
groupId = "org.scala-exercises",
organizationHomePage = url("https://www.scala-exercises.org"),
organizationEmail = "hello@47deg.com"
),
orgLicenseSetting := ApacheLicense,
scalaVersion := "2.11.8",
scalaOrganization := "org.scala-lang",
crossScalaVersions := Seq("2.11.8"),
resolvers ++= Seq(
Resolver.mavenLocal,
Resolver.sonatypeRepo("snapshots"),
Resolver.sonatypeRepo("releases")
),
scalacOptions := sbtorgpolicies.model.scalacCommonOptions,
headers := Map(
"scala" -> (HeaderPattern.cStyleBlockComment,
s"""|/*
| * scala-exercises - ${name.value}
| * Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
| */
|
|""".stripMargin)
)
)
}
2 project/build.properties 100755 → 100644
@@ -1 +1 @@
sbt.version=0.13.12
sbt.version=0.13.13
4 project/plugins.sbt 100755 → 100644
@@ -2,5 +2,5 @@ resolvers ++= Seq(
Resolver.sonatypeRepo("snapshots")
)

addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.3.0-SNAPSHOT", "0.13", "2.10")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
addSbtPlugin("org.scala-exercises" % "sbt-exercise" % "0.4.0-SNAPSHOT", "0.13", "2.10")
addSbtPlugin("com.47deg" % "sbt-org-policies" % "0.3.2")
@@ -1,39 +1,47 @@
/*
* scala-exercises - exercises-scalacheck
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
*/

package scalachecklib

import org.scalatest.Matchers
import org.scalatest.prop.Checkers

/** ==The `arbitrary` Generator==
*
* There is a special generator, `org.scalacheck.Arbitrary.arbitrary`, which generates arbitrary values of any
* supported type.
*
* {{{
* val evenInteger = Arbitrary.arbitrary[Int] suchThat (_ % 2 == 0)
* val squares = for {
* xs <- Arbitrary.arbitrary[List[Int]]
* } yield xs.map(x => x*x)
* }}}
*
* The `arbitrary` generator is the generator used by ScalaCheck when it generates values for ''property'' parameters.
* Most of the times, you have to supply the type of the value to `arbitrary`, like above, since Scala often can't
* infer the type automatically. You can use `arbitrary` for any type that has an implicit `Arbitrary` instance.
* As mentioned earlier, ScalaCheck has default support for common types, but it is also possible to define your own
* implicit `Arbitrary` instances for unsupported types. See the following implicit Arbitrary definition for booleans,
* that comes from the ScalaCheck implementation.
*
* {{{
* implicit lazy val arbBool: Arbitrary[Boolean] = Arbitrary(oneOf(true, false))
* }}}
*
* @param name arbitrary
*/
object ArbitrarySection extends Checkers with Matchers with org.scalaexercises.definitions.Section {
*
* There is a special generator, `org.scalacheck.Arbitrary.arbitrary`, which generates arbitrary values of any
* supported type.
*
* {{{
* val evenInteger = Arbitrary.arbitrary[Int] suchThat (_ % 2 == 0)
* val squares = for {
* xs <- Arbitrary.arbitrary[List[Int]]
* } yield xs.map(x => x*x)
* }}}
*
* The `arbitrary` generator is the generator used by ScalaCheck when it generates values for ''property'' parameters.
* Most of the times, you have to supply the type of the value to `arbitrary`, like above, since Scala often can't
* infer the type automatically. You can use `arbitrary` for any type that has an implicit `Arbitrary` instance.
* As mentioned earlier, ScalaCheck has default support for common types, but it is also possible to define your own
* implicit `Arbitrary` instances for unsupported types. See the following implicit Arbitrary definition for booleans,
* that comes from the ScalaCheck implementation.
*
* {{{
* implicit lazy val arbBool: Arbitrary[Boolean] = Arbitrary(oneOf(true, false))
* }}}
*
* @param name arbitrary
*/
object ArbitrarySection
extends Checkers
with Matchers
with org.scalaexercises.definitions.Section {

import GeneratorsHelper._

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

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

/** This becomes more useful when we're dealing with our own data types.
* We'll use the case class defined in the ''Generators Section'':
*
* {{{
* case class Foo(intValue: Int, charValue: Char)
* }}}
*
* Having an implicit `def` or `val` of our data type in the scope allow us to use the `forAll` method without
* specifying the ''generator''
*/
* We'll use the case class defined in the ''Generators Section'':
*
* {{{
* case class Foo(intValue: Int, charValue: Char)
* }}}
*
* Having an implicit `def` or `val` of our data type in the scope allow us to use the `forAll` method without
* specifying the ''generator''
*/
def implicitArbitraryCaseClass(res0: Boolean) = {

import org.scalacheck.Arbitrary
import org.scalacheck.Gen
import org.scalacheck.Prop.forAll

val fooGen = for {
intValue <- Gen.posNum[Int]
intValue <- Gen.posNum[Int]
charValue <- Gen.alphaChar
} yield Foo(intValue, charValue)

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

/** The `Arbitrary.arbitrary` method also returns a `Gen` object.
*/
*/
def useArbitraryOnGen(res0: Int) = {

import org.scalacheck.Arbitrary
@@ -1,3 +1,8 @@
/*
* scala-exercises - exercises-scalacheck
* Copyright (C) 2015-2016 47 Degrees, LLC. <http://www.47deg.com>
*/

package scalachecklib

object GeneratorsHelper {
Oops, something went wrong.

0 comments on commit ff4ab4d

Please sign in to comment.