什么是intellij的游戏应用程序构建过程 [英] What is intellij's build process for play applications
问题描述
我想了解 IntelliJ
如何构建播放
应用程序。对我来说,这看起来像一个黑盒子。我可以使用默认的 Play2Run
配置构建默认应用程序。它似乎使用 Build
脚本。我怎么能看到 Build
呢?
I want to understand how IntelliJ
builds a play
application. It all looks like a black box to me. I could build the default application using the default Play2Run
configuration. It seems to use a Build
script. How could I see what Build
does?
我想更改构建过程并复制一些不属于项目目录的文件,因此需要从系统上的其他位置复制它们。我能够使用 File-> Project Structure
选项将这些文件包含在工作区中,但这并不会使这些文件成为构建过程的一部分。我被告知在部署应用程序之前,我需要将这些文件作为构建过程的一部分从外部目录中复制。但我不知道在哪里寻找。
I want to change the build process and copy some files which are not part of the project directory and thus they need to be copied from some other location on the system. I was able to include these files in the workspace using File->Project Structure
option but that doesn't make these files part of the build process. I am told that I need to copy these file from the external directory as a part of your build process before deploying the application. But I do not know where to look for.
您可以参考我的两个相关问题来了解我想要实现的目标
You may refer to my two related questions to understand what I am trying to achieve
推荐答案
我能够解决我的问题。我不知道如何 IntelliJ
编译播放
项目,但我注意到如果所需文件放在公共文件夹中,那么 IntelliJ
将部署文件。
I was able to solve my problem. I do not know how IntelliJ
compiles play
project but I notice that if the required files are put in the public folder then IntelliJ
would deploy the files.
1)我在 build.sbt中创建了一个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中创建的任务运行 - >编辑配置 - > +(在左上角) - > sbt任务
。我把它命名为将文件移动到公共
,在任务中给出
copyCommonFilesInPublicKey
任务
2) I created a new sbt task in IntelliJ which would use the task created in step 1 Run -> Edit Configurations -> + (on top left) -> sbt Task
. I named it move files to public
, gave copyCommonFilesInPublicKey
in Tasks
3)我编辑了默认的 Play2Run
配置。 修改配置 - >选择play2Run - > +(此时右侧) - >选择Run Another Conguration - >选中将文件移动到公共(在步骤2中创建) - >将此新配置移至Play2Run内置
3) I edited the default Play2Run
configuration. 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
现在公共文件被移动到公共文件夹,我可以从那里访问它们,如下所示:
Now the common files get moved to public folder and from there I could access them in the code as follows:
<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")">
这篇关于什么是intellij的游戏应用程序构建过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!