From db054b4d44afdb938baa1f93b6e5d212f918af64 Mon Sep 17 00:00:00 2001 From: Christopher Vogt Date: Sun, 26 Feb 2017 22:11:04 +0800 Subject: fix / cleanup scalajs plugin - create target directory if not existent - remove dead code wrt modes - default path for generated .js file --- plugins/scalajs/ScalaJsBuild.scala | 12 ++++++------ plugins/scalajs/ScalaJsLib.scala | 19 +++---------------- 2 files changed, 9 insertions(+), 22 deletions(-) (limited to 'plugins') diff --git a/plugins/scalajs/ScalaJsBuild.scala b/plugins/scalajs/ScalaJsBuild.scala index 0c7222c..1b61b6e 100644 --- a/plugins/scalajs/ScalaJsBuild.scala +++ b/plugins/scalajs/ScalaJsBuild.scala @@ -23,17 +23,17 @@ trait ScalaJsBuild extends DynamicOverrides{ } override def compile = { - super.compile - scalaJsLib.link( - scalaJsTargetFile, scalaJsOptions, target +: dependencies.collect{case d: BoundMavenDependency => d.jar} - ) - None // FIXME: we need to rethink the concept of a "compile" task I think. There is no time to return here. + val res = super.compile + scalaJsLib.link( scalaJsTargetFile, scalaJsOptions, target +: dependencyClasspath.files ) + res + // FIXME: we need to rethink the concept of a "compile" task I think. + // An exit code would probably be more appropriate here. } def scalaJsOptions: Seq[String] = Seq() /** Where to put the generated js file */ - def scalaJsTargetFile: File + def scalaJsTargetFile: File = target / "app.js" override def cleanFiles = super.cleanFiles :+ scalaJsTargetFile :+ (scalaJsTargetFile ++ ".map") diff --git a/plugins/scalajs/ScalaJsLib.scala b/plugins/scalajs/ScalaJsLib.scala index ae37bde..7886478 100644 --- a/plugins/scalajs/ScalaJsLib.scala +++ b/plugins/scalajs/ScalaJsLib.scala @@ -4,28 +4,15 @@ import java.io.File case class ScalaJsLib( scalaJsVersion: String, scalaVersion: String, cbtLastModified: Long, mavenCache: File )(implicit logger: Logger, transientCache: java.util.Map[AnyRef,AnyRef], classLoaderCache: ClassLoaderCache){ - sealed trait ScalaJsOutputMode { - def option: String - def fileSuffix: String - } - case object FastOptJS extends ScalaJsOutputMode{ - override val option = "--fastOpt" - override val fileSuffix = "fastopt" - } - case object FullOptJS extends ScalaJsOutputMode{ - override val option = "--fullOpt" - override val fileSuffix = "fullopt" - } - val lib = new Lib(logger) def dep(artifactId: String) = MavenResolver( cbtLastModified, mavenCache, mavenCentral ).bindOne( MavenDependency("org.scala-js", artifactId, scalaJsVersion) ) def link( - outputPath: File, - scalaJsOptions: Seq[String], entriesToLink: Seq[File] - ) = { + outputPath: File, scalaJsOptions: Seq[String], entriesToLink: Seq[File] + ): ExitCode = { + outputPath.getParentFile.mkdirs val scalaJsCliDep = dep( "scalajs-cli_"++lib.libMajorVersion(scalaVersion) ) outputPath.getParentFile.mkdirs lib.runMain( -- cgit v1.2.3