如何在Play 2.3中使用publish/publishLocal发布webjar资产? [英] How to publish webjar assets with publish/publishLocal in Play 2.3?
问题描述
由于Play Framework 2.3资产被打包到一个jar存档文件中.我想与项目一起自动发布此jar,即在publish
或publishLocal
上我希望资产jar也要发布.
Since Play Framework 2.3 assets are packaged into one jar archive file. I would like to publish this jar automatically with the project, i.e. upon publish
or publishLocal
I want the assets jar to be published as well.
如何实现?
推荐答案
在inspect tree dist
之后,我设法找到了生成资产文件的任务playPackageAssets
:
After inspect tree dist
I managed to find the task playPackageAssets
that generates the assets file:
[play-publish-webjar] $ inspect playPackageAssets
[info] Task: java.io.File
[info] Description:
[info]
[info] Provided by:
[info] {file:/Users/jacek/sandbox/play-publish-webjar/}root/*:playPackageAssets
[info] Defined at:
[info] (sbt.Defaults) Defaults.scala:641
[info] Dependencies:
[info] *:playPackageAssets::packageConfiguration
[info] *:playPackageAssets::streams
[info] Reverse dependencies:
[info] *:scriptClasspath
[info] universal:mappings
[info] Delegates:
[info] *:playPackageAssets
[info] {.}/*:playPackageAssets
[info] */*:playPackageAssets
一个简单的解决方案可能是附加由playPackageAssets
生成的资产webjar到publishLocal
任务的工件.将以下内容添加到build.sbt
(类型将显示您的工作方式):
A naive solution might be to attach the assets webjar as is generated by playPackageAssets
to publishLocal
task's artifacts. Add the following to build.sbt
(the types are to show what you work with):
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, "asset", "jar", "assets") -> assets)
}
针对其他您想要表现出类似行为的任务重复执行该操作.
Repeat it for the other tasks you want to exhibit similar behaviour.
但是我很怀疑这是最好的解决方案.
I'm however quite doubtful it's the best solution.
这篇关于如何在Play 2.3中使用publish/publishLocal发布webjar资产?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!