You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: src/sphinx/universal.rst
+34
Original file line number
Diff line number
Diff line change
@@ -142,6 +142,40 @@ Besides ``mappings``, the ``name``, ``sourceDirectory`` and ``target`` configura
142
142
143
143
**Note: The Universal plugin will make anything in a bin/ directory executable. This is to work around issues with JVM and file system manipulations.**
144
144
145
+
Mapping Examples
146
+
----------------
147
+
SBT provides and IO and .. Path: http://www.scala-sbt.org/0.13.1/docs/Detailed-Topics/Paths.html API, which
148
+
lets you define custom mappings easily. The files will appear in the generate universal zip, but also in your
149
+
debian/rpm/msi/dmg builds as described above in the conventions.
150
+
151
+
The ``packageBin in Compile`` dependency is only needed, if your files get generated
152
+
during the ``packageBin`` command or before. For static files you can remove it.
153
+
154
+
Mapping a complete directory.
155
+
156
+
.. code-block:: scala
157
+
158
+
mappings in Universal <++= (packageBin in Compile, target ) map { (_, target) =>
159
+
val dir = target / "scala-2.10" / "api"
160
+
(dir.***) pair relativeTo(dir.getParentFile)
161
+
}
162
+
163
+
This maps the ``api`` folder directly to the generate universal zip. ``dir.***`` is a short way for
164
+
``dir ** "*"``, which means _select all files including dir_. ``relativeTo(dir.getParentFile)``
165
+
generates a function with a ``file -> Option[String]`` mapping, which tries to generate a relative
166
+
string path from ``dir.getParentFile`` to the passed in file. ``pair`` uses the ``relativeTo``
167
+
function to generate a mapping ``File -> String``, which is _your file_ to _relative destination_.
168
+
169
+
Mapping the content of a directory.
170
+
171
+
.. code-block:: scala
172
+
173
+
mappings in Universal <++= (packageBin in Compile, target ) map { (_, target) =>
174
+
val dir = target / "scala-2.10" / "api"
175
+
(dir.*** --- dir) pair relativeTo(dir)
176
+
}
177
+
178
+
The ``dir`` gets excluded and is used as root for ``relativeTo(dir)``.
0 commit comments