-
Notifications
You must be signed in to change notification settings - Fork 23
/
Library-Management.html
543 lines (524 loc) · 40.2 KB
/
Library-Management.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Library Management — sbt Documentation</title>
<link rel="stylesheet" href="../_static/style.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/issuetracker.css" type="text/css" />
<link rel="stylesheet" href="../_static/base.css" type="text/css" />
<link rel="stylesheet" href="../_static/docs.css" type="text/css" />
<link rel="stylesheet" href="../_static/syntax.css" type="text/css" />
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Exo:300,400,600,700" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.12.1',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../../../versions.js"></script>
<script type="text/javascript" src="../_static/set-versions.js"></script>
<link rel="top" title="sbt Documentation" href="../index.html" />
<link rel="up" title="Detailed Topics" href="index.html" />
<link rel="next" title="Local Scala" href="Local-Scala.html" />
<link rel="prev" title="Launcher Specification" href="Launcher.html" />
</head>
<body>
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<ul class="nav">
<li><a href="http://www.scala-sbt.org/">Home</a></li>
<li><a href="../index.html">Documentation</a></li>
<li><a href="../Getting-Started/Setup.html">Download</a></li>
<li><a href="http://groups.google.com/group/simple-build-tool">Mailing List</a></li>
<li><a href="http://github.com/harrah/xsbt">Project</a></li>
</ul>
</div>
</div>
</div>
<div class="main">
<div class="container">
<div class="page-title">Library Management</div>
<div class="search-box">
<form method="get" action="http://www.google.com/search" id="search">
<input type="search" placeholder="Search 0.12.1 on Google" name="q" results="10" size="29" id="search-input">
<input type="hidden" name="sitesearch" value="http://www.scala-sbt.org/release/docs/">
<input type="submit" id="submit-search">
</form>
</div>
</div>
<div class="main-container">
<div class="container">
<div class="row">
<div class="span12">
<ul class="breadcrumb">
<li>
<span class="divider">|</span> <a href="Local-Scala.html">Local Scala</a> <span class="divider">»</span>
</li>
<li>
<span class="divider">></span><a href="index.html">Detailed Topics</a>
</li>
<li>
<a href="../index.html">Contents</a>
</li>
<li>
<span class="divider">«</span> <a href="Launcher.html">Launcher Specification</a> <span class="divider">|</span>
</li>
<li>
<select id="versions"><option selected value="0.12.1">Version 0.12.1</option></select>
</li>
</ul>
</div>
</div>
<div class="row">
<div class="span9">
<div class="section" id="library-management">
<h1>Library Management<a class="headerlink" href="#library-management" title="Permalink to this headline">¶</a></h1>
<p>There's now a <a class="reference internal" href="../Getting-Started/Library-Dependencies.html"><em>getting started page</em></a>
about library management, which you may want to read first.</p>
<p><em>Wiki Maintenance Note:</em> it would be nice to remove the overlap between
this page and the getting started page, leaving this page with the more
advanced topics such as checksums and external Ivy files.</p>
<div class="section" id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>There are two ways for you to manage libraries with sbt: manually or
automatically. These two ways can be mixed as well. This page discusses
the two approaches. All configurations shown here are settings that go
either directly in a <a class="reference internal" href="../Getting-Started/Basic-Def.html"><em>.sbt file</em></a> or are
appended to the <tt class="docutils literal"><span class="pre">settings</span></tt> of a Project in a <a class="reference internal" href="../Getting-Started/Full-Def.html"><em>.scala file</em></a>.</p>
</div>
<div class="section" id="manual-dependency-management">
<h2>Manual Dependency Management<a class="headerlink" href="#manual-dependency-management" title="Permalink to this headline">¶</a></h2>
<p>Manually managing dependencies involves copying any jars that you want
to use to the <tt class="docutils literal"><span class="pre">lib</span></tt> directory. sbt will put these jars on the
classpath during compilation, testing, running, and when using the
interpreter. You are responsible for adding, removing, updating, and
otherwise managing the jars in this directory. No modifications to your
project definition are required to use this method unless you would like
to change the location of the directory you store the jars in.</p>
<p>To change the directory jars are stored in, change the
<tt class="docutils literal"><span class="pre">unmanaged-base</span></tt> setting in your project definition. For example, to
use <tt class="docutils literal"><span class="pre">custom_lib/</span></tt>:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">unmanagedBase</span> <span class="o"><<=</span> <span class="n">baseDirectory</span> <span class="o">{</span> <span class="n">base</span> <span class="k">=></span> <span class="n">base</span> <span class="o">/</span> <span class="s">"custom_lib"</span> <span class="o">}</span>
</pre></div>
</div>
<p>If you want more control and flexibility, override the
<tt class="docutils literal"><span class="pre">unmanaged-jars</span></tt> task, which ultimately provides the manual
dependencies to sbt. The default implementation is roughly:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">unmanagedJars</span> <span class="n">in</span> <span class="nc">Compile</span> <span class="o"><<=</span> <span class="n">baseDirectory</span> <span class="n">map</span> <span class="o">{</span> <span class="n">base</span> <span class="k">=></span> <span class="o">(</span><span class="n">base</span> <span class="o">**</span> <span class="s">"*.jar"</span><span class="o">).</span><span class="n">classpath</span> <span class="o">}</span>
</pre></div>
</div>
<p>If you want to add jars from multiple directories in addition to the
default directory, you can do:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">unmanagedJars</span> <span class="n">in</span> <span class="nc">Compile</span> <span class="o"><++=</span> <span class="n">baseDirectory</span> <span class="n">map</span> <span class="o">{</span> <span class="n">base</span> <span class="k">=></span>
<span class="k">val</span> <span class="n">baseDirectories</span> <span class="k">=</span> <span class="o">(</span><span class="n">base</span> <span class="o">/</span> <span class="s">"libA"</span><span class="o">)</span> <span class="o">+++</span> <span class="o">(</span><span class="n">base</span> <span class="o">/</span> <span class="s">"b"</span> <span class="o">/</span> <span class="s">"lib"</span><span class="o">)</span> <span class="o">+++</span> <span class="o">(</span><span class="n">base</span> <span class="o">/</span> <span class="s">"libC"</span><span class="o">)</span>
<span class="k">val</span> <span class="n">customJars</span> <span class="k">=</span> <span class="o">(</span><span class="n">baseDirectories</span> <span class="o">**</span> <span class="s">"*.jar"</span><span class="o">)</span> <span class="o">+++</span> <span class="o">(</span><span class="n">base</span> <span class="o">/</span> <span class="s">"d"</span> <span class="o">/</span> <span class="s">"my.jar"</span><span class="o">)</span>
<span class="n">customJars</span><span class="o">.</span><span class="n">classpath</span>
<span class="o">}</span>
</pre></div>
</div>
<p>See <a class="reference internal" href="Paths.html"><em>Paths</em></a> for more information on building up paths.</p>
</div>
<div class="section" id="automatic-dependency-management">
<h2>Automatic Dependency Management<a class="headerlink" href="#automatic-dependency-management" title="Permalink to this headline">¶</a></h2>
<p>This method of dependency management involves specifying the direct
dependencies of your project and letting sbt handle retrieving and
updating your dependencies. sbt supports three ways of specifying these
dependencies:</p>
<ul class="simple">
<li>Declarations in your project definition</li>
<li>Maven POM files (dependency definitions only: no repositories)</li>
<li>Ivy configuration and settings files</li>
</ul>
<p>sbt uses <a class="reference external" href="http://ant.apache.org/ivy/">Apache Ivy</a> to implement
dependency management in all three cases. The default is to use inline
declarations, but external configuration can be explicitly selected. The
following sections describe how to use each method of automatic
dependency management.</p>
<div class="section" id="inline-declarations">
<h3>Inline Declarations<a class="headerlink" href="#inline-declarations" title="Permalink to this headline">¶</a></h3>
<p>Inline declarations are a basic way of specifying the dependencies to be
automatically retrieved. They are intended as a lightweight alternative
to a full configuration using Ivy.</p>
<div class="section" id="dependencies">
<h4>Dependencies<a class="headerlink" href="#dependencies" title="Permalink to this headline">¶</a></h4>
<p>Declaring a dependency looks like:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">libraryDependencies</span> <span class="o">+=</span> <span class="n">groupID</span> <span class="o">%</span> <span class="n">artifactID</span> <span class="o">%</span> <span class="n">revision</span>
</pre></div>
</div>
<p>or</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">libraryDependencies</span> <span class="o">+=</span> <span class="n">groupID</span> <span class="o">%</span> <span class="n">artifactID</span> <span class="o">%</span> <span class="n">revision</span> <span class="o">%</span> <span class="n">configuration</span>
</pre></div>
</div>
<p>See <a class="reference internal" href="../Dormant/Configurations.html"><em>Configurations</em></a> for details on configuration mappings. Also,
several dependencies can be declared together:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">libraryDependencies</span> <span class="o">++=</span> <span class="nc">Seq</span><span class="o">(</span>
<span class="n">groupID</span> <span class="o">%%</span> <span class="n">artifactID</span> <span class="o">%</span> <span class="n">revision</span><span class="o">,</span>
<span class="n">groupID</span> <span class="o">%%</span> <span class="n">otherID</span> <span class="o">%</span> <span class="n">otherRevision</span>
<span class="o">)</span>
</pre></div>
</div>
<p>If you are using a dependency that was built with sbt, double the first
<tt class="docutils literal"><span class="pre">%</span></tt> to be <tt class="docutils literal"><span class="pre">%%</span></tt>:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">libraryDependencies</span> <span class="o">+=</span> <span class="n">groupID</span> <span class="o">%%</span> <span class="n">artifactID</span> <span class="o">%</span> <span class="n">revision</span>
</pre></div>
</div>
<p>This will use the right jar for the dependency built with the version of
Scala that you are currently using. If you get an error while resolving
this kind of dependency, that dependency probably wasn't published for
the version of Scala you are using. See <a class="reference internal" href="Cross-Build.html"><em>Cross-building</em></a> for details.</p>
<p>Ivy can select the latest revision of a module according to constraints
you specify. Instead of a fixed revision like <tt class="docutils literal"><span class="pre">"1.6.1"</span></tt>, you specify
<tt class="docutils literal"><span class="pre">"latest.integration"</span></tt>, <tt class="docutils literal"><span class="pre">"2.9.+"</span></tt>, or <tt class="docutils literal"><span class="pre">"[1.0,)"</span></tt>. See the <a class="reference external" href="http://ant.apache.org/ivy/history/2.2.0/ivyfile/dependency.html#revision">Ivy
revisions</a>
documentation for details.</p>
</div>
<div class="section" id="resolvers">
<h4>Resolvers<a class="headerlink" href="#resolvers" title="Permalink to this headline">¶</a></h4>
<p>sbt uses the standard Maven2 repository by default.</p>
<p>Declare additional repositories with the form:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">resolvers</span> <span class="o">+=</span> <span class="n">name</span> <span class="n">at</span> <span class="n">location</span>
</pre></div>
</div>
<p>For example:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">libraryDependencies</span> <span class="o">++=</span> <span class="nc">Seq</span><span class="o">(</span>
<span class="s">"org.apache.derby"</span> <span class="o">%</span> <span class="s">"derby"</span> <span class="o">%</span> <span class="s">"10.4.1.3"</span><span class="o">,</span>
<span class="s">"org.specs"</span> <span class="o">%</span> <span class="s">"specs"</span> <span class="o">%</span> <span class="s">"1.6.1"</span>
<span class="o">)</span>
<span class="n">resolvers</span> <span class="o">+=</span> <span class="s">"Sonatype OSS Snapshots"</span> <span class="n">at</span> <span class="s">"https://oss.sonatype.org/content/repositories/snapshots"</span>
</pre></div>
</div>
<p>sbt can search your local Maven repository if you add it as a
repository:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">resolvers</span> <span class="o">+=</span> <span class="s">"Local Maven Repository"</span> <span class="n">at</span> <span class="s">"file://"</span><span class="o">+</span><span class="nc">Path</span><span class="o">.</span><span class="n">userHome</span><span class="o">.</span><span class="n">absolutePath</span><span class="o">+</span><span class="s">"/.m2/repository"</span>
</pre></div>
</div>
<p>See <a class="reference internal" href="Resolvers.html"><em>Resolvers</em></a> for details on defining other types of repositories.</p>
</div>
<div class="section" id="override-default-resolvers">
<h4>Override default resolvers<a class="headerlink" href="#override-default-resolvers" title="Permalink to this headline">¶</a></h4>
<p><tt class="docutils literal"><span class="pre">resolvers</span></tt> configures additional, inline user resolvers. By default,
<tt class="docutils literal"><span class="pre">sbt</span></tt> combines these resolvers with default repositories (Maven
Central and the local Ivy repository) to form <tt class="docutils literal"><span class="pre">external-resolvers</span></tt>. To
have more control over repositories, set <tt class="docutils literal"><span class="pre">external-resolvers</span></tt>
directly. To only specify repositories in addition to the usual
defaults, configure <tt class="docutils literal"><span class="pre">resolvers</span></tt>.</p>
<p>For example, to use the Sonatype OSS Snapshots repository in addition to
the default repositories,</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">resolvers</span> <span class="o">+=</span> <span class="s">"Sonatype OSS Snapshots"</span> <span class="n">at</span> <span class="s">"https://oss.sonatype.org/content/repositories/snapshots"</span>
</pre></div>
</div>
<p>To use the local repository, but not the Maven Central repository:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">externalResolvers</span> <span class="o"><<=</span> <span class="n">resolvers</span> <span class="n">map</span> <span class="o">{</span> <span class="n">rs</span> <span class="k">=></span>
<span class="nc">Resolver</span><span class="o">.</span><span class="n">withDefaultResolvers</span><span class="o">(</span><span class="n">rs</span><span class="o">,</span> <span class="n">mavenCentral</span> <span class="k">=</span> <span class="kc">false</span><span class="o">)</span>
<span class="o">}</span>
</pre></div>
</div>
</div>
<div class="section" id="override-all-resolvers-for-all-builds">
<h4>Override all resolvers for all builds<a class="headerlink" href="#override-all-resolvers-for-all-builds" title="Permalink to this headline">¶</a></h4>
<p>The repositories used to retrieve sbt, Scala, plugins, and application
dependencies can be configured globally and declared to override the
resolvers configured in a build or plugin definition. There are two
parts:</p>
<ol class="arabic simple">
<li>Define the repositories used by the launcher.</li>
<li>Specify that these repositories should override those in build
definitions.</li>
</ol>
<p>The repositories used by the launcher can be overridden by defining
<tt class="docutils literal"><span class="pre">~/.sbt/repositories</span></tt>, which must contain a <tt class="docutils literal"><span class="pre">[repositories]</span></tt> section
with the same format as the <a class="reference internal" href="Launcher.html"><em>Launcher Specification</em></a> configuration file. For
example:</p>
<div class="highlight-ini"><pre>[repositories]
local
my-maven-repo: http://example.org/repo
my-ivy-repo: http://example.org/ivy-repo/, [organization]/[module]/[revision]/[type]s/[artifact](-[classifier]).[ext]</pre>
</div>
<p>A different location for the repositories file may be specified by the
<tt class="docutils literal"><span class="pre">sbt.repository.config</span></tt> system property in the sbt startup script. The
final step is to set <tt class="docutils literal"><span class="pre">sbt.override.build.repos</span></tt> to true to use these
repositories for dependency resolution and retrieval.</p>
</div>
<div class="section" id="explicit-url">
<h4>Explicit URL<a class="headerlink" href="#explicit-url" title="Permalink to this headline">¶</a></h4>
<p>If your project requires a dependency that is not present in a
repository, a direct URL to its jar can be specified as follows:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">libraryDependencies</span> <span class="o">+=</span> <span class="s">"slinky"</span> <span class="o">%</span> <span class="s">"slinky"</span> <span class="o">%</span> <span class="s">"2.1"</span> <span class="n">from</span> <span class="s">"http://slinky2.googlecode.com/svn/artifacts/2.1/slinky.jar"</span>
</pre></div>
</div>
<p>The URL is only used as a fallback if the dependency cannot be found
through the configured repositories. Also, the explicit URL is not
included in published metadata (that is, the pom or ivy.xml).</p>
</div>
<div class="section" id="disable-transitivity">
<h4>Disable Transitivity<a class="headerlink" href="#disable-transitivity" title="Permalink to this headline">¶</a></h4>
<p>By default, these declarations fetch all project dependencies,
transitively. In some instances, you may find that the dependencies
listed for a project aren't necessary for it to build. Projects using
the Felix OSGI framework, for instance, only explicitly require its main
jar to compile and run. Avoid fetching artifact dependencies with either
<tt class="docutils literal"><span class="pre">intransitive()</span></tt> or <tt class="docutils literal"><span class="pre">notTransitive()</span></tt>, as in this example:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">libraryDependencies</span> <span class="o">+=</span> <span class="s">"org.apache.felix"</span> <span class="o">%</span> <span class="s">"org.apache.felix.framework"</span> <span class="o">%</span> <span class="s">"1.8.0"</span> <span class="n">intransitive</span><span class="o">()</span>
</pre></div>
</div>
</div>
<div class="section" id="classifiers">
<h4>Classifiers<a class="headerlink" href="#classifiers" title="Permalink to this headline">¶</a></h4>
<p>You can specify the classifier for a dependency using the <tt class="docutils literal"><span class="pre">classifier</span></tt>
method. For example, to get the jdk15 version of TestNG:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">libraryDependencies</span> <span class="o">+=</span> <span class="s">"org.testng"</span> <span class="o">%</span> <span class="s">"testng"</span> <span class="o">%</span> <span class="s">"5.7"</span> <span class="n">classifier</span> <span class="s">"jdk15"</span>
</pre></div>
</div>
<p>For multiple classifiers, use multiple <tt class="docutils literal"><span class="pre">classifier</span></tt> calls:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">libraryDependencies</span> <span class="o">+=</span>
<span class="s">"org.lwjgl.lwjgl"</span> <span class="o">%</span> <span class="s">"lwjgl-platform"</span> <span class="o">%</span> <span class="n">lwjglVersion</span> <span class="n">classifier</span> <span class="s">"natives-windows"</span> <span class="n">classifier</span> <span class="s">"natives-linux"</span> <span class="n">classifier</span> <span class="s">"natives-osx"</span>
</pre></div>
</div>
<p>To obtain particular classifiers for all dependencies transitively, run
the <tt class="docutils literal"><span class="pre">update-classifiers</span></tt> task. By default, this resolves all artifacts
with the <tt class="docutils literal"><span class="pre">sources</span></tt> or <tt class="docutils literal"><span class="pre">javadoc</span></tt> classifier. Select the classifiers
to obtain by configuring the <tt class="docutils literal"><span class="pre">transitive-classifiers</span></tt> setting. For
example, to only retrieve sources:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">transitiveClassifiers</span> <span class="o">:=</span> <span class="nc">Seq</span><span class="o">(</span><span class="s">"sources"</span><span class="o">)</span>
</pre></div>
</div>
</div>
<div class="section" id="exclude-transitive-dependencies">
<h4>Exclude Transitive Dependencies<a class="headerlink" href="#exclude-transitive-dependencies" title="Permalink to this headline">¶</a></h4>
<p>To exclude certain transitive dependencies of a dependency, use the
<tt class="docutils literal"><span class="pre">excludeAll</span></tt> or <tt class="docutils literal"><span class="pre">exclude</span></tt> methods. The <tt class="docutils literal"><span class="pre">exclude</span></tt> method should be
used when a pom will be published for the project. It requires the
organization and module name to exclude. For example,</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">libraryDependencies</span> <span class="o">+=</span>
<span class="s">"log4j"</span> <span class="o">%</span> <span class="s">"log4j"</span> <span class="o">%</span> <span class="s">"1.2.15"</span> <span class="n">exclude</span><span class="o">(</span><span class="s">"javax.jms"</span><span class="o">,</span> <span class="s">"jms"</span><span class="o">)</span>
</pre></div>
</div>
<p>The <tt class="docutils literal"><span class="pre">excludeAll</span></tt> method is more flexible, but because it cannot be
represented in a pom.xml, it should only be used when a pom doesn't need
to be generated. For example,</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">libraryDependencies</span> <span class="o">+=</span>
<span class="s">"log4j"</span> <span class="o">%</span> <span class="s">"log4j"</span> <span class="o">%</span> <span class="s">"1.2.15"</span> <span class="n">excludeAll</span><span class="o">(</span>
<span class="nc">ExclusionRule</span><span class="o">(</span><span class="n">organization</span> <span class="k">=</span> <span class="s">"com.sun.jdmk"</span><span class="o">),</span>
<span class="nc">ExclusionRule</span><span class="o">(</span><span class="n">organization</span> <span class="k">=</span> <span class="s">"com.sun.jmx"</span><span class="o">),</span>
<span class="nc">ExclusionRule</span><span class="o">(</span><span class="n">organization</span> <span class="k">=</span> <span class="s">"javax.jms"</span><span class="o">)</span>
<span class="o">)</span>
</pre></div>
</div>
<p>See
<a class="reference external" href="../../api/sbt/ModuleID.html">ModuleID</a>
for API details.</p>
</div>
<div class="section" id="download-sources">
<h4>Download Sources<a class="headerlink" href="#download-sources" title="Permalink to this headline">¶</a></h4>
<p>Downloading source and API documentation jars is usually handled by an
IDE plugin. These plugins use the <tt class="docutils literal"><span class="pre">update-classifiers</span></tt> and
<tt class="docutils literal"><span class="pre">update-sbt-classifiers</span></tt> tasks, which produce an <a class="reference internal" href="Update-Report.html"><em>Update Report</em></a>
referencing these jars.</p>
<p>To have sbt download the dependency's sources without using an IDE
plugin, add <tt class="docutils literal"><span class="pre">withSources()</span></tt> to the dependency definition. For API
jars, add <tt class="docutils literal"><span class="pre">withJavadoc()</span></tt>. For example:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">libraryDependencies</span> <span class="o">+=</span>
<span class="s">"org.apache.felix"</span> <span class="o">%</span> <span class="s">"org.apache.felix.framework"</span> <span class="o">%</span> <span class="s">"1.8.0"</span> <span class="n">withSources</span><span class="o">()</span> <span class="n">withJavadoc</span><span class="o">()</span>
</pre></div>
</div>
<p>Note that this is not transitive. Use the <tt class="docutils literal"><span class="pre">update-*classifiers</span></tt> tasks
for that.</p>
</div>
<div class="section" id="extra-attributes">
<h4>Extra Attributes<a class="headerlink" href="#extra-attributes" title="Permalink to this headline">¶</a></h4>
<p><a class="reference external" href="http://ant.apache.org/ivy/history/2.2.0/concept.html#extra">Extra
attributes</a>
can be specified by passing key/value pairs to the <tt class="docutils literal"><span class="pre">extra</span></tt> method.</p>
<p>To select dependencies by extra attributes:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">libraryDependencies</span> <span class="o">+=</span> <span class="s">"org"</span> <span class="o">%</span> <span class="s">"name"</span> <span class="o">%</span> <span class="s">"rev"</span> <span class="n">extra</span><span class="o">(</span><span class="s">"color"</span> <span class="o">-></span> <span class="s">"blue"</span><span class="o">)</span>
</pre></div>
</div>
<p>To define extra attributes on the current project:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">projectID</span> <span class="o"><<=</span> <span class="n">projectID</span> <span class="o">{</span> <span class="n">id</span> <span class="k">=></span>
<span class="n">id</span> <span class="n">extra</span><span class="o">(</span><span class="s">"color"</span> <span class="o">-></span> <span class="s">"blue"</span><span class="o">,</span> <span class="s">"component"</span> <span class="o">-></span> <span class="s">"compiler-interface"</span><span class="o">)</span>
<span class="o">}</span>
</pre></div>
</div>
</div>
<div class="section" id="inline-ivy-xml">
<h4>Inline Ivy XML<a class="headerlink" href="#inline-ivy-xml" title="Permalink to this headline">¶</a></h4>
<p>sbt additionally supports directly specifying the configurations or
dependencies sections of an Ivy configuration file inline. You can mix
this with inline Scala dependency and repository declarations.</p>
<p>For example:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">ivyXML</span> <span class="o">:=</span>
<span class="o"><</span><span class="n">dependencies</span><span class="o">></span>
<span class="o"><</span><span class="n">dependency</span> <span class="n">org</span><span class="o">=</span><span class="s">"javax.mail"</span> <span class="n">name</span><span class="o">=</span><span class="s">"mail"</span> <span class="n">rev</span><span class="o">=</span><span class="s">"1.4.2"</span><span class="o">></span>
<span class="o"><</span><span class="n">exclude</span> <span class="n">module</span><span class="o">=</span><span class="s">"activation"</span><span class="o">/></span>
<span class="o"></</span><span class="n">dependency</span><span class="o">></span>
<span class="o"></</span><span class="n">dependencies</span><span class="o">></span>
</pre></div>
</div>
</div>
<div class="section" id="ivy-home-directory">
<h4>Ivy Home Directory<a class="headerlink" href="#ivy-home-directory" title="Permalink to this headline">¶</a></h4>
<p>By default, sbt uses the standard Ivy home directory location
<tt class="docutils literal"><span class="pre">${user.home}/.ivy2/</span></tt>. This can be configured machine-wide, for use by
both the sbt launcher and by projects, by setting the system property
<tt class="docutils literal"><span class="pre">sbt.ivy.home</span></tt> in the sbt startup script (described in
<a class="reference internal" href="../Getting-Started/Setup.html"><em>Setup</em></a>).</p>
<p>For example:</p>
<div class="highlight-text"><div class="highlight"><pre>java -Dsbt.ivy.home=/tmp/.ivy2/ ...
</pre></div>
</div>
</div>
<div class="section" id="checksums">
<h4>Checksums<a class="headerlink" href="#checksums" title="Permalink to this headline">¶</a></h4>
<p>sbt (<a class="reference external" href="http://ant.apache.org/ivy/history/latest-milestone/concept.html#checksum">through
Ivy</a>)
verifies the checksums of downloaded files by default. It also publishes
checksums of artifacts by default. The checksums to use are specified by
the <em>checksums</em> setting.</p>
<p>To disable checksum checking during update:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">checksums</span> <span class="n">in</span> <span class="n">update</span> <span class="o">:=</span> <span class="nc">Nil</span>
</pre></div>
</div>
<p>To disable checksum creation during artifact publishing:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">checksums</span> <span class="n">in</span> <span class="n">publishLocal</span> <span class="o">:=</span> <span class="nc">Nil</span>
<span class="n">checksums</span> <span class="n">in</span> <span class="n">publish</span> <span class="o">:=</span> <span class="nc">Nil</span>
</pre></div>
</div>
<p>The default value is:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">checksums</span> <span class="o">:=</span> <span class="nc">Seq</span><span class="o">(</span><span class="s">"sha1"</span><span class="o">,</span> <span class="s">"md5"</span><span class="o">)</span>
</pre></div>
</div>
</div>
<div class="section" id="publishing">
<h4>Publishing<a class="headerlink" href="#publishing" title="Permalink to this headline">¶</a></h4>
<p>Finally, see <a class="reference internal" href="Publishing.html"><em>Publishing</em></a> for how to publish your project.</p>
</div>
</div>
<div class="section" id="maven-ivy">
<span id="external-maven-ivy"></span><h3>Maven/Ivy<a class="headerlink" href="#maven-ivy" title="Permalink to this headline">¶</a></h3>
<p>For this method, create the configuration files as you would for Maven
(<tt class="docutils literal"><span class="pre">pom.xml</span></tt>) or Ivy (<tt class="docutils literal"><span class="pre">ivy.xml</span></tt> and optionally <tt class="docutils literal"><span class="pre">ivysettings.xml</span></tt>).
External configuration is selected by using one of the following
expressions.</p>
<div class="section" id="ivy-settings-resolver-configuration">
<h4>Ivy settings (resolver configuration)<a class="headerlink" href="#ivy-settings-resolver-configuration" title="Permalink to this headline">¶</a></h4>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">externalIvySettings</span><span class="o">()</span>
</pre></div>
</div>
<p>or</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">externalIvySettings</span><span class="o">(</span><span class="n">baseDirectory</span><span class="o">(</span><span class="k">_</span> <span class="o">/</span> <span class="s">"custom-settings-name.xml"</span><span class="o">))</span>
</pre></div>
</div>
<p>or</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">externalIvySettingsURL</span><span class="o">(</span><span class="n">url</span><span class="o">(</span><span class="s">"your_url_here"</span><span class="o">))</span>
</pre></div>
</div>
</div>
<div class="section" id="ivy-file-dependency-configuration">
<h4>Ivy file (dependency configuration)<a class="headerlink" href="#ivy-file-dependency-configuration" title="Permalink to this headline">¶</a></h4>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">externalIvyFile</span><span class="o">()</span>
</pre></div>
</div>
<p>or</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">externalIvyFile</span><span class="o">(</span><span class="n">baseDirectory</span><span class="o">(</span><span class="k">_</span> <span class="o">/</span> <span class="s">"custom-name.xml"</span><span class="o">))</span>
</pre></div>
</div>
<p>Because Ivy files specify their own configurations, sbt needs to know
which configurations to use for the compile, runtime, and test
classpaths. For example, to specify that the Compile classpath should
use the 'default' configuration:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">classpathConfiguration</span> <span class="n">in</span> <span class="nc">Compile</span> <span class="o">:=</span> <span class="n">config</span><span class="o">(</span><span class="s">"default"</span><span class="o">)</span>
</pre></div>
</div>
</div>
<div class="section" id="maven-pom-dependencies-only">
<h4>Maven pom (dependencies only)<a class="headerlink" href="#maven-pom-dependencies-only" title="Permalink to this headline">¶</a></h4>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">externalPom</span><span class="o">()</span>
</pre></div>
</div>
<p>or</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">externalPom</span><span class="o">(</span><span class="n">baseDirectory</span><span class="o">(</span><span class="k">_</span> <span class="o">/</span> <span class="s">"custom-name.xml"</span><span class="o">))</span>
</pre></div>
</div>
</div>
<div class="section" id="full-ivy-example">
<h4>Full Ivy Example<a class="headerlink" href="#full-ivy-example" title="Permalink to this headline">¶</a></h4>
<p>For example, a <tt class="docutils literal"><span class="pre">build.sbt</span></tt> using external Ivy files might look like:</p>
<div class="highlight-scala"><div class="highlight"><pre><span class="n">externalIvySettings</span><span class="o">()</span>
<span class="n">externalIvyFile</span><span class="o">(</span> <span class="n">baseDirectory</span> <span class="o">{</span> <span class="n">base</span> <span class="k">=></span> <span class="n">base</span> <span class="o">/</span> <span class="s">"ivyA.xml"</span><span class="o">}</span> <span class="o">)</span>
<span class="n">classpathConfiguration</span> <span class="n">in</span> <span class="nc">Compile</span> <span class="o">:=</span> <span class="nc">Compile</span>
<span class="n">classpathConfiguration</span> <span class="n">in</span> <span class="nc">Test</span> <span class="o">:=</span> <span class="nc">Test</span>
<span class="n">classpathConfiguration</span> <span class="n">in</span> <span class="nc">Runtime</span> <span class="o">:=</span> <span class="nc">Runtime</span>
</pre></div>
</div>
</div>
<div class="section" id="known-limitations">
<h4>Known limitations<a class="headerlink" href="#known-limitations" title="Permalink to this headline">¶</a></h4>
<p>Maven support is dependent on Ivy's support for Maven POMs. Known issues
with this support:</p>
<ul class="simple">
<li>Specifying <tt class="docutils literal"><span class="pre">relativePath</span></tt> in the <tt class="docutils literal"><span class="pre">parent</span></tt> section of a POM will
produce an error.</li>
<li>Ivy ignores repositories specified in the POM. A workaround is to
specify repositories inline or in an Ivy <tt class="docutils literal"><span class="pre">ivysettings.xml</span></tt> file.</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="span3"><p class="contents-title">Contents</p>
<div id="scroller-anchor">
<div id="scroller">
<div id="toc"><ul>
<li><a class="reference internal" href="#">Library Management</a><ul>
<li><a class="reference internal" href="#introduction">Introduction</a></li>
<li><a class="reference internal" href="#manual-dependency-management">Manual Dependency Management</a></li>
<li><a class="reference internal" href="#automatic-dependency-management">Automatic Dependency Management</a><ul>
<li><a class="reference internal" href="#inline-declarations">Inline Declarations</a><ul>
<li><a class="reference internal" href="#dependencies">Dependencies</a></li>
<li><a class="reference internal" href="#resolvers">Resolvers</a></li>
<li><a class="reference internal" href="#override-default-resolvers">Override default resolvers</a></li>
<li><a class="reference internal" href="#override-all-resolvers-for-all-builds">Override all resolvers for all builds</a></li>
<li><a class="reference internal" href="#explicit-url">Explicit URL</a></li>
<li><a class="reference internal" href="#disable-transitivity">Disable Transitivity</a></li>
<li><a class="reference internal" href="#classifiers">Classifiers</a></li>
<li><a class="reference internal" href="#exclude-transitive-dependencies">Exclude Transitive Dependencies</a></li>
<li><a class="reference internal" href="#download-sources">Download Sources</a></li>
<li><a class="reference internal" href="#extra-attributes">Extra Attributes</a></li>
<li><a class="reference internal" href="#inline-ivy-xml">Inline Ivy XML</a></li>
<li><a class="reference internal" href="#ivy-home-directory">Ivy Home Directory</a></li>
<li><a class="reference internal" href="#checksums">Checksums</a></li>
<li><a class="reference internal" href="#publishing">Publishing</a></li>
</ul>
</li>
<li><a class="reference internal" href="#maven-ivy">Maven/Ivy</a><ul>
<li><a class="reference internal" href="#ivy-settings-resolver-configuration">Ivy settings (resolver configuration)</a></li>
<li><a class="reference internal" href="#ivy-file-dependency-configuration">Ivy file (dependency configuration)</a></li>
<li><a class="reference internal" href="#maven-pom-dependencies-only">Maven pom (dependencies only)</a></li>
<li><a class="reference internal" href="#full-ivy-example">Full Ivy Example</a></li>
<li><a class="reference internal" href="#known-limitations">Known limitations</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div></div>
</div>
</div>
</div>
</div>
</body>
</html>