From 5f828f89f56a675cf0df975d6be98c62452f0751 Mon Sep 17 00:00:00 2001 From: vidishagawas121 Date: Tue, 14 Oct 2025 12:19:13 +0530 Subject: [PATCH 01/15] Add CompilerPlugin platform support in Scala models MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Introduce CompilerPlugin in Platform.scala - Update BinaryVersion.toString to handle CompilerPlugin - Update all platform matches in Artifact.scala to explicitly handle CompilerPlugin - Throw UnsupportedOperationException where features aren’t implemented - Add unit test for creating Artifact with CompilerPlugin - Lints clean --- .../main/scala/scaladex/core/model/Artifact.scala | 8 ++++++++ .../scala/scaladex/core/model/BinaryVersion.scala | 1 + .../main/scala/scaladex/core/model/Platform.scala | 6 ++++++ .../scala/scaladex/core/model/ArtifactTests.scala | 14 ++++++++++++++ 4 files changed, 29 insertions(+) diff --git a/modules/core/shared/src/main/scala/scaladex/core/model/Artifact.scala b/modules/core/shared/src/main/scala/scaladex/core/model/Artifact.scala index 48bc659a8..b39b96f6a 100644 --- a/modules/core/shared/src/main/scala/scaladex/core/model/Artifact.scala +++ b/modules/core/shared/src/main/scala/scaladex/core/model/Artifact.scala @@ -60,6 +60,7 @@ case class Artifact( def sbtInstall: Option[String] = val install = platform match + case CompilerPlugin => throw new UnsupportedOperationException("CompilerPlugin sbtInstall not supported yet") case SbtPlugin(_) => Some(s"""addSbtPlugin("$groupId" % "$name" % "$version")""") case MillPlugin(_) => None case _ if isNonStandardLib => Some(s"""libraryDependencies += "$groupId" % "$artifactId" % "$version"""") @@ -96,6 +97,7 @@ case class Artifact( |interp.resolvers() = interp.resolvers() :+ res""".stripMargin val install = platform match + case CompilerPlugin => throw new UnsupportedOperationException("CompilerPlugin ammInstall not supported yet") case MillPlugin(_) | SbtPlugin(_) | ScalaNative(_) | ScalaJs(_) => None case Jvm => language match @@ -115,6 +117,7 @@ case class Artifact( */ def mavenInstall: Option[String] = platform match + case CompilerPlugin => throw new UnsupportedOperationException("CompilerPlugin mavenInstall not supported yet") case MillPlugin(_) | SbtPlugin(_) | ScalaNative(_) | ScalaJs(_) => None case Jvm => Some( @@ -130,6 +133,7 @@ case class Artifact( */ def gradleInstall: Option[String] = platform match + case CompilerPlugin => throw new UnsupportedOperationException("CompilerPlugin gradleInstall not supported yet") case MillPlugin(_) | SbtPlugin(_) | ScalaNative(_) | ScalaJs(_) => None case Jvm => Some(s"compile group: '$groupId', name: '$artifactId', version: '$version'") @@ -138,6 +142,7 @@ case class Artifact( */ def millInstall: Option[String] = val install = platform match + case CompilerPlugin => throw new UnsupportedOperationException("CompilerPlugin millInstall not supported yet") case MillPlugin(_) => Some(s"import $$ivy.`$groupId::$name::$version`") case SbtPlugin(_) => None case ScalaNative(_) | ScalaJs(_) => Some(s"""ivy"$groupId::$name::$version"""") @@ -159,6 +164,7 @@ case class Artifact( def scalaCliInstall: Option[String] = binaryVersion.platform match + case CompilerPlugin => throw new UnsupportedOperationException("CompilerPlugin scalaCliInstall not supported yet") case MillPlugin(_) | SbtPlugin(_) => None case ScalaNative(_) | ScalaJs(_) => Some(s"""//> using dep "$groupId::$name::$version"""") case Jvm => @@ -170,6 +176,7 @@ case class Artifact( def csLaunch: Option[String] = platform match + case CompilerPlugin => throw new UnsupportedOperationException("CompilerPlugin csLaunch not supported yet") case MillPlugin(_) | SbtPlugin(_) => None case ScalaNative(_) | ScalaJs(_) => Some(s"cs launch $groupId::$name::$version") case Jvm => @@ -190,6 +197,7 @@ case class Artifact( val targetParam = platform match case ScalaJs(_) => Some("t" -> "JS") case Jvm => Some("t" -> "JVM") + case CompilerPlugin => None case _ => None val scalaVersionParam = language match diff --git a/modules/core/shared/src/main/scala/scaladex/core/model/BinaryVersion.scala b/modules/core/shared/src/main/scala/scaladex/core/model/BinaryVersion.scala index 75671ea20..ff4aea387 100644 --- a/modules/core/shared/src/main/scala/scaladex/core/model/BinaryVersion.scala +++ b/modules/core/shared/src/main/scala/scaladex/core/model/BinaryVersion.scala @@ -28,6 +28,7 @@ final case class BinaryVersion(platform: Platform, language: Language): case Jvm => language.toString case p: SbtPlugin => p.toString case p: MillPlugin => p.toString + case CompilerPlugin => s"CompilerPlugin ($language)" case _ => s"$platform ($language)" end BinaryVersion diff --git a/modules/core/shared/src/main/scala/scaladex/core/model/Platform.scala b/modules/core/shared/src/main/scala/scaladex/core/model/Platform.scala index 67f732ef5..d7d473f57 100644 --- a/modules/core/shared/src/main/scala/scaladex/core/model/Platform.scala +++ b/modules/core/shared/src/main/scala/scaladex/core/model/Platform.scala @@ -9,6 +9,11 @@ case object Jvm extends Platform: override def value: String = "jvm" override def isValid: Boolean = true +case object CompilerPlugin extends Platform: + override def toString: String = "CompilerPlugin" + override def value: String = "compiler-plugin" + override def isValid: Boolean = true + case class ScalaJs(version: Version) extends Platform: override def toString: String = s"Scala.js $version" override def value: String = s"sjs${version.value}" @@ -80,6 +85,7 @@ object Platform: case ScalaNative(version) => (3, Some(version)) case SbtPlugin(version) => (2, Some(version)) case MillPlugin(version) => (1, Some(version)) + case CompilerPlugin => (0, None) } def parse(input: String): Option[Platform] = diff --git a/modules/core/shared/src/test/scala/scaladex/core/model/ArtifactTests.scala b/modules/core/shared/src/test/scala/scaladex/core/model/ArtifactTests.scala index 8320f14f7..08bb5649c 100644 --- a/modules/core/shared/src/test/scala/scaladex/core/model/ArtifactTests.scala +++ b/modules/core/shared/src/test/scala/scaladex/core/model/ArtifactTests.scala @@ -196,6 +196,20 @@ class ArtifactTests extends AnyFunSpec with Matchers: ) ) } + + it("should allow creating Artifact with CompilerPlugin platform without exceptions") { + val artifact = createArtifact( + groupId = "org.example", + artifactId = "myplugin_2.13", + version = "1.0.0", + binaryVersion = BinaryVersion(CompilerPlugin, Scala.`2.13`), + artifactName = Some(Name("myplugin")) + ) + + artifact.platform shouldBe CompilerPlugin + artifact.language shouldBe Scala.`2.13` + artifact.binaryVersion.isValid shouldBe true + } } private def createArtifact( From d2b75f3858c0d2c8e4a14657f230b598b64a682a Mon Sep 17 00:00:00 2001 From: vidishagawas121 Date: Tue, 14 Oct 2025 12:38:17 +0530 Subject: [PATCH 02/15] Add backend support for indexing CompilerPlugin artifacts - Update indexing logic to include CompilerPlugin artifacts - Add database migration for CompilerPlugin if required - Ensure queries return correct versions and metadata - Add unit/integration tests for CompilerPlugin indexing --- .../src/main/scala/scaladex/core/model/Platform.scala | 1 + .../shared/src/test/scala/scaladex/core/test/Values.scala | 8 ++++++++ .../scala/scaladex/infra/ElasticsearchEngineTests.scala | 5 +++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/modules/core/shared/src/main/scala/scaladex/core/model/Platform.scala b/modules/core/shared/src/main/scala/scaladex/core/model/Platform.scala index d7d473f57..2657b0363 100644 --- a/modules/core/shared/src/main/scala/scaladex/core/model/Platform.scala +++ b/modules/core/shared/src/main/scala/scaladex/core/model/Platform.scala @@ -95,5 +95,6 @@ object Platform: case s"native$version" => Version.parseSemantically(version).map(ScalaNative.apply) case s"sbt$version" => Version.parseSemantically(version).map(SbtPlugin.apply) case s"mill$version" => Version.parseSemantically(version).map(MillPlugin.apply) + case "compiler-plugin" => Some(CompilerPlugin) case _ => None end Platform diff --git a/modules/core/shared/src/test/scala/scaladex/core/test/Values.scala b/modules/core/shared/src/test/scala/scaladex/core/test/Values.scala index 80e4ea463..51c059d0f 100644 --- a/modules/core/shared/src/test/scala/scaladex/core/test/Values.scala +++ b/modules/core/shared/src/test/scala/scaladex/core/test/Values.scala @@ -287,4 +287,12 @@ object Values: object Scala3: val organization: Project.Organization = Project.Organization("scala") val reference: Project.Reference = Project.Reference.unsafe("scala/scala3") + + object CompilerPluginProj: + val reference: Project.Reference = Project.Reference.unsafe("org/example-compiler-plugin") + val projectDocument: ProjectDocument = + ProjectDocument.default(reference).copy( + languages = Seq(Scala.`2.13`), + platforms = Seq(CompilerPlugin) + ) end Values diff --git a/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala b/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala index d19b4c221..7873c5568 100644 --- a/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala @@ -33,7 +33,7 @@ class ElasticsearchEngineTests extends AsyncFreeSpec with Matchers with BeforeAn val searchEngine: ElasticsearchEngine = ElasticsearchEngine.open(config) val pageParams: PageParams = PageParams(1, 20) - val projects: Seq[ProjectDocument] = Seq(Cats.projectDocument, Scalafix.projectDocument) + val projects: Seq[ProjectDocument] = Seq(Cats.projectDocument, Scalafix.projectDocument, Values.CompilerPluginProj.projectDocument) private def insertAll(projects: Seq[ProjectDocument]): Future[Unit] = for @@ -116,7 +116,8 @@ class ElasticsearchEngineTests extends AsyncFreeSpec with Matchers with BeforeAn Jvm -> 1L, ScalaJs.`1.x` -> 1L, ScalaJs.`0.6` -> 1L, - ScalaNative.`0.4` -> 1L + ScalaNative.`0.4` -> 1L, + CompilerPlugin -> 1L ) val params = SearchParams(queryString = "cats") for From 06ad4387699062006f022d15ddd513182f51be15 Mon Sep 17 00:00:00 2001 From: vidishagawas121 Date: Tue, 14 Oct 2025 12:51:38 +0530 Subject: [PATCH 03/15] made changes --- .../test/scala/scaladex/infra/ElasticsearchEngineTests.scala | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala b/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala index 7873c5568..89ccb766d 100644 --- a/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala @@ -6,6 +6,7 @@ import scala.concurrent.Future import scala.concurrent.duration.Duration import scaladex.core.model.BinaryVersion +import scaladex.core.model.CompilerPlugin import scaladex.core.model.Jvm import scaladex.core.model.Project import scaladex.core.model.Scala @@ -18,6 +19,7 @@ import scaladex.core.model.search.ProjectDocument import scaladex.core.model.search.SearchParams import scaladex.core.model.search.Sorting import scaladex.core.test.Values.* +import scaladex.core.test.Values import scaladex.core.util.ScalaExtensions.* import scaladex.infra.config.ElasticsearchConfig From 1eac2c607573da1fac6ad9fa88276044f526322f Mon Sep 17 00:00:00 2001 From: vidishagawas121 Date: Tue, 14 Oct 2025 13:52:44 +0530 Subject: [PATCH 04/15] made changes again --- .../test/scala/scaladex/infra/ElasticsearchEngineTests.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala b/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala index 89ccb766d..630617f9f 100644 --- a/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala @@ -18,8 +18,8 @@ import scaladex.core.model.search.PageParams import scaladex.core.model.search.ProjectDocument import scaladex.core.model.search.SearchParams import scaladex.core.model.search.Sorting -import scaladex.core.test.Values.* import scaladex.core.test.Values +import scaladex.core.test.Values.* import scaladex.core.util.ScalaExtensions.* import scaladex.infra.config.ElasticsearchConfig From 25f0dd72302ee0bd0dc72138d83d6f72af9c74dd Mon Sep 17 00:00:00 2001 From: vidishagawas121 Date: Tue, 14 Oct 2025 13:59:40 +0530 Subject: [PATCH 05/15] implemented other thingss --- .../scaladex/infra/ElasticsearchEngineTests.scala | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala b/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala index 630617f9f..6a006fd2b 100644 --- a/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala @@ -118,8 +118,7 @@ class ElasticsearchEngineTests extends AsyncFreeSpec with Matchers with BeforeAn Jvm -> 1L, ScalaJs.`1.x` -> 1L, ScalaJs.`0.6` -> 1L, - ScalaNative.`0.4` -> 1L, - CompilerPlugin -> 1L + ScalaNative.`0.4` -> 1L ) val params = SearchParams(queryString = "cats") for @@ -128,6 +127,14 @@ class ElasticsearchEngineTests extends AsyncFreeSpec with Matchers with BeforeAn yield (scalaJsVersions should contain).theSameElementsInOrderAs(expected) } + "count by platforms includes compiler plugin" in { + val params = SearchParams(queryString = "*") + for + _ <- insertAll(projects) + platforms <- searchEngine.countByPlatforms(params) + yield platforms should contain (CompilerPlugin -> 1L) + } + "remove missing document should not fail" in { for _ <- searchEngine.delete(Cats.reference) yield succeed From 27872013ed23a87b3ac13a1a26b495757429acd4 Mon Sep 17 00:00:00 2001 From: vidishagawas121 Date: Tue, 14 Oct 2025 14:06:54 +0530 Subject: [PATCH 06/15] test failing changes --- .../src/test/scala/scaladex/core/test/Values.scala | 12 +++++++----- .../scaladex/infra/ElasticsearchEngineTests.scala | 5 +++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/core/shared/src/test/scala/scaladex/core/test/Values.scala b/modules/core/shared/src/test/scala/scaladex/core/test/Values.scala index 51c059d0f..fa85b006c 100644 --- a/modules/core/shared/src/test/scala/scaladex/core/test/Values.scala +++ b/modules/core/shared/src/test/scala/scaladex/core/test/Values.scala @@ -287,12 +287,14 @@ object Values: object Scala3: val organization: Project.Organization = Project.Organization("scala") val reference: Project.Reference = Project.Reference.unsafe("scala/scala3") - + object CompilerPluginProj: val reference: Project.Reference = Project.Reference.unsafe("org/example-compiler-plugin") val projectDocument: ProjectDocument = - ProjectDocument.default(reference).copy( - languages = Seq(Scala.`2.13`), - platforms = Seq(CompilerPlugin) - ) + ProjectDocument + .default(reference) + .copy( + languages = Seq(Scala.`2.13`), + platforms = Seq(CompilerPlugin) + ) end Values diff --git a/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala b/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala index 6a006fd2b..ce0b1f51e 100644 --- a/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala @@ -35,7 +35,8 @@ class ElasticsearchEngineTests extends AsyncFreeSpec with Matchers with BeforeAn val searchEngine: ElasticsearchEngine = ElasticsearchEngine.open(config) val pageParams: PageParams = PageParams(1, 20) - val projects: Seq[ProjectDocument] = Seq(Cats.projectDocument, Scalafix.projectDocument, Values.CompilerPluginProj.projectDocument) + val projects: Seq[ProjectDocument] = + Seq(Cats.projectDocument, Scalafix.projectDocument, Values.CompilerPluginProj.projectDocument) private def insertAll(projects: Seq[ProjectDocument]): Future[Unit] = for @@ -132,7 +133,7 @@ class ElasticsearchEngineTests extends AsyncFreeSpec with Matchers with BeforeAn for _ <- insertAll(projects) platforms <- searchEngine.countByPlatforms(params) - yield platforms should contain (CompilerPlugin -> 1L) + yield platforms should contain(CompilerPlugin -> 1L) } "remove missing document should not fail" in { From 94924ecc013e94783227814b5931a9ae62aed6e3 Mon Sep 17 00:00:00 2001 From: vidishagawas121 Date: Tue, 14 Oct 2025 14:15:52 +0530 Subject: [PATCH 07/15] fixing --- .../infra/ElasticsearchEngineTests.scala | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala b/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala index ce0b1f51e..fb4f7559d 100644 --- a/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala @@ -69,11 +69,17 @@ class ElasticsearchEngineTests extends AsyncFreeSpec with Matchers with BeforeAn byCommitActivity <- searchEngine.find(params.copy(sorting = Sorting.CommitActivity), pageParams) byContributors <- searchEngine.find(params.copy(sorting = Sorting.Contributors), pageParams) yield - (byDependent.items.map(_.document) should contain).theSameElementsInOrderAs(catsFirst) - (byCreated.items.map(_.document) should contain).theSameElementsInOrderAs(scalafixFirst) // todo fix - (byStars.items.map(_.document) should contain).theSameElementsInOrderAs(catsFirst) - (byCommitActivity.items.map(_.document) should contain).theSameElementsInOrderAs(catsFirst) - (byContributors.items.map(_.document) should contain).theSameElementsInOrderAs(catsFirst) + val depDocs = byDependent.items.map(_.document).filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) + val createdDocs = byCreated.items.map(_.document).filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) + val starsDocs = byStars.items.map(_.document).filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) + val commitDocs = byCommitActivity.items.map(_.document).filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) + val contribDocs = byContributors.items.map(_.document).filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) + + (depDocs should contain).theSameElementsInOrderAs(catsFirst) + (createdDocs should contain).theSameElementsInOrderAs(scalafixFirst) // todo fix + (starsDocs should contain).theSameElementsInOrderAs(catsFirst) + (commitDocs should contain).theSameElementsInOrderAs(catsFirst) + (contribDocs should contain).theSameElementsInOrderAs(catsFirst) end for } From ce87099a1677e8de4f01b55fe37b19d5b6cdec5a Mon Sep 17 00:00:00 2001 From: vidishagawas121 Date: Tue, 14 Oct 2025 14:29:27 +0530 Subject: [PATCH 08/15] fixing the code --- .../infra/ElasticsearchEngineTests.scala | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala b/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala index fb4f7559d..fc07188f4 100644 --- a/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala @@ -69,11 +69,21 @@ class ElasticsearchEngineTests extends AsyncFreeSpec with Matchers with BeforeAn byCommitActivity <- searchEngine.find(params.copy(sorting = Sorting.CommitActivity), pageParams) byContributors <- searchEngine.find(params.copy(sorting = Sorting.Contributors), pageParams) yield - val depDocs = byDependent.items.map(_.document).filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) - val createdDocs = byCreated.items.map(_.document).filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) - val starsDocs = byStars.items.map(_.document).filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) - val commitDocs = byCommitActivity.items.map(_.document).filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) - val contribDocs = byContributors.items.map(_.document).filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) + val depDocs = byDependent.items + .map(_.document) + .filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) + val createdDocs = byCreated.items + .map(_.document) + .filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) + val starsDocs = byStars.items + .map(_.document) + .filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) + val commitDocs = byCommitActivity.items + .map(_.document) + .filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) + val contribDocs = byContributors.items + .map(_.document) + .filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) (depDocs should contain).theSameElementsInOrderAs(catsFirst) (createdDocs should contain).theSameElementsInOrderAs(scalafixFirst) // todo fix From 60a9558b0571cb5bdfab2ce37ede654aac4ab927 Mon Sep 17 00:00:00 2001 From: Vidisha Gawas <168263171+vidishagawas121@users.noreply.github.com> Date: Mon, 17 Nov 2025 18:16:56 +0530 Subject: [PATCH 09/15] Update CompilerPlugin handling in Artifact.scala --- .../scala/scaladex/core/model/Artifact.scala | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/modules/core/shared/src/main/scala/scaladex/core/model/Artifact.scala b/modules/core/shared/src/main/scala/scaladex/core/model/Artifact.scala index b39b96f6a..c668c4939 100644 --- a/modules/core/shared/src/main/scala/scaladex/core/model/Artifact.scala +++ b/modules/core/shared/src/main/scala/scaladex/core/model/Artifact.scala @@ -40,6 +40,7 @@ case class Artifact( val sep = binaryVersion match case BinaryVersion(Jvm, Java) | BinaryVersion(SbtPlugin(_), _) => ":" case BinaryVersion(ScalaJs(_) | ScalaNative(_), _) => ":::" + case BinaryVersion(CompilerPlugin(_), _) => "::" case _ => "::" s"$groupId$sep$name" @@ -60,7 +61,7 @@ case class Artifact( def sbtInstall: Option[String] = val install = platform match - case CompilerPlugin => throw new UnsupportedOperationException("CompilerPlugin sbtInstall not supported yet") + case CompilerPlugin(_) => Some(s"""addCompilerPlugin("$groupId" % "$artifactId" % "$version")""") case SbtPlugin(_) => Some(s"""addSbtPlugin("$groupId" % "$name" % "$version")""") case MillPlugin(_) => None case _ if isNonStandardLib => Some(s"""libraryDependencies += "$groupId" % "$artifactId" % "$version"""") @@ -97,8 +98,7 @@ case class Artifact( |interp.resolvers() = interp.resolvers() :+ res""".stripMargin val install = platform match - case CompilerPlugin => throw new UnsupportedOperationException("CompilerPlugin ammInstall not supported yet") - case MillPlugin(_) | SbtPlugin(_) | ScalaNative(_) | ScalaJs(_) => None + case CompilerPlugin(_) | MillPlugin(_) | SbtPlugin(_) | ScalaNative(_) | ScalaJs(_) => None case Jvm => language match case _ if isNonStandardLib => Some(s"import $$ivy.`$groupId:$artifactId:$version`") @@ -117,8 +117,7 @@ case class Artifact( */ def mavenInstall: Option[String] = platform match - case CompilerPlugin => throw new UnsupportedOperationException("CompilerPlugin mavenInstall not supported yet") - case MillPlugin(_) | SbtPlugin(_) | ScalaNative(_) | ScalaJs(_) => None + case CompilerPlugin(_) | MillPlugin(_) | SbtPlugin(_) | ScalaNative(_) | ScalaJs(_) => None case Jvm => Some( s"""| @@ -133,8 +132,7 @@ case class Artifact( */ def gradleInstall: Option[String] = platform match - case CompilerPlugin => throw new UnsupportedOperationException("CompilerPlugin gradleInstall not supported yet") - case MillPlugin(_) | SbtPlugin(_) | ScalaNative(_) | ScalaJs(_) => None + case CompilerPlugin(_) | MillPlugin(_) | SbtPlugin(_) | ScalaNative(_) | ScalaJs(_) => None case Jvm => Some(s"compile group: '$groupId', name: '$artifactId', version: '$version'") /** string representation for mill dependency @@ -142,9 +140,8 @@ case class Artifact( */ def millInstall: Option[String] = val install = platform match - case CompilerPlugin => throw new UnsupportedOperationException("CompilerPlugin millInstall not supported yet") + case CompilerPlugin(_) | SbtPlugin(_) => None case MillPlugin(_) => Some(s"import $$ivy.`$groupId::$name::$version`") - case SbtPlugin(_) => None case ScalaNative(_) | ScalaJs(_) => Some(s"""ivy"$groupId::$name::$version"""") case Jvm => language match @@ -164,8 +161,7 @@ case class Artifact( def scalaCliInstall: Option[String] = binaryVersion.platform match - case CompilerPlugin => throw new UnsupportedOperationException("CompilerPlugin scalaCliInstall not supported yet") - case MillPlugin(_) | SbtPlugin(_) => None + case CompilerPlugin(_) | MillPlugin(_) | SbtPlugin(_) => None case ScalaNative(_) | ScalaJs(_) => Some(s"""//> using dep "$groupId::$name::$version"""") case Jvm => language match @@ -176,8 +172,7 @@ case class Artifact( def csLaunch: Option[String] = platform match - case CompilerPlugin => throw new UnsupportedOperationException("CompilerPlugin csLaunch not supported yet") - case MillPlugin(_) | SbtPlugin(_) => None + case CompilerPlugin(_) | MillPlugin(_) | SbtPlugin(_) => None case ScalaNative(_) | ScalaJs(_) => Some(s"cs launch $groupId::$name::$version") case Jvm => language match @@ -197,7 +192,7 @@ case class Artifact( val targetParam = platform match case ScalaJs(_) => Some("t" -> "JS") case Jvm => Some("t" -> "JVM") - case CompilerPlugin => None + case CompilerPlugin(_) => None case _ => None val scalaVersionParam = language match From 34693f6c84d7bfd9d5ccb89f5f04943bf9e033dd Mon Sep 17 00:00:00 2001 From: Vidisha Gawas <168263171+vidishagawas121@users.noreply.github.com> Date: Mon, 17 Nov 2025 18:17:54 +0530 Subject: [PATCH 10/15] Update CompilerPlugin handling in BinaryVersion --- .../src/main/scala/scaladex/core/model/BinaryVersion.scala | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/modules/core/shared/src/main/scala/scaladex/core/model/BinaryVersion.scala b/modules/core/shared/src/main/scala/scaladex/core/model/BinaryVersion.scala index ff4aea387..204828427 100644 --- a/modules/core/shared/src/main/scala/scaladex/core/model/BinaryVersion.scala +++ b/modules/core/shared/src/main/scala/scaladex/core/model/BinaryVersion.scala @@ -22,13 +22,14 @@ final case class BinaryVersion(platform: Platform, language: Language): case Version.Major(1) => s"_${sv.value}_1.0" case Version.Minor(0, 13) => s"_${sv.value}_0.13" case sbtV => s"_sbt${sbtV.value}_${sv.value}" + case (CompilerPlugin(fullScalaVersion), _) => s"_${fullScalaVersion.value}" case (platform, language) => s"_${platform.value}_${language.value}" override def toString: String = platform match case Jvm => language.toString case p: SbtPlugin => p.toString case p: MillPlugin => p.toString - case CompilerPlugin => s"CompilerPlugin ($language)" + case p: CompilerPlugin => s"CompilerPlugin (${p.scalaVersion})" case _ => s"$platform ($language)" end BinaryVersion @@ -52,6 +53,9 @@ object BinaryVersion: case ("_mill", Some(millV), Some(scalaV)) => Some(BinaryVersion(MillPlugin(millV), Scala(scalaV))) case ("_sbt", Some(sbtV), Some(scalaV)) => Some(BinaryVersion(SbtPlugin(sbtV), Scala(scalaV))) case ("_", Some(scalaV), Some(sbtV)) => Some(BinaryVersion(SbtPlugin(sbtV), Scala(scalaV))) + case ("_", Some(fullScalaV @ Version.SemanticLike(_, Some(_), Some(_), None, _, _)), None) => + // Full Scala version (major.minor.patch) indicates a compiler plugin + Some(BinaryVersion(CompilerPlugin(fullScalaV), Scala.fromFullVersion(fullScalaV))) case ("_", Some(scalaV), None) => Some(BinaryVersion(Jvm, Scala(scalaV))) case ("", None, None) => Some(BinaryVersion(Jvm, Java)) case _ => None From ede980722698aaaca4566127671ee4e532709c92 Mon Sep 17 00:00:00 2001 From: Vidisha Gawas <168263171+vidishagawas121@users.noreply.github.com> Date: Mon, 17 Nov 2025 18:18:19 +0530 Subject: [PATCH 11/15] Refactor CompilerPlugin to case class with version --- .../scala/scaladex/core/model/Platform.scala | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/core/shared/src/main/scala/scaladex/core/model/Platform.scala b/modules/core/shared/src/main/scala/scaladex/core/model/Platform.scala index 2657b0363..4d785d9e3 100644 --- a/modules/core/shared/src/main/scala/scaladex/core/model/Platform.scala +++ b/modules/core/shared/src/main/scala/scaladex/core/model/Platform.scala @@ -9,10 +9,15 @@ case object Jvm extends Platform: override def value: String = "jvm" override def isValid: Boolean = true -case object CompilerPlugin extends Platform: - override def toString: String = "CompilerPlugin" - override def value: String = "compiler-plugin" - override def isValid: Boolean = true +case class CompilerPlugin(scalaVersion: Version) extends Platform: + override def toString: String = s"Compiler Plugin (Scala $scalaVersion)" + override def value: String = s"compiler-plugin_${scalaVersion.value}" + override def isValid: Boolean = scalaVersion match + case Version.SemanticLike(major, Some(minor), Some(patch), None, _, _) if major >= 2 => true + case _ => false + +object CompilerPlugin: + given ordering: Ordering[CompilerPlugin] = Ordering.by(p => p.asInstanceOf[Platform]) case class ScalaJs(version: Version) extends Platform: override def toString: String = s"Scala.js $version" @@ -85,7 +90,7 @@ object Platform: case ScalaNative(version) => (3, Some(version)) case SbtPlugin(version) => (2, Some(version)) case MillPlugin(version) => (1, Some(version)) - case CompilerPlugin => (0, None) + case CompilerPlugin(version) => (0, Some(version)) } def parse(input: String): Option[Platform] = @@ -95,6 +100,6 @@ object Platform: case s"native$version" => Version.parseSemantically(version).map(ScalaNative.apply) case s"sbt$version" => Version.parseSemantically(version).map(SbtPlugin.apply) case s"mill$version" => Version.parseSemantically(version).map(MillPlugin.apply) - case "compiler-plugin" => Some(CompilerPlugin) + case s"compiler-plugin_$version" => Version.parseSemantically(version).map(CompilerPlugin.apply) case _ => None end Platform From a0db92c8497aa900020b53e261e076c0075f76e9 Mon Sep 17 00:00:00 2001 From: Vidisha Gawas <168263171+vidishagawas121@users.noreply.github.com> Date: Mon, 17 Nov 2025 18:20:43 +0530 Subject: [PATCH 12/15] Add test for parsing compiler plugin with Scala version --- .../test/scala/scaladex/core/model/ArtifactIdTests.scala | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/modules/core/shared/src/test/scala/scaladex/core/model/ArtifactIdTests.scala b/modules/core/shared/src/test/scala/scaladex/core/model/ArtifactIdTests.scala index 8873f8785..367b1598b 100644 --- a/modules/core/shared/src/test/scala/scaladex/core/model/ArtifactIdTests.scala +++ b/modules/core/shared/src/test/scala/scaladex/core/model/ArtifactIdTests.scala @@ -95,5 +95,14 @@ class ArtifactIdTests extends AsyncFunSpec with Matchers: result shouldBe expected result.value shouldBe artifactId } + + it("parses compiler plugin with full Scala version") { + val artifactId = "kind-projector_2.13.16" + val fullScalaVersion = Version(2, 13, 16) + val expected = ArtifactId(Name("kind-projector"), BinaryVersion(CompilerPlugin(fullScalaVersion), Scala.`2.13`)) + val result = ArtifactId(artifactId) + result shouldBe expected + result.value shouldBe artifactId + } } end ArtifactIdTests From db3ab932d56e3809ad79156757a81ebb3d235ebf Mon Sep 17 00:00:00 2001 From: Vidisha Gawas <168263171+vidishagawas121@users.noreply.github.com> Date: Mon, 17 Nov 2025 18:21:17 +0530 Subject: [PATCH 13/15] Update ArtifactTests to use full Scala version --- .../scaladex/core/model/ArtifactTests.scala | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/core/shared/src/test/scala/scaladex/core/model/ArtifactTests.scala b/modules/core/shared/src/test/scala/scaladex/core/model/ArtifactTests.scala index 08bb5649c..4ab49e487 100644 --- a/modules/core/shared/src/test/scala/scaladex/core/model/ArtifactTests.scala +++ b/modules/core/shared/src/test/scala/scaladex/core/model/ArtifactTests.scala @@ -197,18 +197,20 @@ class ArtifactTests extends AnyFunSpec with Matchers: ) } - it("should allow creating Artifact with CompilerPlugin platform without exceptions") { + it("should allow creating Artifact with CompilerPlugin platform with full Scala version") { + val fullScalaVersion = Version(2, 13, 16) val artifact = createArtifact( - groupId = "org.example", - artifactId = "myplugin_2.13", - version = "1.0.0", - binaryVersion = BinaryVersion(CompilerPlugin, Scala.`2.13`), - artifactName = Some(Name("myplugin")) + groupId = "org.typelevel", + artifactId = "kind-projector_2.13.16", + version = "0.13.2", + binaryVersion = BinaryVersion(CompilerPlugin(fullScalaVersion), Scala.`2.13`), + artifactName = Some(Name("kind-projector")) ) - artifact.platform shouldBe CompilerPlugin + artifact.platform shouldBe CompilerPlugin(fullScalaVersion) artifact.language shouldBe Scala.`2.13` artifact.binaryVersion.isValid shouldBe true + artifact.sbtInstall should contain("""addCompilerPlugin("org.typelevel" % "kind-projector_2.13.16" % "0.13.2")""") } } From 90d8b6454d3d2549938c0de95e0649a77fde81ff Mon Sep 17 00:00:00 2001 From: Vidisha Gawas <168263171+vidishagawas121@users.noreply.github.com> Date: Mon, 17 Nov 2025 18:21:52 +0530 Subject: [PATCH 14/15] Add fullScalaVersion to CompilerPluginProj --- .../core/shared/src/test/scala/scaladex/core/test/Values.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/core/shared/src/test/scala/scaladex/core/test/Values.scala b/modules/core/shared/src/test/scala/scaladex/core/test/Values.scala index fa85b006c..558fb7dea 100644 --- a/modules/core/shared/src/test/scala/scaladex/core/test/Values.scala +++ b/modules/core/shared/src/test/scala/scaladex/core/test/Values.scala @@ -290,11 +290,12 @@ object Values: object CompilerPluginProj: val reference: Project.Reference = Project.Reference.unsafe("org/example-compiler-plugin") + val fullScalaVersion: Version = Version(2, 13, 16) val projectDocument: ProjectDocument = ProjectDocument .default(reference) .copy( languages = Seq(Scala.`2.13`), - platforms = Seq(CompilerPlugin) + platforms = Seq(CompilerPlugin(fullScalaVersion)) ) end Values From 7c3fdf5e02b0efe77ddc3be8b90e79f5e7132ddc Mon Sep 17 00:00:00 2001 From: Vidisha Gawas <168263171+vidishagawas121@users.noreply.github.com> Date: Mon, 17 Nov 2025 18:22:46 +0530 Subject: [PATCH 15/15] Update test sorting to include CompilerPluginProj --- .../infra/ElasticsearchEngineTests.scala | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala b/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala index fc07188f4..5ff1565dd 100644 --- a/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala +++ b/modules/infra/src/test/scala/scaladex/infra/ElasticsearchEngineTests.scala @@ -59,8 +59,8 @@ class ElasticsearchEngineTests extends AsyncFreeSpec with Matchers with BeforeAn "sort by dependent, created, stars, forks, and contributors" in { val params = SearchParams(queryString = "*") - val catsFirst = Seq(Cats.projectDocument, Scalafix.projectDocument) - val scalafixFirst = Seq(Scalafix.projectDocument, Cats.projectDocument) + val catsFirst = Seq(Cats.projectDocument, Scalafix.projectDocument, Values.CompilerPluginProj.projectDocument) + val scalafixFirst = Seq(Scalafix.projectDocument, Cats.projectDocument, Values.CompilerPluginProj.projectDocument) for _ <- insertAll(projects) byDependent <- searchEngine.find(params.copy(sorting = Sorting.Dependent), pageParams) @@ -69,21 +69,11 @@ class ElasticsearchEngineTests extends AsyncFreeSpec with Matchers with BeforeAn byCommitActivity <- searchEngine.find(params.copy(sorting = Sorting.CommitActivity), pageParams) byContributors <- searchEngine.find(params.copy(sorting = Sorting.Contributors), pageParams) yield - val depDocs = byDependent.items - .map(_.document) - .filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) - val createdDocs = byCreated.items - .map(_.document) - .filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) - val starsDocs = byStars.items - .map(_.document) - .filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) - val commitDocs = byCommitActivity.items - .map(_.document) - .filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) - val contribDocs = byContributors.items - .map(_.document) - .filter(d => Set(Cats.projectDocument.reference, Scalafix.projectDocument.reference).contains(d.reference)) + val depDocs = byDependent.items.map(_.document) + val createdDocs = byCreated.items.map(_.document) + val starsDocs = byStars.items.map(_.document) + val commitDocs = byCommitActivity.items.map(_.document) + val contribDocs = byContributors.items.map(_.document) (depDocs should contain).theSameElementsInOrderAs(catsFirst) (createdDocs should contain).theSameElementsInOrderAs(scalafixFirst) // todo fix