首页 \ 问答 \ 为什么多模块项目构建为具有阶段的子模块生成空的jar文件?(Why does multi-module project build generate empty jar files for submodules with stage?)

为什么多模块项目构建为具有阶段的子模块生成空的jar文件?(Why does multi-module project build generate empty jar files for submodules with stage?)

我是Typesafe Activator的新手,我正在尝试创建一个子项目关系的Play项目。

我使用activator进行本地开发,并在Heroku上使用。 这是版本0.13.5。

当我从root项目的基目录中键入sbt clean stage ,它会调用子模块并在<parent_dir>/<sub_project_dir>/universal/stage/lib下的相应位置生成一个jar文件。

问题是jar文件只有META-INF/MANIFEST.MF文件,里面没有其他文件,类文件包括。

当我使用activator clean stage从子模块的基本目录构建子模块时,将创建包含所有正确类文件的jar文件。

以下是顶级项目build.sbt (减去库依赖项和repo解析器):

import play.PlayScala

name := "perf-catalog-index"

version := "1.0"

lazy val index_worker=(project in file("index_worker")) settings (
  name:="perf-catalog-index-worker",
  mainClass:=Some("org.myorg.catalog.index.CatalogIndexWorker")
)

lazy val root = (project in file(".")) enablePlugins(PlayScala) aggregate(index_worker)

aggregate in Global := true

scalaVersion := "2.11.1"

这里是我的子项目index_workerbuild.sbt文件的类似内容:

import play.PlayScala

name := "perf-catalog-index-worker"

version := "1.0"

lazy val root = (project in file(".")) enablePlugins(PlayScala)

// Setup the packager
packageArchetype.java_application

// Enable JAR export for staging
exportJars := true

val workerMainClass = Some("org.myorg.catalog.index.CatalogIndexWorker")

mainClass in (Compile, run) := workerMainClass

mainClass in (Compile, packageBin) := workerMainClass

scalaVersion := "2.11.1"

如何获取stage命令为子项目生成包含类文件的jar文件?


I'm new to Typesafe Activator and am trying to create a Play project with a subproject relationship.

I use activator for local development and sbt on Heroku. It's sbt version 0.13.5.

When I type sbt clean stage from the root project's base directory, it calls the submodule and generates a jar file in the appropriate spot under <parent_dir>/<sub_project_dir>/universal/stage/lib.

The issue is that the jar file has the META-INF/MANIFEST.MF file only with no other files inside, class files including.

When I build the submodule from the submodule's base directory using activator clean stage the jar file is created with all the correct class files inside.

Here is the content of the top-level project's build.sbt (minus library dependencies and repo resolvers):

import play.PlayScala

name := "perf-catalog-index"

version := "1.0"

lazy val index_worker=(project in file("index_worker")) settings (
  name:="perf-catalog-index-worker",
  mainClass:=Some("org.myorg.catalog.index.CatalogIndexWorker")
)

lazy val root = (project in file(".")) enablePlugins(PlayScala) aggregate(index_worker)

aggregate in Global := true

scalaVersion := "2.11.1"

And here is similar content for my sub project index_worker's build.sbt file:

import play.PlayScala

name := "perf-catalog-index-worker"

version := "1.0"

lazy val root = (project in file(".")) enablePlugins(PlayScala)

// Setup the packager
packageArchetype.java_application

// Enable JAR export for staging
exportJars := true

val workerMainClass = Some("org.myorg.catalog.index.CatalogIndexWorker")

mainClass in (Compile, run) := workerMainClass

mainClass in (Compile, packageBin) := workerMainClass

scalaVersion := "2.11.1"

How can I get the stage command to generate a jar file for the sub project with the class files in it?


原文:https://stackoverflow.com/questions/26539248
更新时间:2019-12-03 08:12

最满意答案

我的猜测是更改index_worker项目声明,以明确地使用enablePlugins PlayScala

lazy val index_worker = (project in file("index_worker")) settings (
  name := "perf-catalog-index-worker",
  mainClass := Some("org.myorg.catalog.index.CatalogIndexWorker")
) enablePlugins PlayScala

这样做的原因是你有两个独立的Play项目 - index_workerroot 。 虽然index_worker是一个完整的Play项目,但它的整个project构建定义都没有被选中,因为只有顶级项目(这就是sbt的工作原理)。

但我无法弄清楚为什么在子模块中执行stage原因。 我可能弄错了。


My guess would be to change index_worker project declaration in the top-level build.sbt to have enablePlugins PlayScala explicitly:

lazy val index_worker = (project in file("index_worker")) settings (
  name := "perf-catalog-index-worker",
  mainClass := Some("org.myorg.catalog.index.CatalogIndexWorker")
) enablePlugins PlayScala

The reason for this is that you've got two standalone Play projects - index_worker and root. While index_worker is a complete Play project its entire project build definition is not picked up since only the top-level one is (that's how sbt works).

I can't figure out why stage is executed in the submodule whatsoever, though. I may be mistaken.

2014-10-27

相关问答

更多

将文本文件分为两个不同的部分(Dividing a text file into two different parts)

你可以试试这个: with open('file.txt', 'r') as f: data = [] category = [] lines = f.readlines() for line in lines: if line.startswith('Category'): category.append(line) else: data.append(line) c

preg_match_all多行不起作用(preg_match_all with multilines not working)

看起来你只想在一个字pool ,1 +空格和/之后提取非空白字符块。 你可以用 '~\bpool\h+/\K\S+$~m' 使用PHP中的preg_match_all函数。 请参阅正则表达式演示 。 细节 \bpool - 一个完整的单词pool (下一个char应该是一个水平的空格, \b是一个单词边界) \h+ - 1+水平空白字符 / - a / char \K匹配重置运算符以丢弃到目前为止匹配的文本 \S+ - 除了空格以外的1 +个字符 $ - 行尾(由于m修饰符)。 PHP演示 :

使用android处理程序的启动画面不起作用(splash screen using android handler is not working)

这是我的启动画面代码,它正在工作: @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_splash_screen); int SPLASH_TIME_OUT = 1500; new Handler().postDelayed(new Runna

不同的时间推迟下载文件(different time delaying to download files)

对不起,还不能发表评论但是: 等待命令在PHP中使用SSH2_Shell完成 所以你可以这样做: while (true){ $data .= stream_get_contents($stream); if (strpos($data,"XOXO") !== false) { echo "okay: command finished\n"; break; } } echo $dat

Google地球:在运行时禁用flyToView(Google Earth: Disable flyToView on runtime)

如果您在NetworkLink中设置了flyToView,则会出现这种情况。 检查flyToView元素是NetworkLink的子代,而不是Link。 可能由您正在使用的JavaScript API生成的KML未正确设置flyToView或者不支持它。 <Document> <visibility>1</visibility> <NetworkLink> <name>NE US Radar</name> <refreshVisibility>1</refreshVisi

Web服务请求中的特殊字符(Special Characters in Webservice Request)

由于我控制web服务和使用它的平台,我能够开发自己的约定来处理特殊字符。 我知道对于我现在发送的内容,我不太可能拥有包含双下划线的值,并且下划线似乎对我到目前为止看到的所有内容都是合法的,所以我开发了一个系统,我拼出一个角色并用下划线包围它。 所以我有类似的东西 ...<username>__QUOTE__Frank__QUOTE__</username>... 在我的新系统中。 我可以在从我的应用程序发送请求或从Web服务发送响应之前查找特殊字符,并执行简单的字符串替换。 然后,只要我收到X

使用java标记数据提取(data extraction by tagging using java)

感谢您的回复...是的,我找到了解决方案,我使用solr荧光笔,通过调整solr响应返回的片段的片段大小,我们可以得到搜索项存在的段落 Thank u for ur reply... yeah i found the solution, i m using solr highlighter, by adjusting fragment size of the snippet returned by the solr response we can get the paragraph where

使用foldl / foldr插入函数(Insert function using foldl/foldr)

这些或多或少是我尝试使用foldl / foldr编写函数时的想法: foldl / foldr从组成最终结果的逻辑中抽象出列表递归。 首先绘制一个与原始程序结构非常相似的函数,但使用foldr并且kinsert而不是递归函数是给foldr的函数: fun separate (k, x, L) = let fun kinsert (y, ys) = ... in foldr kinsert [] L end 这不是绝对必要的; kinsert也可能是匿名的。 你正在使用

相关文章

更多

最新问答

更多
  • 根据Woocommerce中的自定义字段计算自定义购物车商品价格(Custom cart item price calculation based on dimentions custom fields in Woocommerce)
  • 分开foreach项目并单独打印(Separate foreach items and print them individually)
  • 写模式管道是否同步?(Is write mode pipe synchronous?)
  • 发现可用的Windows Phone强调色和本地化名称(Discover available Windows Phone accent colors and localized names)
  • 使用多线程和WPF更新集合(Update Collection with multithreading and WPF)
  • 如何在字符串的情况下使用同步?(How should the synchronization be used in case of strings?)
  • 打印唯一的行,比较不超过N个字符(Print unique lines, compare no more than N characters)
  • Javascript / jQuery - 如何调用switch case从另一个函数执行(Javascript/jQuery - how to call a switch case to execute from another function)
  • Hbase超时错误不断发生(Hbase timeout errors keep occuring)
  • 如何在Delphi中更改TabControl中活动TAB的颜色(How to change the color of active TAB in a TabControl, in Delphi)
  • 正则表达式:在sublime文本中替换一些PHP代码(Regex: replace some pieces of php code in sublime text)
  • 在带有Scene2D的LibGDX中,如何在按下按钮时连续向右走?(In LibGDX with Scene2D, how can I continuously walk to the right when a button is pressed?)
  • 累加器如何在Haskell中工作?(How do accumulators work in Haskell?)
  • 使用开关检查市场和前缀与正确的货币符号(using switch to check market and prefix with correct currency symbol)
  • 在哪里分配一次使用类?(Where to allocate one time use class?)
  • 如何从两个DateTime / NaiveDateTime获取持续时间?(How do I get Duration from two DateTime / NaiveDateTime?)
  • 解析TimeSpan大于24小时?(Parse a TimeSpan greater than 24 hours? [duplicate])
  • 如何在球拍中本地更改阅读规则?(How to locally change reading rules in racket?)
  • 数据库应该由DI注入时的模拟存储(通过构造函数)(Mock storage when database should be injected by DI (through constructor))
  • 使用maven集成2个eclipse项目(Integrate 2 eclipse projects using maven)
  • 角度ng-repeat不检测变化(Angular ng-repeat not detecting changes)
  • Xaml组件在Silverlight + XNA应用程序的多个页面中可见(Xaml component visible in multiple pages in Silverlight+XNA applications)
  • 如何将`var`变量等同于另一个查询(How to equate `var` variable to another query)
  • 如何设计hyperledger链代码以适合您的业务?(how to design your chaincode of hyperledger to fit for your business?)
  • PHP readfile错误(PHP readfile error)
  • 在Date之后排序列表然后是时间(Sorting list after Date then time)
  • Android内部版本号(Android build number)
  • 在没有预设退出条件的情况下停止无限循环(stopping an infinite loop with no preset exit condition)
  • Phonegap应用程序全屏通过html页面中的按钮(Phonegap Application fullscreen through a button in html page)
  • PAA是否适合在门户网站中自动执行wcm库部署和设置?(Is PAA a good candidate for automating wcm library deployment and setup in portal?)