Skip to content

Commit

Permalink
make metals not freak out due to macro subproject, .gitignore tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
greg2010 committed Mar 12, 2021
1 parent 5fd2156 commit 76fecb1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 51 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,17 @@ project/plugins/project/
*.log
*.metals
*.bsp
<<<<<<< Updated upstream
*.bloop
*.idea

.vscode
# End of https://www.gitignore.io/api/sbt,scala,intellij

project/metals.sbt
project/project

*.idea
.sbt/
.ivy2/
.cache/
Expand Down
1 change: 0 additions & 1 deletion backend/src/main/scala/org/kys/athena/Server.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ object Server extends App {
def allocateHttpServer: ZIO[AppRuntime with Has[ConfigModule], Throwable, Unit] = {
ZIO.runtime[AppRuntime with Has[ConfigModule]]
.flatMap { implicit runtime =>

val config = runtime.environment.get[ConfigModule].loaded

val routes: HttpRoutes[AppTask] = Router(config.http.prefix -> LogicEndpoints.publicRoutes,
Expand Down
19 changes: 14 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ scalaVersion in ThisBuild := "2.13.4"
// Projects
lazy val global = project
.in(file("."))
.settings(settings)
.settings(settings, bloopGenerate in Test := None)
.disablePlugins(AssemblyPlugin)
.aggregate(common.jvm, common.js, backend, frontend, macroSub)

Expand All @@ -17,6 +17,9 @@ lazy val common = crossProject(JSPlatform, JVMPlatform)
.settings(name := "common",
settings,
libraryDependencies ++= dependencies.common.value)
.jsSettings(
bloopGenerate in Test := None
)
.disablePlugins(AssemblyPlugin)

lazy val backend = project
Expand All @@ -27,6 +30,7 @@ lazy val backend = project
javaOptions in Compile ++= Seq("-Xss8M"))
.dependsOn(common.jvm)


lazy val frontend = project
.settings(name := "frontend",
settings,
Expand All @@ -35,16 +39,18 @@ lazy val frontend = project
// include the macro classes and resources in the main js
Compile / packageBin / mappings ++= (macroSub / Compile / packageBin / mappings).value,
// include the macro sources in the main source js
Compile / packageSrc / mappings ++= (macroSub / Compile / packageSrc / mappings).value)
Compile / packageSrc / mappings ++= (macroSub / Compile / packageSrc / mappings).value,
bloopGenerate in Test := None)
.disablePlugins(AssemblyPlugin)
.enablePlugins(ScalaJSPlugin)
.dependsOn(common.js)
.dependsOn(macroSub % "compile-internal, test-internal")
.dependsOn(macroSub)

lazy val macroSub = (project in file("macro"))
.settings(name := "macro",
commonSettings,
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value)
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value,
bloopGenerate in Test := None)
.disablePlugins(AssemblyPlugin)
.enablePlugins(ScalaJSPlugin)

Expand All @@ -55,7 +61,10 @@ lazy val compilerOptions = Seq("-unchecked", "-feature", "-deprecation", "-Wunus
lazy val commonSettings = Seq(scalacOptions ++= compilerOptions, resolvers += "jitpack" at "https://jitpack.io")

lazy val wartremoverSettings = Seq(wartremoverWarnings in(Compile, compile) ++= Warts.unsafe.filterNot { w =>
w == Wart.Any || w == Wart.Nothing || w == Wart.DefaultArguments || w == Wart.StringPlusAny ||
w == Wart.Any ||
w == Wart.Nothing ||
w == Wart.DefaultArguments ||
w == Wart.StringPlusAny ||
w == Wart.NonUnitStatements
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import scala.reflect.macros.blackbox

@compileTimeOnly("enable macro paradise to expand macro annotations")
object AssetLoader {
def test: Unit = {}
def require(path: String): String = macro requireImpl

def requireImpl(c: blackbox.Context)(path: c.Expr[String]): c.Expr[String] = {
Expand All @@ -28,51 +29,6 @@ object AssetLoader {
|Caused by: $e
|""".stripMargin)
}
/*
def eval[B](tree: Tree): B = c.eval[B](c.Expr[B](c.untypecheck(tree.duplicate)))
path match {
case Expr(Literal(Constant(s: String))) => {
reify(JSImporter.require(s"../../src/main/resources" + path.splice))
}
case Expr(Select(This(TypeName(n)), TermName(f))) => {
val pp = q"org.kys.athena.riot.api.dto.league.TierEnum.Challenger.toString"
println(showRaw(pp))
val expr = c.Expr[String](pp)
println(c.eval(expr))
reify(JSImporter.require(s"../../src/main/resourcestest123" + expr.splice))
}
case Expr(Apply(Select(x), y)) => {
println("hi")
x._1 match {
case Select(z) => println(z._2)
}
println(showRaw(x))
path
}
case _ => {
println(showRaw(path))
val pp = q"org.kys.athena.riot.api.dto.league.TierEnum.Challenger.toString"
println(showRaw(pp))
println(showRaw(c.eval(path)))
path
}
}
//val x = c.eval(c.Expr[String](c.untypecheck(path.tree.duplicate)))
//println(showRaw(x))
//JSImporter.require[String](s"../../src/main/resources${path.splice}")
/*path match {
case Literal(Constant(str: String)) => {
reify {
JSImporter.require[String](s"../../src/main/resources$str")
}
}
case Ident(TermName(n)) => {
val tree = q"$n"
val expr = c.Expr[String](tree)
requireImpl(c)(expr)
}
}*/*/
}

}

0 comments on commit 76fecb1

Please sign in to comment.