2016-03-29 11 views
3

マルチモジュールビルドとsbt-native-packagerに関するすべての例では、サブプロジェクトを1つのパッケージにまとめます。私はそれぞれがマイクロサービスを提供するサブプロジェクトを持っています。私はこれらのそれぞれがそれ自身のネイティブパッケージを持っているべきだと信じていますが、私はそれを行う方法を見ておらず、すべてのサブプロジェクトのために1つのコマンドを構築しています。サブプロジェクトごとにRPMを作成するsbt-native-packagerを使用してマルチプロジェクトビルドを定義する方法

答えて

2

これは簡単なことです。パッケージ化するサブプロジェクトごとにネイティブパッケージャの設定を提供するだけで、集約するプロジェクトには提供しません。

私はそれに応じてhttps://github.com/muuki88/sbt-native-packager-examples/tree/master/multi-module-buildを変更することでテストした:

import NativePackagerKeys._ 

name := "mukis-fullstack" 

// used like the groupId in maven 
organization in ThisBuild := "de.mukis" 

// all sub projects have the same version 
version in ThisBuild := "1.0" 

scalaVersion in ThisBuild := "2.11.2" 

// common dependencies 
libraryDependencies in ThisBuild ++= Seq(
    "com.typesafe" % "config" % "1.2.0" 
) 

// this is the root project, aggregating all sub projects 
lazy val root = Project(
    id = "root", 
    base = file("."), 
    // configure your native packaging settings here 
// settings = packageArchetype.java_server++ Seq(
//  maintainer := "John Smith <[email protected]>", 
//  packageDescription := "Fullstack Application", 
//  packageSummary := "Fullstack Application", 
     // entrypoint 
//  mainClass in Compile := Some("de.mukis.frontend.ProductionServer") 
// ), 
    // always run all commands on each sub project 
    aggregate = Seq(frontend, backend, api) 
) dependsOn(frontend, backend, api) // this does the actual aggregation 

// --------- Project Frontend ------------------ 
lazy val frontend = Project(
    id = "frontend", 
    base = file("frontend"), 
    settings = packageArchetype.java_server++ Seq(
     maintainer := "John Smith <[email protected]>", 
     packageDescription := "Frontend appplication", 
     mainClass in Compile := Some("de.mukis.frontend.ProductionServer") 
    ) 
) dependsOn(api) 


// --------- Project Backend ---------------- 
lazy val backend = Project(
    id = "backend", 
    base = file("backend"), 
    settings = packageArchetype.java_server++ Seq(
     maintainer := "John Smith <[email protected]>", 
     packageDescription := "Fullstack Application", 
     packageSummary := "Fullstack Application", 
     // entrypoint 
     mainClass in Compile := Some("de.mukis.frontend.ProductionServer") 
    ) 
) dependsOn(api) 

// --------- Project API ------------------ 
lazy val api = Project(
    id = "api", 
    base = file("api") 

結果:

debian:packageBin 
...misc messages elided... 
[info] dpkg-deb: building package `frontend' in `../frontend_1.0_all.deb'. 
[info] dpkg-deb: building package `backend' in `../backend_1.0_all.deb'. 
関連する問題