Skip to content

Commit

Permalink
Merge pull request #374 from sbt/wip/autoplugins
Browse files Browse the repository at this point in the history
Wip/autoplugins
  • Loading branch information
muuki88 committed Oct 22, 2014
2 parents dbf1500 + 91fd4c4 commit 3de9f83
Show file tree
Hide file tree
Showing 87 changed files with 1,297 additions and 949 deletions.
2 changes: 2 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ com.typesafe.sbt.SbtSite.SiteKeys.siteMappings <+= (baseDirectory) map { dir =>

site.sphinxSupport()

site.includeScaladoc()

ghpages.settings

git.remoteRepo := "git@github.com:sbt/sbt-native-packager.git"
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.5
sbt.version=0.13.6
175 changes: 129 additions & 46 deletions src/main/scala/com/typesafe/sbt/PackagerPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,56 +2,139 @@ package com.typesafe.sbt

import packager._

import debian.Keys.genChanges
import Keys.{ packageName, packageZipTarball, packageXzTarball }
import debian.DebianPlugin.autoImport.genChanges
import universal.UniversalPlugin.autoImport.{ packageZipTarball, packageXzTarball }
import sbt._
import sbt.Keys.{ normalizedName, packageBin }

object SbtNativePackager extends Plugin
with linux.LinuxPlugin
with debian.DebianPlugin
with rpm.RpmPlugin
with windows.WindowsPlugin
with docker.DockerPlugin
with universal.UniversalPlugin
with GenericPackageSettings {

val NativePackagerKeys = packager.Keys

val NativePackagerHelper = packager.MappingsHelper

def packagerSettings = linuxSettings ++
debianSettings ++
rpmSettings ++
windowsSettings ++
dockerSettings ++
universalSettings ++
Seq( // Bad defaults that let us at least not explode users who don't care about native packagers
NativePackagerKeys.maintainer := "",
NativePackagerKeys.packageDescription := "",
NativePackagerKeys.packageSummary := "",
NativePackagerKeys.packageName <<= normalizedName,
NativePackagerKeys.executableScriptName <<= NativePackagerKeys.packageName
)

import SettingsHelper._
def deploymentSettings = makeDeploymentSettings(Debian, packageBin in Debian, "deb") ++
makeDeploymentSettings(Rpm, packageBin in Rpm, "rpm") ++
makeDeploymentSettings(Windows, packageBin in Windows, "msi") ++
makeDeploymentSettings(Universal, packageBin in Universal, "zip") ++
addPackage(Universal, packageZipTarball in Universal, "tgz") ++
makeDeploymentSettings(UniversalDocs, packageBin in UniversalDocs, "zip") ++
addPackage(UniversalDocs, packageXzTarball in UniversalDocs, "txz") ++
makeDeploymentSettings(Debian, genChanges in Debian, "changes")
import sbt.Keys.{ name, normalizedName, packageBin }

/**
* == SBT Native Packager Plugin ==
*
* This is the top level plugin for the sbt native packager.
* You don't have to enable this by yourself, instead we recommend
* using an archetype for this.
*
* Currently you can choose between
*
* <ul>
* <li>JavaAppPackaging</li>
* <li>JavaServerPackaging</li>
* <li>AkkaAppPackging</li>
* </ul>
*
* == Configuration ==
*
* The are a few settings you should set if you want to build package
* no matter what format.
*
* {{{
* maintainer := "Your name <your.name@your-company.org>"
* packageDescription := "A short description of your application"
* }}}
*
* For all other general settings take a look at [[com.typesafe.sbt.packager.NativePackagerKeys]]
*
* @example Enable the plugin in the `build.sbt`
* {{{
* enablePlugins(SbtNativePackager)
* }}}
*
*/
object SbtNativePackager extends AutoPlugin {

/* === Universal Configuration === */
val Universal = universal.UniversalPlugin.autoImport.Universal
val UniversalDocs = universal.UniversalPlugin.autoImport.UniversalDocs
val UniversalSrc = universal.UniversalPlugin.autoImport.UniversalSrc

/* === OS Configurations === */
val Linux = linux.LinuxPlugin.autoImport.Linux
val Debian = debian.DebianPlugin.autoImport.Debian
val Rpm = rpm.RpmPlugin.autoImport.Rpm
val Windows = windows.WindowsPlugin.autoImport.Windows
val Docker = docker.DockerPlugin.autoImport.Docker

/**
* imports all [[com.typesafe.sbt.packager.NativePackagerKeys]] and two objects:
*
* === NativePackagerKeys ===
*
* This inclues ''all'' available keys provided by the sbt-native-packager.
* Used it if a setting/task key is not in scope.
*
* {{{
* NativePackagerKeys.notAutomaticallyImported := "cool!"
* }}}
*
* === NativePackagerHelper ===
*
* This object contains a set of helper methods for working with mappings.
*
*/
object autoImport extends packager.NativePackagerKeys {

val NativePackagerKeys = packager.Keys
val NativePackagerHelper = packager.MappingsHelper

import SettingsHelper._

def deploymentSettings = makeDeploymentSettings(Debian, packageBin in Debian, "deb") ++
makeDeploymentSettings(Rpm, packageBin in Rpm, "rpm") ++
makeDeploymentSettings(Windows, packageBin in Windows, "msi") ++
makeDeploymentSettings(Universal, packageBin in Universal, "zip") ++
addPackage(Universal, packageZipTarball in Universal, "tgz") ++
makeDeploymentSettings(UniversalDocs, packageBin in UniversalDocs, "zip") ++
addPackage(UniversalDocs, packageXzTarball in UniversalDocs, "txz") ++
makeDeploymentSettings(Debian, genChanges in Debian, "changes")
}

import autoImport._

override lazy val projectSettings = Seq(
// Bad defaults that let us at least not explode users who don't care about native packagers
maintainer := "",
packageDescription := name.value,
packageSummary := name.value,
packageName := normalizedName.value,
executableScriptName := normalizedName.value

)

object packageArchetype {
private[this] def genericMappingSettings: Seq[Setting[_]] = packagerSettings ++ mapGenericFilesToLinux ++ mapGenericFilesToWindows

/**
* == Recommended usage ==
*
* {{{
* enablePlugins(JavaAppPackaging)
* }}}
*/
@deprecated("Use enablePlugins(JavaAppPackaging)", "1.x")
def java_application: Seq[Setting[_]] =
genericMappingSettings ++ archetypes.JavaAppPackaging.settings
def akka_application: Seq[Setting[_]] =
genericMappingSettings ++ archetypes.AkkaApp.settings
def java_server: Seq[Setting[_]] =
genericMappingSettings ++ archetypes.JavaServerAppPackaging.settings
projectSettings ++
universal.UniversalPlugin.projectSettings ++
linux.LinuxPlugin.projectSettings ++
debian.DebianPlugin.projectSettings ++
rpm.RpmPlugin.projectSettings ++
docker.DockerPlugin.projectSettings ++
windows.WindowsPlugin.projectSettings ++
archetypes.JavaAppPackaging.projectSettings

/**
* {{{
* enablePlugins(AkkaAppPackaging)
* }}}
*/
@deprecated("Use enablePlugins(AkkaAppPackaging)", "1.x")
def akka_application: Seq[Setting[_]] = java_application ++ archetypes.AkkaAppPackaging.projectSettings

/**
* {{{
* enablePlugins(JavaServerAppPackaging)
* }}}
*/
@deprecated("Use enablePlugins(JavaServerAppPackaging)", "1.x")
def java_server: Seq[Setting[_]] = java_application ++ archetypes.JavaServerAppPackaging.projectSettings
}

// TODO - Add a few targets that detect the current OS and build a package for that OS.
Expand Down
144 changes: 0 additions & 144 deletions src/main/scala/com/typesafe/sbt/packager/GenericPackageSettings.scala

This file was deleted.

0 comments on commit 3de9f83

Please sign in to comment.