Skip to content

Commit a60700b

Browse files
Integrates sbt-org-policies plugin (#41)
1 parent f8179e8 commit a60700b

38 files changed

+836
-629
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 - Shapeless
2-
1+
# Scala Exercises - Shapeless
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 [Shapeless](https://github.com/milessabin/shapeless) generic programming 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 & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,23 @@
1+
val scalaExerciesV = "0.4.0-SNAPSHOT"
2+
3+
def dep(artifactId: String) = "org.scala-exercises" %% artifactId % scalaExerciesV
4+
15
lazy val shapeless = (project in file("."))
2-
.settings(publishSettings:_*)
3-
.enablePlugins(ExerciseCompilerPlugin)
4-
.settings(
5-
organization := "org.scala-exercises",
6-
name := "exercises-shapeless",
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.typelevel" %% "cats-core" % "0.7.2",
15-
"com.chuusai" %% "shapeless" % "2.2.5",
16-
"org.scalatest" %% "scalatest" % "2.2.4",
17-
"org.scala-exercises" %% "exercise-compiler" % version.value,
18-
"org.scala-exercises" %% "definitions" % version.value,
19-
"org.scalacheck" %% "scalacheck" % "1.12.5",
20-
"com.github.alexarchambault" %% "scalacheck-shapeless_1.12" % "0.3.1",
21-
compilerPlugin("org.spire-math" %% "kind-projector" % "0.9.0")
6+
.enablePlugins(ExerciseCompilerPlugin)
7+
.settings(
8+
name := "exercises-shapeless",
9+
libraryDependencies ++= Seq(
10+
dep("exercise-compiler"),
11+
dep("definitions"),
12+
%%("shapeless"),
13+
%%("scalatest"),
14+
%%("scalacheck"),
15+
%%("scheckShapeless")
16+
)
2217
)
23-
)
2418

2519
// Distribution
2620

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

project/plugins.sbt

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/shapeless/ArityExercises.scala

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

38
import org.scalatest._
@@ -7,31 +12,32 @@ import ops.function._
712
import syntax.std.function._
813

914
object Helper {
10-
def applyProduct[P <: Product, F, L <: HList, R](p: P)(f: F)(implicit gen: Generic.Aux[P, L], fp: FnToProduct.Aux[F, L R]) =
15+
def applyProduct[P <: Product, F, L <: HList, R](p: P)(
16+
f: F)(implicit gen: Generic.Aux[P, L], fp: FnToProduct.Aux[F, L R]) =
1117
f.toProduct(gen.to(p))
1218
}
1319

1420
/** == Facilities for abstracting over arity ==
15-
*
16-
* Conversions between tuples and `HList`'s, and between ordinary Scala functions of arbitrary arity and functions which
17-
* take a single corresponding `HList` argument allow higher order functions to abstract over the arity of the functions
18-
* and values they are passed
19-
* {{{
20-
* import syntax.std.function._
21-
* import ops.function._
22-
*
23-
* def applyProduct[P <: Product, F, L <: HList, R](p: P)(f: F)
24-
* (implicit gen: Generic.Aux[P, L], fp: FnToProduct.Aux[F, L => R]) =
25-
* f.toProduct(gen.to(p))
26-
* }}}
27-
*
28-
* @param name arity
29-
*/
21+
*
22+
* Conversions between tuples and `HList`'s, and between ordinary Scala functions of arbitrary arity and functions which
23+
* take a single corresponding `HList` argument allow higher order functions to abstract over the arity of the functions
24+
* and values they are passed
25+
* {{{
26+
* import syntax.std.function._
27+
* import ops.function._
28+
*
29+
* def applyProduct[P <: Product, F, L <: HList, R](p: P)(f: F)
30+
* (implicit gen: Generic.Aux[P, L], fp: FnToProduct.Aux[F, L => R]) =
31+
* f.toProduct(gen.to(p))
32+
* }}}
33+
*
34+
* @param name arity
35+
*/
3036
object ArityExercises extends FlatSpec with Matchers with org.scalaexercises.definitions.Section {
3137
import Helper._
3238

3339
/** Abstracting over arity
34-
*/
40+
*/
3541
def arityTest(res0: Int, res1: Int) = {
3642
applyProduct(1, 2)((_: Int) + (_: Int)) should be(res0)
3743
applyProduct(1, 2, 3)((_: Int) * (_: Int) * (_: Int)) should be(res1)

0 commit comments

Comments
 (0)