我想了解IntelliJ
如何构建play
应用程序。这一切对我来说都像一个黑盒子。我可以使用默认的Play2Run
配置构建默认应用程序。它似乎使用Build
脚本。我怎么能看到Build
的作用?
我想更改构建过程并复制一些不属于项目目录的文件,因此需要从系统上的其他位置复制它们。我能够使用File->Project Structure
选项将这些文件包含在工作区中,但这并不能使这些文件成为构建过程的一部分。我被告知在部署应用程序之前,我需要将这些文件作为构建过程的一部分从外部目录中复制。但我不知道在哪里寻找。
您可以参考我的两个相关问题来了解我想要实现的目标
unable to include external files in a project
Include external files (not libraries) in a project in Intellij
答案 0 :(得分:0)
我能够解决我的问题。我不知道IntelliJ
如何编译play
项目,但我注意到如果所需文件放在公共文件夹中,那么IntelliJ
将部署文件。
1)我在build.sbt
/* task to Copy files in ../common/css and ../common/javascripts in public/stylesheet/common and public/javascripts/common*/
val copyCommonFilesInPublicKey = taskKey[Int]("Copies files in ../common/css and ../common/javascripts in public/stylesheet/common and public/javascripts/common")
/*
the xcopy command is used to copy all the files and folders [/s] newer than those already copied [/d], including empty folders [/e]. 'common' folder in destination is assumed to be a
directory [/i] and xcopy will not seek permission to overwrite files [/y]
*/
copyCommonFilesInPublicKey := {
val copyCSS = Process(Seq("xcopy", "/i", "/s","/y","/d","/e","..\\common\\css", "public\\stylesheets\\common\\")).!<
println(s"copy CSS returned ${copyCSS}")
val copyJS = Process(Seq("xcopy", "/i","/s", "/y","/d","/e","..\\common\\javascripts", "public\\javascripts\\common\\")).!<
println(s"copy JS returned ${copyJS}")
copyJS
}
2)我在IntelliJ中创建了一个新的sbt任务,该任务将使用在步骤1 Run -> Edit Configurations -> + (on top left) -> sbt Task
中创建的任务。我将其命名为move files to public
,在copyCommonFilesInPublicKey
Tasks
3)我编辑了默认的Play2Run
配置。 Edit Configuration -> select play2Run -> + (on right side this time) -> select Run Another Conguration -> selected moves file to public (created in step 2) -> moved this new configuration above Play2Run built
现在公共文件被移动到公共文件夹,从那里我可以在代码中访问它们,如下所示:
<link rel="stylesheet" media="screen" href="@routes.Assets.versioned("stylesheets/common/css-reset.css")">
<link rel="stylesheet" media="screen" href="@routes.Assets.versioned("stylesheets/common/common-styles.css")">
<link rel="stylesheet" media="screen" href="@routes.Assets.versioned("stylesheets/common/vendor/bootstrap/bootstrap.css")">