-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simple multi module SBT project with native packager plugin for deplo…
…yment.
- Loading branch information
1 parent
f1362a3
commit dc41753
Showing
11 changed files
with
218 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#SBT | ||
target | ||
|
||
# Mac | ||
.DS_Store | ||
|
||
# IntelliJ | ||
.idea | ||
.idea_modules | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.history | ||
|
||
project/target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
Multi-Project-Skeleton | ||
------------ | ||
|
||
This project aims to simplify creating a multi module project ready to package and deploy to a server. | ||
|
||
It provides some minimal code just to demonstrate usage. | ||
|
||
Requires | ||
--------------- | ||
* Please download latest version of SBT. | ||
* [sbt 1.0.3](http://www.scala-sbt.org) | ||
|
||
Use | ||
--------------- | ||
Clone and update the project name from build.sbt | ||
|
||
$ git clone git://github.com/fractal/multi-project-skeleton my-project | ||
$ cd my-project | ||
$ rm -rf .git | ||
$ vi build.sbt # change name to my-project, and organization to something that suits you | ||
$ sbt | ||
> app/run | ||
> app/packageZipTarball | ||
|
||
Author | ||
-------------------- | ||
Fernando Racca | ||
|
||
[@quant_leap](http://twitter.com/quant_leap) | ||
|
||
Simpler version: | ||
[fractal/skeleton](http://github.com/fractal/skeleton) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
|
||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<layout class="ch.qos.logback.classic.PatternLayout"> | ||
<Pattern> | ||
%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n | ||
</Pattern> | ||
</layout> | ||
</appender> | ||
|
||
<logger name="com.github.fractal.mpskeleton" level="debug" /> | ||
|
||
<root level="info"> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
|
||
</configuration> |
15 changes: 15 additions & 0 deletions
15
app/src/main/scala/com/github/fractal/mpskeleton/app/Application.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.github.fractal.mpskeleton.app | ||
|
||
import com.github.fractal.mpskeleton.common.KafkaConfig | ||
import com.github.fractal.mpskeleton.kafka.DummyKafkaConsumer | ||
|
||
object Application extends App { | ||
|
||
val kafkaConsumer = DummyKafkaConsumer(SimpleKafkaConfig()) | ||
|
||
kafkaConsumer.consume() | ||
|
||
} | ||
|
||
|
||
case class SimpleKafkaConfig(topic : String = "dummyTopic") extends KafkaConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
name := "multi-project-skeleton" | ||
|
||
import Dependencies._ | ||
|
||
// For Settings/Task reference, see http://www.scala-sbt.org/release/sxr/sbt/Keys.scala.html | ||
|
||
lazy val common = (project in file("common")).settings(commonSettings) | ||
|
||
lazy val kafka = (project in file("kafka")).settings(kafkaSettings).dependsOn(common) | ||
|
||
lazy val app = (project in file("app")). | ||
settings(appSettings). | ||
dependsOn(kafka). | ||
dependsOn(common). | ||
enablePlugins(UniversalPlugin). | ||
enablePlugins(JavaAppPackaging) | ||
|
||
lazy val root = Project( | ||
id = "root", | ||
base = file(".") | ||
).aggregate(common, kafka, app) | ||
.settings(Defaults.coreDefaultSettings ++ dontPublishRootModuleSettings) | ||
|
||
lazy val generalModuleSettings = Seq( | ||
organization := "com.github.fractal", | ||
version := "1.4", | ||
scalaVersion := "2.12.4", | ||
// Compiler settings. Use scalac -X for other options and their description. | ||
// See Here for more info http://www.scala-lang.org/files/archive/nightly/docs/manual/html/scalac.html | ||
scalacOptions ++= List("-feature","-deprecation", "-unchecked", "-Xlint"), | ||
|
||
// Uncommenting this line sometime helps troubleshooting if you are having issues with jars download (for example, if behind a proxy) | ||
//ivyLoggingLevel := UpdateLogging.Full | ||
publishArtifact in Test := false, | ||
publishTo := { | ||
val basePublishingUrl = "http://internal-repo/" //your proxy reporsitory url | ||
val suffix = if(isSnapshot.value) "snapshots" else "releases" | ||
val internalRepoBaseName = "internal-repo" | ||
Some(s"$internalRepoBaseName-$suffix" at (basePublishingUrl + suffix)) | ||
} | ||
) | ||
|
||
lazy val dontPublishRootModuleSettings = Seq( | ||
publishLocal := {}, | ||
publish := {} | ||
) | ||
|
||
|
||
lazy val commonSettings = generalModuleSettings ++ Seq( | ||
libraryDependencies ++= commonDependencies | ||
) | ||
|
||
lazy val kafkaSettings = generalModuleSettings ++ Seq( | ||
libraryDependencies ++= kafkaDependencies | ||
) | ||
|
||
lazy val appSettings = generalModuleSettings ++ Seq( | ||
libraryDependencies ++= appDependencies | ||
) |
9 changes: 9 additions & 0 deletions
9
common/src/main/scala/com/github/fractal/mpskeleton/common/KafkaConfig.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.github.fractal.mpskeleton.common | ||
|
||
|
||
trait KafkaConfig { | ||
|
||
def topic: String | ||
|
||
} | ||
|
15 changes: 15 additions & 0 deletions
15
kafka/src/main/scala/com/github/fractal/mpskeleton/kafka/DummyKafkaConsumer.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.github.fractal.mpskeleton.kafka | ||
|
||
import com.github.fractal.mpskeleton.common.KafkaConfig | ||
|
||
case class DummyKafkaConsumer(kafkaConfig: KafkaConfig) { | ||
|
||
import KafkaConsumer.logger | ||
|
||
def consume(): Unit = { | ||
val topic = kafkaConfig.topic | ||
|
||
logger.info(s"[Consumer] @ $topic ") | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
kafka/src/main/scala/com/github/fractal/mpskeleton/kafka/SimpleKafkaConsumer.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.github.fractal.mpskeleton.kafka | ||
|
||
import com.github.fractal.mpskeleton.common.KafkaConfig | ||
import org.slf4j.LoggerFactory | ||
|
||
|
||
trait SimpleKafkaConsumer { | ||
def kafkaConfig: KafkaConfig | ||
} | ||
|
||
|
||
object KafkaConsumer { | ||
|
||
val logger = LoggerFactory.getLogger(KafkaConsumer.getClass) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
import sbt._ | ||
|
||
object Dependencies extends Versions { | ||
|
||
lazy val commonDependencies = Seq( | ||
"org.slf4j" % "slf4j-api" % slf4jVersion, | ||
"org.scalatest" %% "scalatest" % scalaTestVersion % "test" | ||
) | ||
|
||
lazy val kafkaDependencies = Seq( | ||
"org.slf4j" % "slf4j-api" % slf4jVersion, | ||
"org.scalatest" %% "scalatest" % scalaTestVersion % "test" | ||
) | ||
|
||
|
||
lazy val appDependencies = Seq( | ||
"ch.qos.logback" % "logback-classic" % "1.2.3", | ||
"org.scalatest" %% "scalatest" % scalaTestVersion % "test" | ||
) | ||
|
||
} | ||
|
||
trait Versions { | ||
|
||
lazy val slf4jVersion = "1.7.25" | ||
lazy val scalaTestVersion = "3.0.4" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sbt.version=1.0.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
resolvers += Classpaths.sbtPluginReleases | ||
|
||
// See docs : https://github.com/sbt/sbt-native-packager | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.1") | ||
//Documentation is not published, which can cause some issues when using Intellij's SBT Shell Library | ||
|
||
|
||
//just a useful tool graph depenency tool. comment out if having troubles behind certain proxies | ||
//addSbtPlugin("net-virtual-void" % "sbt-dependency-graph" % "0.9.0") |