本文介绍了发布Play框架插件的资产文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用build.sbt文件中的publishTo,它可以是自动化发布进度.但是资产文件(在public文件夹中)没有打包.如何打包和发布资产文件?

using publishTo in build.sbt file, it can be automation the publishing progress.But asset files( in public folder) does not packaged. how to package and publish asset files?

推荐答案

对于本地发布的资产文件,请将此代码段添加到build.sbt文件中

For locally publishing assets files , add this snippet in build.sbt file

import play.PlayImport.PlayKeys._

packagedArtifacts in publishLocal := {
  val artifacts: Map[sbt.Artifact, java.io.File] = (packagedArtifacts in publishLocal).value
  val assets: java.io.File = (playPackageAssets in Compile).value
  artifacts + (Artifact(moduleName.value, "jar", "jar", "assets") -> assets)
}

最后一行功能中的重要说明:

Important notes in last function line:

首先jar指定包类型文件夹(作为webJars添加为Java依赖项,它们应放在jars文件夹中).

first jar specify package type folder (As webJars added as java dependency they should put in jars folder).

jar指定打包文件的扩展名.

second jar specify extention of packaged file.

assets是分类器(更多信息关于sbt分类器)

现在,您可以使用buil.sbt文件中的以下命令,在另一个项目中将打包资产用作webjar:

now you can use packaged assets as webjar in another project using this command in buil.sbt file:

libraryDependencies ++=   "organization" % "pluginName_scalaVersion" % "version" classifier "assets"

这篇关于发布Play框架插件的资产文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 03:28