Since Play Framework 2.3 assets are packaged into one jar archive file.我想將這個jar自動發佈到該項目中,即publish
或publishLocal
我也希望發佈資產jar。如何在Play 2.3中發佈帶publish/publishLocal的webjar資源?
如何實現這一目標?
Since Play Framework 2.3 assets are packaged into one jar archive file.我想將這個jar自動發佈到該項目中,即publish
或publishLocal
我也希望發佈資產jar。如何在Play 2.3中發佈帶publish/publishLocal的webjar資源?
如何實現這一目標?
inspect tree dist
後我設法找到產生資產文件的任務playPackageAssets
:
[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
一個天真的解決辦法可能是附加 webjar如由playPackageAssets
到publishLocal
任務的假象所產生的資產。添加以下build.sbt
(該類型是展示你的合作伙伴):
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)
}
重複它要表現出類似行爲的其他任務。
不過我很懷疑這是最好的解決方案。
在build.sbt文件中使用這些更改會導致將assets文件發佈到ivy中'assets'文件夾的jar文件中。但爲了在其他sbt項目中添加jar依賴項,jar文件應該放在'jars'文件夾中。 – 2014-10-15 07:43:23
'分類器(「資產」)是否工作? – 2014-10-16 08:17:55
不!在sbt文件中使用分類器會導致在'jars'文件夾中搜索庫名稱資產,而不是資產文件夾的方式:'C:\ Users \ M.Kashi \ .ivy2 \ local \ com.rh \ ?? _ 2.11 \ 1.0- SNAPSHOT \ jars \ ?? _ 2.11-assets.jar' – 2014-10-16 10:12:09
你是什麼意思*「由於playframework 2.3資產打包成一個webjar存檔文件。」*?你能分享一個鏈接到描述該功能的文檔嗎?我似乎無法重現它。 – 2014-09-28 20:58:28
https://www.playframework.com/documentation/2.3.x/資產,章節:「公共資產如何打包?」 – liosedhel 2014-09-28 21:12:14
您是否可以確認資產webjar僅在您'dist'而不是'publishLocal'時創建?我設法只在'dist'中創建了資源jar。 – 2014-09-28 21:43:03