Skip to content

Commit

Permalink
Add dev, CI, release mode functionality to the plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidGregory084 committed Mar 29, 2022
1 parent 5d5688f commit 43eab02
Show file tree
Hide file tree
Showing 13 changed files with 961 additions and 300 deletions.
7 changes: 7 additions & 0 deletions .scalafix.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
rules = [
OrganizeImports
]

OrganizeImports {
preset = INTELLIJ_2020_3
}
13 changes: 13 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version = 3.4.3

runner.dialect = scala212

preset = defaultWithAlign

maxColumn = 100

indent {
callSite = 2
defnSite = 2
extendSite = 2
}
21 changes: 14 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Common settings

name := "sbt-tpolecat"
description := "scalac options for the enlightened"
name := "sbt-tpolecat"
description := "scalac options for the enlightened"
organization := "io.github.davidgregory084"

organizationName := "David Gregory"
startYear := Some(2022)
startYear := Some(2022)
licenses += ("Apache-2.0", url("https://www.apache.org/licenses/LICENSE-2.0.html"))
scmInfo := Some(
ScmInfo(
Expand Down Expand Up @@ -34,20 +34,27 @@ addSbtPlugin("org.lyranthe.sbt" % "partial-unification" % "1.1.2")
// License headers

Compile / headerCreate := { (Compile / headerCreate).triggeredBy(Compile / compile).value }
Test / headerCreate := { (Test / headerCreate).triggeredBy(Test / compile).value }
Test / headerCreate := { (Test / headerCreate).triggeredBy(Test / compile).value }

scalacOptions += "-Xlint:unused"

libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.2.11" % Test,
"org.scalacheck" %% "scalacheck" % "1.15.4" % Test,
"org.scalatest" %% "scalatest" % "3.2.11" % Test,
"org.scalacheck" %% "scalacheck" % "1.15.4" % Test,
"org.scalatestplus" %% "scalacheck-1-15" % "3.2.11.0" % Test
)

ThisBuild / semanticdbEnabled := true
ThisBuild / semanticdbVersion := scalafixSemanticdb.revision
ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.6.0"

// Testing

scriptedBufferLog := false

scriptedLaunchOpts := scriptedLaunchOpts.value ++ Seq(
"-Xmx1024M", "-Dplugin.version=" + version.value
"-Xmx1024M",
"-Dplugin.version=" + version.value
)

test := {
Expand Down
4 changes: 4 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.5")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.7")

addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.6.2")

addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6")

addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.34")
23 changes: 23 additions & 0 deletions src/main/scala/io/github/davidgregory084/OptionsMode.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright 2022 David Gregory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.github.davidgregory084

sealed abstract class OptionsMode extends Product with Serializable

case object DevMode extends OptionsMode
case object CiMode extends OptionsMode
case object ReleaseMode extends OptionsMode
38 changes: 38 additions & 0 deletions src/main/scala/io/github/davidgregory084/ScalaVersion.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2022 David Gregory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.github.davidgregory084

import scala.Ordering.Implicits._

case class ScalaVersion(major: Long, minor: Long, patch: Long) {
def isBetween(addedVersion: ScalaVersion, removedVersion: ScalaVersion) =
this >= addedVersion && this < removedVersion
}

object ScalaVersion {
val V2_11_0 = ScalaVersion(2, 11, 0)
val V2_12_0 = ScalaVersion(2, 12, 0)
val V2_13_0 = ScalaVersion(2, 13, 0)
val V2_13_3 = ScalaVersion(2, 13, 3)
val V2_13_4 = ScalaVersion(2, 13, 4)
val V2_13_5 = ScalaVersion(2, 13, 5)
val V2_13_6 = ScalaVersion(2, 13, 6)
val V3_0_0 = ScalaVersion(3, 0, 0)

implicit val scalaVersionOrdering: Ordering[ScalaVersion] =
Ordering.by(version => (version.major, version.minor, version.patch))
}
22 changes: 22 additions & 0 deletions src/main/scala/io/github/davidgregory084/ScalacOption.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2022 David Gregory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.github.davidgregory084

case class ScalacOption(
tokens: List[String],
isSupported: ScalaVersion => Boolean = _ => true
)
Loading

0 comments on commit 43eab02

Please sign in to comment.