From 978ee2e58903fedae1e2dd0a162ea15aa250bdbd Mon Sep 17 00:00:00 2001 From: d10xa Date: Mon, 3 Feb 2020 00:40:11 +0300 Subject: [PATCH 1/6] Move GroupId to types --- build.sbt | 4 +++- .../scala/ru/d10xa/jadd/core/Artifact.scala | 9 +------- src/main/scala/ru/d10xa/jadd/core/types.scala | 22 +++++++++++++++++++ .../jadd/shortcuts/ArtifactInfoFinder.scala | 2 +- .../ru/d10xa/jadd/show/MavenShowCommand.scala | 2 +- .../ru/d10xa/jadd/show/SbtShowCommand.scala | 2 +- .../d10xa/jadd/ArtifactInfoFinderTest.scala | 2 +- .../scala/ru/d10xa/jadd/ArtifactTest.scala | 2 +- .../jadd/GradleArtifactProviderTest.scala | 2 +- .../code/inserts/SbtArtifactMatcherTest.scala | 2 +- .../code/inserts/SbtFileInsertsTest.scala | 2 +- ...MavenRemoteMetadataRepositoryApiTest.scala | 2 +- .../ArtifactVersionsDownloaderTest.scala | 2 +- .../ru/d10xa/jadd/view/ArtifactViewTest.scala | 2 +- 14 files changed, 37 insertions(+), 20 deletions(-) create mode 100644 src/main/scala/ru/d10xa/jadd/core/types.scala diff --git a/build.sbt b/build.sbt index e76edc05..8c27653c 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ name := "jadd" organization in ThisBuild := "ru.d10xa" scalaVersion in ThisBuild := "2.13.1" -version in ThisBuild := IO.read(new File("VERSION")).trim +version in ThisBuild := IO.read(file("VERSION")).trim mainClass in Compile := Some("ru.d10xa.jadd.Jadd") lazy val root = project @@ -63,3 +63,5 @@ libraryDependencies += "org.typelevel" %% "cats-effect" % "2.0.0" libraryDependencies += "com.github.pathikrit" %% "better-files" % "3.8.0" libraryDependencies += "io.get-coursier" %% "coursier-core" % "2.0.0-RC5-6" libraryDependencies += "org.antlr" % "antlr4-runtime" % "4.7.2" +libraryDependencies += "io.estatico" %% "newtype" % "0.4.3" +libraryDependencies += "eu.timepit" %% "refined" % "0.9.12" diff --git a/src/main/scala/ru/d10xa/jadd/core/Artifact.scala b/src/main/scala/ru/d10xa/jadd/core/Artifact.scala index 22453814..a84059d9 100644 --- a/src/main/scala/ru/d10xa/jadd/core/Artifact.scala +++ b/src/main/scala/ru/d10xa/jadd/core/Artifact.scala @@ -4,6 +4,7 @@ import cats.Show import cats.implicits._ import com.typesafe.scalalogging.StrictLogging import coursier.core.Version +import ru.d10xa.jadd.core.types.GroupId import ru.d10xa.jadd.repository.MavenMetadata import ru.d10xa.jadd.show.JaddFormatShowPrinter import troubles.ArtifactTrouble @@ -86,10 +87,6 @@ final case class Artifact( } -final case class GroupId(val value: String) extends AnyVal { - def path: String = value.replace('.', '/') -} - final case class ScalaVersion(val version: Version) extends AnyVal object ScalaVersion { @@ -98,10 +95,6 @@ object ScalaVersion { Show[ScalaVersion](_.version.repr) } -object GroupId { - implicit val showGroupId: Show[GroupId] = Show[GroupId](_.value.toString) -} - object Artifact { implicit val showArtifact: Show[Artifact] = (t: Artifact) => diff --git a/src/main/scala/ru/d10xa/jadd/core/types.scala b/src/main/scala/ru/d10xa/jadd/core/types.scala new file mode 100644 index 00000000..ecf63989 --- /dev/null +++ b/src/main/scala/ru/d10xa/jadd/core/types.scala @@ -0,0 +1,22 @@ +package ru.d10xa.jadd.core + +import cats.Show +//import eu.timepit.refined._ +//import eu.timepit.refined.types.string.NonEmptyString +//import io.estatico.newtype.macros.newtype + +object types { + +// @newtype case class GroupId(value: NonEmptyString) { +// def path: NonEmptyString = refineMV(value.value.replace('.', '/')) +// } + + final case class GroupId(val value: String) extends AnyVal { + def path: String = value.replace('.', '/') + } + + object GroupId { + implicit val showGroupId: Show[GroupId] = Show[GroupId](_.value.toString) + } + +} diff --git a/src/main/scala/ru/d10xa/jadd/shortcuts/ArtifactInfoFinder.scala b/src/main/scala/ru/d10xa/jadd/shortcuts/ArtifactInfoFinder.scala index 244a54ea..7ae7bae3 100644 --- a/src/main/scala/ru/d10xa/jadd/shortcuts/ArtifactInfoFinder.scala +++ b/src/main/scala/ru/d10xa/jadd/shortcuts/ArtifactInfoFinder.scala @@ -4,10 +4,10 @@ import cats.effect.Sync import cats.implicits._ import ru.d10xa.jadd.core.Artifact import ru.d10xa.jadd.core.ArtifactInfo -import ru.d10xa.jadd.core.GroupId import ru.d10xa.jadd.core.Scope import ru.d10xa.jadd.core.Utils import ru.d10xa.jadd.core.troubles +import ru.d10xa.jadd.core.types.GroupId import scala.util.Try diff --git a/src/main/scala/ru/d10xa/jadd/show/MavenShowCommand.scala b/src/main/scala/ru/d10xa/jadd/show/MavenShowCommand.scala index 27a95019..fe09d0c5 100644 --- a/src/main/scala/ru/d10xa/jadd/show/MavenShowCommand.scala +++ b/src/main/scala/ru/d10xa/jadd/show/MavenShowCommand.scala @@ -3,7 +3,7 @@ package ru.d10xa.jadd.show import com.typesafe.scalalogging.StrictLogging import coursier.core.Version import ru.d10xa.jadd.core.Artifact -import ru.d10xa.jadd.core.GroupId +import ru.d10xa.jadd.core.types.GroupId import scala.xml.Node import scala.xml.XML diff --git a/src/main/scala/ru/d10xa/jadd/show/SbtShowCommand.scala b/src/main/scala/ru/d10xa/jadd/show/SbtShowCommand.scala index c21c6a0b..a3b5099e 100644 --- a/src/main/scala/ru/d10xa/jadd/show/SbtShowCommand.scala +++ b/src/main/scala/ru/d10xa/jadd/show/SbtShowCommand.scala @@ -8,7 +8,7 @@ import ru.d10xa.jadd.core import ru.d10xa.jadd.cli.Config import ru.d10xa.jadd.core.Artifact import ru.d10xa.jadd.core.CodeBlock -import ru.d10xa.jadd.core.GroupId +import ru.d10xa.jadd.core.types.GroupId import ru.d10xa.jadd.core.ProjectFileReader import ru.d10xa.jadd.core.ScalaVersion import ru.d10xa.jadd.core.Scope diff --git a/src/test/scala/ru/d10xa/jadd/ArtifactInfoFinderTest.scala b/src/test/scala/ru/d10xa/jadd/ArtifactInfoFinderTest.scala index 95949133..4c212343 100644 --- a/src/test/scala/ru/d10xa/jadd/ArtifactInfoFinderTest.scala +++ b/src/test/scala/ru/d10xa/jadd/ArtifactInfoFinderTest.scala @@ -11,7 +11,7 @@ import ru.d10xa.jadd.core.troubles.ArtifactTrouble import cats.implicits._ import ru.d10xa.jadd.core.Artifact import ru.d10xa.jadd.core.ArtifactInfo -import ru.d10xa.jadd.core.GroupId +import ru.d10xa.jadd.core.types.GroupId import ru.d10xa.jadd.core.ScalaVersion import ru.d10xa.jadd.core.Scope diff --git a/src/test/scala/ru/d10xa/jadd/ArtifactTest.scala b/src/test/scala/ru/d10xa/jadd/ArtifactTest.scala index 20f63da8..c775a725 100644 --- a/src/test/scala/ru/d10xa/jadd/ArtifactTest.scala +++ b/src/test/scala/ru/d10xa/jadd/ArtifactTest.scala @@ -6,7 +6,7 @@ import ru.d10xa.jadd.testkit.TestBase import ru.d10xa.jadd.core.troubles.WrongArtifactRaw import cats.implicits._ import ru.d10xa.jadd.core.Artifact -import ru.d10xa.jadd.core.GroupId +import ru.d10xa.jadd.core.types.GroupId import ru.d10xa.jadd.core.ScalaVersion class ArtifactTest extends TestBase { diff --git a/src/test/scala/ru/d10xa/jadd/GradleArtifactProviderTest.scala b/src/test/scala/ru/d10xa/jadd/GradleArtifactProviderTest.scala index 17b05bd0..4d997f5b 100644 --- a/src/test/scala/ru/d10xa/jadd/GradleArtifactProviderTest.scala +++ b/src/test/scala/ru/d10xa/jadd/GradleArtifactProviderTest.scala @@ -4,7 +4,7 @@ import coursier.core.Version import ru.d10xa.jadd.core.ArtifactProvider import ru.d10xa.jadd.core.ArtifactProvider.GradleBuildDescription import ru.d10xa.jadd.core.Artifact -import ru.d10xa.jadd.core.GroupId +import ru.d10xa.jadd.core.types.GroupId import ru.d10xa.jadd.core.ScalaVersion import ru.d10xa.jadd.testkit.TestBase diff --git a/src/test/scala/ru/d10xa/jadd/code/inserts/SbtArtifactMatcherTest.scala b/src/test/scala/ru/d10xa/jadd/code/inserts/SbtArtifactMatcherTest.scala index 8a65103f..82ceb8e4 100644 --- a/src/test/scala/ru/d10xa/jadd/code/inserts/SbtArtifactMatcherTest.scala +++ b/src/test/scala/ru/d10xa/jadd/code/inserts/SbtArtifactMatcherTest.scala @@ -1,7 +1,7 @@ package ru.d10xa.jadd.code.inserts import ru.d10xa.jadd.core.Artifact -import ru.d10xa.jadd.core.GroupId +import ru.d10xa.jadd.core.types.GroupId import ru.d10xa.jadd.testkit.TestBase import ru.d10xa.jadd.view.ArtifactView import ru.d10xa.jadd.view.ArtifactView.MatchImpl diff --git a/src/test/scala/ru/d10xa/jadd/code/inserts/SbtFileInsertsTest.scala b/src/test/scala/ru/d10xa/jadd/code/inserts/SbtFileInsertsTest.scala index cdfb4cfe..298a5077 100644 --- a/src/test/scala/ru/d10xa/jadd/code/inserts/SbtFileInsertsTest.scala +++ b/src/test/scala/ru/d10xa/jadd/code/inserts/SbtFileInsertsTest.scala @@ -2,7 +2,7 @@ package ru.d10xa.jadd.code.inserts import coursier.core.Version import ru.d10xa.jadd.core.Artifact -import ru.d10xa.jadd.core.GroupId +import ru.d10xa.jadd.core.types.GroupId import ru.d10xa.jadd.core.ScalaVersion import ru.d10xa.jadd.testkit.TestBase diff --git a/src/test/scala/ru/d10xa/jadd/it/MavenRemoteMetadataRepositoryApiTest.scala b/src/test/scala/ru/d10xa/jadd/it/MavenRemoteMetadataRepositoryApiTest.scala index 4a279440..e8a1a46e 100644 --- a/src/test/scala/ru/d10xa/jadd/it/MavenRemoteMetadataRepositoryApiTest.scala +++ b/src/test/scala/ru/d10xa/jadd/it/MavenRemoteMetadataRepositoryApiTest.scala @@ -1,7 +1,7 @@ package ru.d10xa.jadd.it import ru.d10xa.jadd.core.Artifact -import ru.d10xa.jadd.core.GroupId +import ru.d10xa.jadd.core.types.GroupId import ru.d10xa.jadd.core.ScalaVersion import ru.d10xa.jadd.repository.MavenRemoteMetadataRepositoryApi import ru.d10xa.jadd.testkit.WireMockTestBase diff --git a/src/test/scala/ru/d10xa/jadd/versions/ArtifactVersionsDownloaderTest.scala b/src/test/scala/ru/d10xa/jadd/versions/ArtifactVersionsDownloaderTest.scala index 0f8986c6..f87dce0e 100644 --- a/src/test/scala/ru/d10xa/jadd/versions/ArtifactVersionsDownloaderTest.scala +++ b/src/test/scala/ru/d10xa/jadd/versions/ArtifactVersionsDownloaderTest.scala @@ -3,7 +3,7 @@ package ru.d10xa.jadd.versions import cats.implicits._ import coursier.core.Version import ru.d10xa.jadd.core.Artifact -import ru.d10xa.jadd.core.GroupId +import ru.d10xa.jadd.core.types.GroupId import ru.d10xa.jadd.testkit.TestBase class ArtifactVersionsDownloaderTest extends TestBase { diff --git a/src/test/scala/ru/d10xa/jadd/view/ArtifactViewTest.scala b/src/test/scala/ru/d10xa/jadd/view/ArtifactViewTest.scala index 32c81716..24219e31 100644 --- a/src/test/scala/ru/d10xa/jadd/view/ArtifactViewTest.scala +++ b/src/test/scala/ru/d10xa/jadd/view/ArtifactViewTest.scala @@ -1,7 +1,7 @@ package ru.d10xa.jadd.view import ru.d10xa.jadd.core.Artifact -import ru.d10xa.jadd.core.GroupId +import ru.d10xa.jadd.core.types.GroupId import ru.d10xa.jadd.core.ScalaVersion import ru.d10xa.jadd.code.inserts.SbtArtifactMatcher import ru.d10xa.jadd.testkit.TestBase From efbf85581d46b9dbd4b216a6fb21b1c62df1539a Mon Sep 17 00:00:00 2001 From: d10xa Date: Mon, 3 Feb 2020 11:12:12 +0300 Subject: [PATCH 2/6] @newtype GroupId --- build.sbt | 3 ++- project/plugins.sbt | 3 +++ src/main/scala/ru/d10xa/jadd/core/types.scala | 19 +++++++++++++++---- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index c0d3c098..e4e492d9 100644 --- a/build.sbt +++ b/build.sbt @@ -16,7 +16,8 @@ lazy val root = project "-feature", // warn about misused language features "-language:higherKinds", // allow higher kinded types without `import scala.language.higherKinds` "-Xlint", // enable handy linter warnings - "-Xfatal-warnings" // turn compiler warnings into errors + "-Xfatal-warnings", // turn compiler warnings into errors, + "-Ymacro-annotations" // for @newtype ) ) diff --git a/project/plugins.sbt b/project/plugins.sbt index e80fee51..13cb2fcb 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,4 +2,7 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.6.1") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1") addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7") addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.4.3") +addCompilerPlugin( + ("org.scalamacros" % "paradise" % "2.1.1").cross(CrossVersion.full)) + ///https://dl.bintray.com/sbt/sbt-plugin-releases/com.typesafe.sbt/sbt-native-packager/scala_2.12/sbt_1.0/ diff --git a/src/main/scala/ru/d10xa/jadd/core/types.scala b/src/main/scala/ru/d10xa/jadd/core/types.scala index ecf63989..2c530ebe 100644 --- a/src/main/scala/ru/d10xa/jadd/core/types.scala +++ b/src/main/scala/ru/d10xa/jadd/core/types.scala @@ -3,18 +3,29 @@ package ru.d10xa.jadd.core import cats.Show //import eu.timepit.refined._ //import eu.timepit.refined.types.string.NonEmptyString -//import io.estatico.newtype.macros.newtype +import io.estatico.newtype.macros.newtype +import scala.language.implicitConversions +/** + * Warnings disabled because of @newtype + */ +@SuppressWarnings( + Array( + "org.wartremover.warts.FinalCaseClass", + "org.wartremover.warts.ImplicitParameter", + "org.wartremover.warts.PublicInference", + "org.wartremover.warts.ImplicitConversion" + )) object types { // @newtype case class GroupId(value: NonEmptyString) { // def path: NonEmptyString = refineMV(value.value.replace('.', '/')) // } - final case class GroupId(val value: String) extends AnyVal { - def path: String = value.replace('.', '/') + @newtype case class GroupId(value: String) { + def path: String = + value.replace('.', '/') //refineMV(value.value.replace('.', '/')) } - object GroupId { implicit val showGroupId: Show[GroupId] = Show[GroupId](_.value.toString) } From 75bed2c210b808b66bb2f0898e7009b954784f42 Mon Sep 17 00:00:00 2001 From: d10xa Date: Tue, 4 Feb 2020 22:44:40 +0300 Subject: [PATCH 3/6] Add kind-projector Remove paradise --- build.sbt | 3 +++ project/plugins.sbt | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index e4e492d9..e864a34a 100644 --- a/build.sbt +++ b/build.sbt @@ -22,6 +22,9 @@ lazy val root = project ) enablePlugins(JavaAppPackaging) + +addCompilerPlugin("org.typelevel" %% "kind-projector" % "0.11.0" cross CrossVersion.full) + //wartremoverErrors ++= Warts.unsafe wartremoverErrors in (Compile, compile) ++= Seq( // Wart.Any, diff --git a/project/plugins.sbt b/project/plugins.sbt index 13cb2fcb..c4321aac 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,7 +2,5 @@ addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.6.1") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1") addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.2.7") addSbtPlugin("org.wartremover" % "sbt-wartremover" % "2.4.3") -addCompilerPlugin( - ("org.scalamacros" % "paradise" % "2.1.1").cross(CrossVersion.full)) ///https://dl.bintray.com/sbt/sbt-plugin-releases/com.typesafe.sbt/sbt-native-packager/scala_2.12/sbt_1.0/ From d187dba4bf4e361d5c81194df502f167ec986a27 Mon Sep 17 00:00:00 2001 From: d10xa Date: Tue, 4 Feb 2020 23:36:44 +0300 Subject: [PATCH 4/6] @newtype ScalaVersion --- src/main/scala/ru/d10xa/jadd/cli/Cli.scala | 2 +- src/main/scala/ru/d10xa/jadd/cli/Config.scala | 2 +- .../jadd/code/inserts/SbtArtifactMatcher.scala | 2 +- src/main/scala/ru/d10xa/jadd/core/Artifact.scala | 9 +-------- src/main/scala/ru/d10xa/jadd/core/types.scala | 14 ++++++++------ .../ru/d10xa/jadd/pipelines/AmmonitePipeline.scala | 2 +- .../ru/d10xa/jadd/pipelines/GradlePipeline.scala | 2 +- .../ru/d10xa/jadd/pipelines/MavenPipeline.scala | 2 +- .../scala/ru/d10xa/jadd/pipelines/Pipeline.scala | 2 +- .../ru/d10xa/jadd/pipelines/SbtPipeline.scala | 2 +- .../jadd/pipelines/UnknownProjectPipeline.scala | 2 +- .../ru/d10xa/jadd/repository/MavenMetadata.scala | 2 +- .../scala/ru/d10xa/jadd/show/SbtShowCommand.scala | 2 +- .../ru/d10xa/jadd/versions/ScalaVersions.scala | 2 +- .../ru/d10xa/jadd/ArtifactInfoFinderTest.scala | 2 +- src/test/scala/ru/d10xa/jadd/ArtifactTest.scala | 2 +- .../ru/d10xa/jadd/GradleArtifactProviderTest.scala | 2 +- .../jadd/code/inserts/SbtFileInsertsTest.scala | 2 +- .../it/MavenRemoteMetadataRepositoryApiTest.scala | 2 +- .../ru/d10xa/jadd/pipelines/SbtPipelineTest.scala | 2 +- .../scala/ru/d10xa/jadd/testkit/TestBase.scala | 2 +- .../ru/d10xa/jadd/view/ArtifactViewTest.scala | 2 +- 22 files changed, 29 insertions(+), 34 deletions(-) diff --git a/src/main/scala/ru/d10xa/jadd/cli/Cli.scala b/src/main/scala/ru/d10xa/jadd/cli/Cli.scala index d102eb3f..ff9a08bb 100644 --- a/src/main/scala/ru/d10xa/jadd/cli/Cli.scala +++ b/src/main/scala/ru/d10xa/jadd/cli/Cli.scala @@ -5,7 +5,7 @@ import ru.d10xa.jadd.cli.Command.Install import ru.d10xa.jadd.cli.Command.Search import ru.d10xa.jadd.cli.Command.Show import ru.d10xa.jadd.core.Ctx -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion import ru.d10xa.jadd.show.JaddFormatShowPrinter import ru.d10xa.jadd.show.ShowPrinter import scopt.OptionDef diff --git a/src/main/scala/ru/d10xa/jadd/cli/Config.scala b/src/main/scala/ru/d10xa/jadd/cli/Config.scala index c4608e67..b8657daf 100644 --- a/src/main/scala/ru/d10xa/jadd/cli/Config.scala +++ b/src/main/scala/ru/d10xa/jadd/cli/Config.scala @@ -1,7 +1,7 @@ package ru.d10xa.jadd.cli import ru.d10xa.jadd.cli.Command.Repl -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion import ru.d10xa.jadd.repository.RepositoryConstants import ru.d10xa.jadd.show.JaddFormatShowPrinter import ru.d10xa.jadd.show.ShowPrinter diff --git a/src/main/scala/ru/d10xa/jadd/code/inserts/SbtArtifactMatcher.scala b/src/main/scala/ru/d10xa/jadd/code/inserts/SbtArtifactMatcher.scala index 3190ad8c..11c30ee8 100644 --- a/src/main/scala/ru/d10xa/jadd/code/inserts/SbtArtifactMatcher.scala +++ b/src/main/scala/ru/d10xa/jadd/code/inserts/SbtArtifactMatcher.scala @@ -3,7 +3,7 @@ package ru.d10xa.jadd.code.inserts import cats.implicits._ import ru.d10xa.jadd.core.Artifact import ru.d10xa.jadd.core.CodeBlock -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion import ru.d10xa.jadd.view.ArtifactView.Match import scala.util.matching.Regex diff --git a/src/main/scala/ru/d10xa/jadd/core/Artifact.scala b/src/main/scala/ru/d10xa/jadd/core/Artifact.scala index a84059d9..65fb1cac 100644 --- a/src/main/scala/ru/d10xa/jadd/core/Artifact.scala +++ b/src/main/scala/ru/d10xa/jadd/core/Artifact.scala @@ -5,6 +5,7 @@ import cats.implicits._ import com.typesafe.scalalogging.StrictLogging import coursier.core.Version import ru.d10xa.jadd.core.types.GroupId +import ru.d10xa.jadd.core.types.ScalaVersion import ru.d10xa.jadd.repository.MavenMetadata import ru.d10xa.jadd.show.JaddFormatShowPrinter import troubles.ArtifactTrouble @@ -87,14 +88,6 @@ final case class Artifact( } -final case class ScalaVersion(val version: Version) extends AnyVal - -object ScalaVersion { - def fromString(str: String): ScalaVersion = ScalaVersion(Version(str)) - implicit val showScalaVersion: Show[ScalaVersion] = - Show[ScalaVersion](_.version.repr) -} - object Artifact { implicit val showArtifact: Show[Artifact] = (t: Artifact) => diff --git a/src/main/scala/ru/d10xa/jadd/core/types.scala b/src/main/scala/ru/d10xa/jadd/core/types.scala index 2c530ebe..dd802e9f 100644 --- a/src/main/scala/ru/d10xa/jadd/core/types.scala +++ b/src/main/scala/ru/d10xa/jadd/core/types.scala @@ -1,9 +1,9 @@ package ru.d10xa.jadd.core import cats.Show -//import eu.timepit.refined._ -//import eu.timepit.refined.types.string.NonEmptyString +import coursier.core.Version import io.estatico.newtype.macros.newtype + import scala.language.implicitConversions /** @@ -18,10 +18,6 @@ import scala.language.implicitConversions )) object types { -// @newtype case class GroupId(value: NonEmptyString) { -// def path: NonEmptyString = refineMV(value.value.replace('.', '/')) -// } - @newtype case class GroupId(value: String) { def path: String = value.replace('.', '/') //refineMV(value.value.replace('.', '/')) @@ -30,4 +26,10 @@ object types { implicit val showGroupId: Show[GroupId] = Show[GroupId](_.value.toString) } + @newtype case class ScalaVersion(version: Version) + object ScalaVersion { + def fromString(str: String): ScalaVersion = ScalaVersion(Version(str)) + implicit val showScalaVersion: Show[ScalaVersion] = + Show[ScalaVersion](_.version.repr) + } } diff --git a/src/main/scala/ru/d10xa/jadd/pipelines/AmmonitePipeline.scala b/src/main/scala/ru/d10xa/jadd/pipelines/AmmonitePipeline.scala index 741a10b7..fe25e2f5 100644 --- a/src/main/scala/ru/d10xa/jadd/pipelines/AmmonitePipeline.scala +++ b/src/main/scala/ru/d10xa/jadd/pipelines/AmmonitePipeline.scala @@ -8,7 +8,7 @@ import ru.d10xa.jadd.core.Artifact import ru.d10xa.jadd.core.Ctx import ru.d10xa.jadd.core.ProjectFileReader import ru.d10xa.jadd.core.SafeFileWriter -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion import ru.d10xa.jadd.show.AmmoniteFormatShowPrinter import ru.d10xa.jadd.versions.ScalaVersions diff --git a/src/main/scala/ru/d10xa/jadd/pipelines/GradlePipeline.scala b/src/main/scala/ru/d10xa/jadd/pipelines/GradlePipeline.scala index 5c13a75c..2acebca6 100644 --- a/src/main/scala/ru/d10xa/jadd/pipelines/GradlePipeline.scala +++ b/src/main/scala/ru/d10xa/jadd/pipelines/GradlePipeline.scala @@ -7,7 +7,7 @@ import com.typesafe.scalalogging.StrictLogging import ru.d10xa.jadd.core.Artifact import ru.d10xa.jadd.core.Ctx import ru.d10xa.jadd.core.SafeFileWriter -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion import ru.d10xa.jadd.code.inserts.GradleFileInserts import ru.d10xa.jadd.shortcuts.ArtifactInfoFinder import ru.d10xa.jadd.show.GradleShowCommand diff --git a/src/main/scala/ru/d10xa/jadd/pipelines/MavenPipeline.scala b/src/main/scala/ru/d10xa/jadd/pipelines/MavenPipeline.scala index e93ede6b..5f23a4d8 100644 --- a/src/main/scala/ru/d10xa/jadd/pipelines/MavenPipeline.scala +++ b/src/main/scala/ru/d10xa/jadd/pipelines/MavenPipeline.scala @@ -9,7 +9,7 @@ import ru.d10xa.jadd.code.Indentation import ru.d10xa.jadd.core.Artifact import ru.d10xa.jadd.core.Ctx import ru.d10xa.jadd.core.SafeFileWriter -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion import ru.d10xa.jadd.code.inserts.MavenFileInserts import ru.d10xa.jadd.shortcuts.ArtifactInfoFinder import ru.d10xa.jadd.show.MavenFormatShowPrinter diff --git a/src/main/scala/ru/d10xa/jadd/pipelines/Pipeline.scala b/src/main/scala/ru/d10xa/jadd/pipelines/Pipeline.scala index 679b2a5e..44a7c366 100644 --- a/src/main/scala/ru/d10xa/jadd/pipelines/Pipeline.scala +++ b/src/main/scala/ru/d10xa/jadd/pipelines/Pipeline.scala @@ -14,7 +14,7 @@ import ru.d10xa.jadd.core.Artifact import ru.d10xa.jadd.core.Ctx import ru.d10xa.jadd.core.Loader import ru.d10xa.jadd.core.ProjectMeta -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion import ru.d10xa.jadd.core.Utils import ru.d10xa.jadd.core.troubles import ru.d10xa.jadd.core.troubles.ArtifactTrouble diff --git a/src/main/scala/ru/d10xa/jadd/pipelines/SbtPipeline.scala b/src/main/scala/ru/d10xa/jadd/pipelines/SbtPipeline.scala index aeeccf2d..cf73dce3 100644 --- a/src/main/scala/ru/d10xa/jadd/pipelines/SbtPipeline.scala +++ b/src/main/scala/ru/d10xa/jadd/pipelines/SbtPipeline.scala @@ -8,7 +8,7 @@ import ru.d10xa.jadd.core.Artifact import ru.d10xa.jadd.core.Ctx import ru.d10xa.jadd.core.ProjectFileReader import ru.d10xa.jadd.core.SafeFileWriter -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion import ru.d10xa.jadd.code.inserts.SbtFileInserts import ru.d10xa.jadd.shortcuts.ArtifactInfoFinder import ru.d10xa.jadd.show.SbtShowCommand diff --git a/src/main/scala/ru/d10xa/jadd/pipelines/UnknownProjectPipeline.scala b/src/main/scala/ru/d10xa/jadd/pipelines/UnknownProjectPipeline.scala index 84f54518..159d84f6 100644 --- a/src/main/scala/ru/d10xa/jadd/pipelines/UnknownProjectPipeline.scala +++ b/src/main/scala/ru/d10xa/jadd/pipelines/UnknownProjectPipeline.scala @@ -5,7 +5,7 @@ import cats.implicits._ import com.typesafe.scalalogging.StrictLogging import ru.d10xa.jadd.core.Artifact import ru.d10xa.jadd.core.Ctx -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion import ru.d10xa.jadd.shortcuts.ArtifactInfoFinder import ru.d10xa.jadd.versions.ScalaVersions diff --git a/src/main/scala/ru/d10xa/jadd/repository/MavenMetadata.scala b/src/main/scala/ru/d10xa/jadd/repository/MavenMetadata.scala index ff0dd734..3a06bcb5 100644 --- a/src/main/scala/ru/d10xa/jadd/repository/MavenMetadata.scala +++ b/src/main/scala/ru/d10xa/jadd/repository/MavenMetadata.scala @@ -3,7 +3,7 @@ package ru.d10xa.jadd.repository import java.time.LocalDateTime import java.time.format.DateTimeFormatter -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion import ru.d10xa.jadd.xml.MavenMetadataVersionsRawReader import scala.util.Try diff --git a/src/main/scala/ru/d10xa/jadd/show/SbtShowCommand.scala b/src/main/scala/ru/d10xa/jadd/show/SbtShowCommand.scala index a3b5099e..a8a68f6a 100644 --- a/src/main/scala/ru/d10xa/jadd/show/SbtShowCommand.scala +++ b/src/main/scala/ru/d10xa/jadd/show/SbtShowCommand.scala @@ -10,7 +10,7 @@ import ru.d10xa.jadd.core.Artifact import ru.d10xa.jadd.core.CodeBlock import ru.d10xa.jadd.core.types.GroupId import ru.d10xa.jadd.core.ProjectFileReader -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion import ru.d10xa.jadd.core.Scope import ru.d10xa.jadd.generated.antlr.SbtDependenciesBaseVisitor import ru.d10xa.jadd.generated.antlr.SbtDependenciesLexer diff --git a/src/main/scala/ru/d10xa/jadd/versions/ScalaVersions.scala b/src/main/scala/ru/d10xa/jadd/versions/ScalaVersions.scala index cc7daf6b..350a80c8 100644 --- a/src/main/scala/ru/d10xa/jadd/versions/ScalaVersions.scala +++ b/src/main/scala/ru/d10xa/jadd/versions/ScalaVersions.scala @@ -1,7 +1,7 @@ package ru.d10xa.jadd.versions import cats.data.NonEmptyList -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion object ScalaVersions { val supportedMinorVersions: NonEmptyList[ScalaVersion] = diff --git a/src/test/scala/ru/d10xa/jadd/ArtifactInfoFinderTest.scala b/src/test/scala/ru/d10xa/jadd/ArtifactInfoFinderTest.scala index 4c212343..f93055b4 100644 --- a/src/test/scala/ru/d10xa/jadd/ArtifactInfoFinderTest.scala +++ b/src/test/scala/ru/d10xa/jadd/ArtifactInfoFinderTest.scala @@ -12,7 +12,7 @@ import cats.implicits._ import ru.d10xa.jadd.core.Artifact import ru.d10xa.jadd.core.ArtifactInfo import ru.d10xa.jadd.core.types.GroupId -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion import ru.d10xa.jadd.core.Scope class ArtifactInfoFinderTest extends TestBase { diff --git a/src/test/scala/ru/d10xa/jadd/ArtifactTest.scala b/src/test/scala/ru/d10xa/jadd/ArtifactTest.scala index c775a725..2b4c2649 100644 --- a/src/test/scala/ru/d10xa/jadd/ArtifactTest.scala +++ b/src/test/scala/ru/d10xa/jadd/ArtifactTest.scala @@ -7,7 +7,7 @@ import ru.d10xa.jadd.core.troubles.WrongArtifactRaw import cats.implicits._ import ru.d10xa.jadd.core.Artifact import ru.d10xa.jadd.core.types.GroupId -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion class ArtifactTest extends TestBase { diff --git a/src/test/scala/ru/d10xa/jadd/GradleArtifactProviderTest.scala b/src/test/scala/ru/d10xa/jadd/GradleArtifactProviderTest.scala index 4d997f5b..b76fe363 100644 --- a/src/test/scala/ru/d10xa/jadd/GradleArtifactProviderTest.scala +++ b/src/test/scala/ru/d10xa/jadd/GradleArtifactProviderTest.scala @@ -5,7 +5,7 @@ import ru.d10xa.jadd.core.ArtifactProvider import ru.d10xa.jadd.core.ArtifactProvider.GradleBuildDescription import ru.d10xa.jadd.core.Artifact import ru.d10xa.jadd.core.types.GroupId -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion import ru.d10xa.jadd.testkit.TestBase class GradleArtifactProviderTest extends TestBase { diff --git a/src/test/scala/ru/d10xa/jadd/code/inserts/SbtFileInsertsTest.scala b/src/test/scala/ru/d10xa/jadd/code/inserts/SbtFileInsertsTest.scala index 298a5077..ddc31c91 100644 --- a/src/test/scala/ru/d10xa/jadd/code/inserts/SbtFileInsertsTest.scala +++ b/src/test/scala/ru/d10xa/jadd/code/inserts/SbtFileInsertsTest.scala @@ -3,7 +3,7 @@ package ru.d10xa.jadd.code.inserts import coursier.core.Version import ru.d10xa.jadd.core.Artifact import ru.d10xa.jadd.core.types.GroupId -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion import ru.d10xa.jadd.testkit.TestBase class SbtFileInsertsTest extends TestBase { diff --git a/src/test/scala/ru/d10xa/jadd/it/MavenRemoteMetadataRepositoryApiTest.scala b/src/test/scala/ru/d10xa/jadd/it/MavenRemoteMetadataRepositoryApiTest.scala index e8a1a46e..6d32e6f1 100644 --- a/src/test/scala/ru/d10xa/jadd/it/MavenRemoteMetadataRepositoryApiTest.scala +++ b/src/test/scala/ru/d10xa/jadd/it/MavenRemoteMetadataRepositoryApiTest.scala @@ -2,7 +2,7 @@ package ru.d10xa.jadd.it import ru.d10xa.jadd.core.Artifact import ru.d10xa.jadd.core.types.GroupId -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion import ru.d10xa.jadd.repository.MavenRemoteMetadataRepositoryApi import ru.d10xa.jadd.testkit.WireMockTestBase diff --git a/src/test/scala/ru/d10xa/jadd/pipelines/SbtPipelineTest.scala b/src/test/scala/ru/d10xa/jadd/pipelines/SbtPipelineTest.scala index 2292d497..2707d46b 100644 --- a/src/test/scala/ru/d10xa/jadd/pipelines/SbtPipelineTest.scala +++ b/src/test/scala/ru/d10xa/jadd/pipelines/SbtPipelineTest.scala @@ -1,6 +1,6 @@ package ru.d10xa.jadd.pipelines -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion import ru.d10xa.jadd.testkit.TestBase class SbtPipelineTest extends TestBase { diff --git a/src/test/scala/ru/d10xa/jadd/testkit/TestBase.scala b/src/test/scala/ru/d10xa/jadd/testkit/TestBase.scala index 87ddc5be..9cdce5b6 100644 --- a/src/test/scala/ru/d10xa/jadd/testkit/TestBase.scala +++ b/src/test/scala/ru/d10xa/jadd/testkit/TestBase.scala @@ -3,7 +3,7 @@ package ru.d10xa.jadd.testkit import org.scalatest.funsuite.AnyFunSuiteLike import org.scalatest.matchers.should.Matchers import ru.d10xa.jadd.core.Artifact -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion abstract class TestBase extends AnyFunSuiteLike with Matchers { implicit class ArtifactImplicits(private val artifact: Artifact) { diff --git a/src/test/scala/ru/d10xa/jadd/view/ArtifactViewTest.scala b/src/test/scala/ru/d10xa/jadd/view/ArtifactViewTest.scala index 24219e31..21faf065 100644 --- a/src/test/scala/ru/d10xa/jadd/view/ArtifactViewTest.scala +++ b/src/test/scala/ru/d10xa/jadd/view/ArtifactViewTest.scala @@ -2,7 +2,7 @@ package ru.d10xa.jadd.view import ru.d10xa.jadd.core.Artifact import ru.d10xa.jadd.core.types.GroupId -import ru.d10xa.jadd.core.ScalaVersion +import ru.d10xa.jadd.core.types.ScalaVersion import ru.d10xa.jadd.code.inserts.SbtArtifactMatcher import ru.d10xa.jadd.testkit.TestBase import ru.d10xa.jadd.view.ArtifactView.Match From 1098c44701badc1c355a353a5dbf78e71be3fe81 Mon Sep 17 00:00:00 2001 From: d10xa Date: Tue, 4 Feb 2020 23:38:28 +0300 Subject: [PATCH 5/6] //refined --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index e864a34a..c07dced5 100644 --- a/build.sbt +++ b/build.sbt @@ -68,4 +68,4 @@ libraryDependencies += "com.github.pathikrit" %% "better-files" % "3.8.0" libraryDependencies += "io.get-coursier" %% "coursier-core" % "2.0.0-RC5-6" libraryDependencies += "org.antlr" % "antlr4-runtime" % "4.8" libraryDependencies += "io.estatico" %% "newtype" % "0.4.3" -libraryDependencies += "eu.timepit" %% "refined" % "0.9.12" +//libraryDependencies += "eu.timepit" %% "refined" % "0.9.12" From ed60c6a0462a9aa13b8d42724f6e598eb4f256ec Mon Sep 17 00:00:00 2001 From: d10xa Date: Tue, 4 Feb 2020 23:43:14 +0300 Subject: [PATCH 6/6] import ScalaVersion at ProjectMeta.scala --- src/main/scala/ru/d10xa/jadd/core/ProjectMeta.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/scala/ru/d10xa/jadd/core/ProjectMeta.scala b/src/main/scala/ru/d10xa/jadd/core/ProjectMeta.scala index e1f732b2..50e85d83 100644 --- a/src/main/scala/ru/d10xa/jadd/core/ProjectMeta.scala +++ b/src/main/scala/ru/d10xa/jadd/core/ProjectMeta.scala @@ -1,3 +1,5 @@ package ru.d10xa.jadd.core +import ru.d10xa.jadd.core.types.ScalaVersion + final case class ProjectMeta(scalaVersion: Option[ScalaVersion])