什么是intellij的游戏应用程序构建过程

问题描述 投票:0回答:1

我想了解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

intellij-idea playframework-2.0
1个回答
0
投票

我能够解决我的问题。我不知道IntelliJ如何编译play项目,但我注意到如果所需文件放在公共文件夹中,那么IntelliJ将部署文件。

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中创建的任务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")">
© www.soinside.com 2019 - 2024. All rights reserved.