@@ -2,56 +2,139 @@ package com.typesafe.sbt
2
2
3
3
import packager ._
4
4
5
- import debian .Keys .genChanges
6
- import Keys .{ packageName , packageZipTarball , packageXzTarball }
5
+ import debian .DebianPlugin . autoImport .genChanges
6
+ import universal . UniversalPlugin . autoImport .{ packageZipTarball , packageXzTarball }
7
7
import sbt ._
8
- import sbt .Keys .{ normalizedName , packageBin }
9
-
10
- object SbtNativePackager extends Plugin
11
- with linux.LinuxPlugin
12
- with debian.DebianPlugin
13
- with rpm.RpmPlugin
14
- with windows.WindowsPlugin
15
- with docker.DockerPlugin
16
- with universal.UniversalPlugin
17
- with GenericPackageSettings {
18
-
19
- val NativePackagerKeys = packager.Keys
20
-
21
- val NativePackagerHelper = packager.MappingsHelper
22
-
23
- def packagerSettings = linuxSettings ++
24
- debianSettings ++
25
- rpmSettings ++
26
- windowsSettings ++
27
- dockerSettings ++
28
- universalSettings ++
29
- Seq ( // Bad defaults that let us at least not explode users who don't care about native packagers
30
- NativePackagerKeys .maintainer := " " ,
31
- NativePackagerKeys .packageDescription := " " ,
32
- NativePackagerKeys .packageSummary := " " ,
33
- NativePackagerKeys .packageName <<= normalizedName,
34
- NativePackagerKeys .executableScriptName <<= NativePackagerKeys .packageName
35
- )
36
-
37
- import SettingsHelper ._
38
- def deploymentSettings = makeDeploymentSettings(Debian , packageBin in Debian , " deb" ) ++
39
- makeDeploymentSettings(Rpm , packageBin in Rpm , " rpm" ) ++
40
- makeDeploymentSettings(Windows , packageBin in Windows , " msi" ) ++
41
- makeDeploymentSettings(Universal , packageBin in Universal , " zip" ) ++
42
- addPackage(Universal , packageZipTarball in Universal , " tgz" ) ++
43
- makeDeploymentSettings(UniversalDocs , packageBin in UniversalDocs , " zip" ) ++
44
- addPackage(UniversalDocs , packageXzTarball in UniversalDocs , " txz" ) ++
45
- makeDeploymentSettings(Debian , genChanges in Debian , " changes" )
8
+ import sbt .Keys .{ name , normalizedName , packageBin }
9
+
10
+ /**
11
+ * == SBT Native Packager Plugin ==
12
+ *
13
+ * This is the top level plugin for the sbt native packager.
14
+ * You don't have to enable this by yourself, instead we recommend
15
+ * using an archetype for this.
16
+ *
17
+ * Currently you can choose between
18
+ *
19
+ * <ul>
20
+ * <li>JavaAppPackaging</li>
21
+ * <li>JavaServerPackaging</li>
22
+ * <li>AkkaAppPackging</li>
23
+ * </ul>
24
+ *
25
+ * == Configuration ==
26
+ *
27
+ * The are a few settings you should set if you want to build package
28
+ * no matter what format.
29
+ *
30
+ * {{{
31
+ * maintainer := "Your name <[email protected] >"
32
+ * packageDescription := "A short description of your application"
33
+ * }}}
34
+ *
35
+ * For all other general settings take a look at [[com.typesafe.sbt.packager.NativePackagerKeys ]]
36
+ *
37
+ * @example Enable the plugin in the `build.sbt`
38
+ * {{{
39
+ * enablePlugins(SbtNativePackager)
40
+ * }}}
41
+ *
42
+ */
43
+ object SbtNativePackager extends AutoPlugin {
44
+
45
+ /* === Universal Configuration === */
46
+ val Universal = universal.UniversalPlugin .autoImport.Universal
47
+ val UniversalDocs = universal.UniversalPlugin .autoImport.UniversalDocs
48
+ val UniversalSrc = universal.UniversalPlugin .autoImport.UniversalSrc
49
+
50
+ /* === OS Configurations === */
51
+ val Linux = linux.LinuxPlugin .autoImport.Linux
52
+ val Debian = debian.DebianPlugin .autoImport.Debian
53
+ val Rpm = rpm.RpmPlugin .autoImport.Rpm
54
+ val Windows = windows.WindowsPlugin .autoImport.Windows
55
+ val Docker = docker.DockerPlugin .autoImport.Docker
56
+
57
+ /**
58
+ * imports all [[com.typesafe.sbt.packager.NativePackagerKeys ]] and two objects:
59
+ *
60
+ * === NativePackagerKeys ===
61
+ *
62
+ * This inclues ''all'' available keys provided by the sbt-native-packager.
63
+ * Used it if a setting/task key is not in scope.
64
+ *
65
+ * {{{
66
+ * NativePackagerKeys.notAutomaticallyImported := "cool!"
67
+ * }}}
68
+ *
69
+ * === NativePackagerHelper ===
70
+ *
71
+ * This object contains a set of helper methods for working with mappings.
72
+ *
73
+ */
74
+ object autoImport extends packager.NativePackagerKeys {
75
+
76
+ val NativePackagerKeys = packager.Keys
77
+ val NativePackagerHelper = packager.MappingsHelper
78
+
79
+ import SettingsHelper ._
80
+
81
+ def deploymentSettings = makeDeploymentSettings(Debian , packageBin in Debian , " deb" ) ++
82
+ makeDeploymentSettings(Rpm , packageBin in Rpm , " rpm" ) ++
83
+ makeDeploymentSettings(Windows , packageBin in Windows , " msi" ) ++
84
+ makeDeploymentSettings(Universal , packageBin in Universal , " zip" ) ++
85
+ addPackage(Universal , packageZipTarball in Universal , " tgz" ) ++
86
+ makeDeploymentSettings(UniversalDocs , packageBin in UniversalDocs , " zip" ) ++
87
+ addPackage(UniversalDocs , packageXzTarball in UniversalDocs , " txz" ) ++
88
+ makeDeploymentSettings(Debian , genChanges in Debian , " changes" )
89
+ }
90
+
91
+ import autoImport ._
92
+
93
+ override lazy val projectSettings = Seq (
94
+ // Bad defaults that let us at least not explode users who don't care about native packagers
95
+ maintainer := " " ,
96
+ packageDescription := name.value,
97
+ packageSummary := name.value,
98
+ packageName := normalizedName.value,
99
+ executableScriptName := normalizedName.value
100
+
101
+ )
46
102
47
103
object packageArchetype {
48
- private [this ] def genericMappingSettings : Seq [Setting [_]] = packagerSettings ++ mapGenericFilesToLinux ++ mapGenericFilesToWindows
104
+
105
+ /**
106
+ * == Recommended usage ==
107
+ *
108
+ * {{{
109
+ * enablePlugins(JavaAppPackaging)
110
+ * }}}
111
+ */
112
+ @ deprecated(" Use enablePlugins(JavaAppPackaging)" , " 1.x" )
49
113
def java_application : Seq [Setting [_]] =
50
- genericMappingSettings ++ archetypes.JavaAppPackaging .settings
51
- def akka_application : Seq [Setting [_]] =
52
- genericMappingSettings ++ archetypes.AkkaApp .settings
53
- def java_server : Seq [Setting [_]] =
54
- genericMappingSettings ++ archetypes.JavaServerAppPackaging .settings
114
+ projectSettings ++
115
+ universal.UniversalPlugin .projectSettings ++
116
+ linux.LinuxPlugin .projectSettings ++
117
+ debian.DebianPlugin .projectSettings ++
118
+ rpm.RpmPlugin .projectSettings ++
119
+ docker.DockerPlugin .projectSettings ++
120
+ windows.WindowsPlugin .projectSettings ++
121
+ archetypes.JavaAppPackaging .projectSettings
122
+
123
+ /**
124
+ * {{{
125
+ * enablePlugins(AkkaAppPackaging)
126
+ * }}}
127
+ */
128
+ @ deprecated(" Use enablePlugins(AkkaAppPackaging)" , " 1.x" )
129
+ def akka_application : Seq [Setting [_]] = java_application ++ archetypes.AkkaAppPackaging .projectSettings
130
+
131
+ /**
132
+ * {{{
133
+ * enablePlugins(JavaServerAppPackaging)
134
+ * }}}
135
+ */
136
+ @ deprecated(" Use enablePlugins(JavaServerAppPackaging)" , " 1.x" )
137
+ def java_server : Seq [Setting [_]] = java_application ++ archetypes.JavaServerAppPackaging .projectSettings
55
138
}
56
139
57
140
// TODO - Add a few targets that detect the current OS and build a package for that OS.
0 commit comments