Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide docs how to use the plugin with multi-project projects #52

Closed
Bohtvaroh opened this issue Oct 22, 2013 · 7 comments
Closed

Provide docs how to use the plugin with multi-project projects #52

Bohtvaroh opened this issue Oct 22, 2013 · 7 comments
Labels
documentation Documentation should be extended or updated

Comments

@Bohtvaroh
Copy link

Hi, Josh. I try to use this plugin with multi-project setup described in your book "SBT in Action" (btw, I can't skip dots at the end of the lines like in the book - it doesn't compile).

My build.sbt:

import dependencies._
import common._

packageArchetype.java_application

name := "CoolProject"

lazy val common = (
  DefProject("common").
  settings(libraryDependencies ++= commonDependencies)
)

lazy val backend = (
  DefProject("backend").
  dependsOn(common).
  settings(libraryDependencies ++= backendDependencies)
)

lazy val frontend = (
  DefProject("frontend").
  dependsOn(backend).
  settings(libraryDependencies ++= frontendDependencies)
)

common.scala:

import sbt._
import Keys._

object common {
  val commonSettings = Seq(
    organization := "com.example",
    organizationName := "AwesomeOrg",
    version := "0.1-SNAPSHOT",

    scalaVersion := "2.10.3",
    scalacOptions ++= Seq("-feature", "-unchecked", "-encoding", "utf8"),

    resolvers ++= Seq(
      "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
    )
  )

  def DefProject(name: String): Project = {
    Project(name, file(name)).
    settings(commonSettings: _*)
  }
}

and dependencies.scala:

import sbt._

object dependencies {
  // versions
  val scalaARMVersion = "1.3"

  val jodaTimeVersion = "2.3"
  val jodaConvertVersion = "1.2"

  val apachePOIVersion = "3.9"

  val reactiveMongoVersion = "0.9"

  val scalaTestVersion = "1.9.1"
  val scalaCheckVersion = "1.10.1"

  // libraries
  val scalaARM = "com.jsuereth" %% "scala-arm" % scalaARMVersion

  val jodaTime = "joda-time" % "joda-time" % jodaTimeVersion
  val jodaConvert = "org.joda" % "joda-convert" % jodaConvertVersion

  val apachePOI = "org.apache.poi" % "poi-scratchpad" % apachePOIVersion

  val reactiveMongo = "org.reactivemongo" %% "reactivemongo" % reactiveMongoVersion

  val scalaTest = "org.scalatest" %% "scalatest" % scalaTestVersion
  val scalaCheck = "org.scalacheck" %% "scalacheck" % scalaCheckVersion

  // projects
  val commonDependencies = Seq(
    scalaTest % "test", scalaCheck % "test"
  )

  val backendDependencies = commonDependencies ++ Seq(
    scalaARM,

    jodaTime, jodaConvert,

    apachePOI,

    reactiveMongo
  )

  val frontendDependencies = commonDependencies ++ Seq(
  )
}

But when I invoke 'stage' from the root I don't get my sub-projects and their dependencies. I just want to include all my sub-projects. Can you provide some documentation describing this plugin usage in such a common scenario? Thank you so much for your book and this plugin!

@jsuereth
Copy link
Member

I'll try to detail this out soon.

Basically, the "archetypes" are a per-project based packaging scenario. If you want to package multiple projects, you may need to "manually" construct the mappings in Universal that aggregates all your sub-projects and then use the mechanism to create native packages from these.

I'll see if perhaps I can promote that idea as first class.

@Bohtvaroh
Copy link
Author

Josh, it would be very nice to support this idea as first class. It's common to have frontend, backend, common sub-projects and wish to merge them together into a single package without too much pain.

For now, can you provide some steps or code required to construct this setup manually?

Thanks you.

@muuki88 muuki88 added the docs label Feb 4, 2014
@muuki88
Copy link
Contributor

muuki88 commented Mar 9, 2014

I think we should put this in our next milestone 0.8.0

@jsuereth
Copy link
Member

sounds good. Sorry I've been AFK, trying to push 0.13.2-RC1 out.

@muuki88 muuki88 added this to the 0.8.0 - windows services milestone May 17, 2014
@ogirardot
Copy link

bump :)
any news on that, i'm trying to do pretty much that (by merging native packager result on subprojects for the master project).

@muuki88
Copy link
Contributor

muuki88 commented Jun 19, 2014

Not from me :( I'm currently not having that much experience with multi-module-sbt projects. I'm doing this currently with a configuration like this

  lazy val frontend = Project(
    id = "frontend",
    base = file("."),
    settings = defaultSettings ++ playScalaSettings ++ packageArchetype.java_server ++ Packaging.debian ++ Seq(
      libraryDependencies ++= Dependencies.frontend
    ),
    aggregate = Seq(common, api)
  ) dependsOn(common, api)


  // --------- Project Commons ----------------
  lazy val common = Project(
    id = "common",
    base = file("sub_common"),
    settings = defaultSettings ++ Seq(
      libraryDependencies ++= Dependencies.common
    )
  )

  // --------- Project API ------------------
  lazy val api = Project(
    id = "api",
    base = file("sub_api"),
    settings = defaultSettings ++ Seq(
      libraryDependencies ++= Dependencies.common
    )
  ) dependsOn(common)

@jsuereth
Copy link
Member

Yeah, so we only support "whole" packages right now, with all dependent jars bundles, and no sharing. It'd be an epic feature request to do more, and possibly some socialization of how to do so.

Otherwise @muuki88's code looks great except for that defaultSettings bit :). Using defaultSettings is effectively deprecated in 0.13.5 (as it means you're going to bypass the entire AutoPlugin mechanism), so here's what I would write:

lazy val frontend = (Project(
    id = "frontend",
    base = file("."),
    aggregate = Seq(common, api)
  )  settings(playScalaSettings:_*)
     settings(packageArchetype.java_server:_*) settings(
      libraryDependencies ++= Dependencies.frontend
  ),dependsOn(common, api))


  // --------- Project Commons ----------------
  lazy val common = Project(
    id = "common",
    base = file("sub_common")
   ) settings(
      libraryDependencies ++= Dependencies.common
    )
  )

  // --------- Project API ------------------
  lazy val api = Project(
    id = "api",
    base = file("sub_api"),
  ) settings (
      libraryDependencies ++= Dependencies.common
    )
  ) dependsOn(common)

@muuki88 muuki88 modified the milestones: 0.8.0-M1 Windows Services, 0.8.0 - windows services Aug 31, 2014
muuki88 added a commit that referenced this issue Sep 24, 2014
muuki88 added a commit that referenced this issue Sep 25, 2014
…in Universal and Linux

Conflicts:
	src/sphinx/DetailedTopics/index.rst
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation should be extended or updated
Projects
None yet
Development

No branches or pull requests

4 participants