forked from bndtools/bnd
/
140-best-practices.html
383 lines (141 loc) · 10.1 KB
/
140-best-practices.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
<!DOCTYPE html>
<html lang="en" ng-app="jpm">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="/releases/6.3.0/css/style.css" rel="stylesheet" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="/js/releases.js"></script>
<!-- Begin Jekyll SEO tag v2.8.0 -->
<title>Best practices | bnd</title>
<meta name="generator" content="Jekyll v3.9.2" />
<meta property="og:title" content="Best practices" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="Workspaces" />
<meta property="og:description" content="Workspaces" />
<meta property="og:site_name" content="bnd" />
<meta property="og:type" content="website" />
<meta name="twitter:card" content="summary" />
<meta property="twitter:title" content="Best practices" />
<script type="application/ld+json">
{"@context":"https://schema.org","@type":"WebPage","description":"Workspaces","headline":"Best practices","url":"/releases/6.3.0/chapters/140-best-practices.html"}</script>
<!-- End Jekyll SEO tag -->
<style>
body {
counter-reset: h1 6;
}
</style>
</head>
<body>
<ul class="container12 menu-bar" style="display:flex;align-items:center">
<li span=8><a class=menu-link href="/releases/6.3.0/"><img
class=menu-logo src="/releases/6.3.0/img/bnd-80x40-white.png"></a>
<a href="/releases/6.3.0/chapters/110-introduction.html">Intro
</a><a href="/releases/6.3.0/chapters/800-headers.html">Headers
</a><a href="/releases/6.3.0/chapters/825-instructions-ref.html">Instructions
</a><a href="/releases/6.3.0/chapters/855-macros-ref.html">Macros
</a><a href="/releases/6.3.0/chapters/400-commands.html">Commands
</a><div class="releases">
<button class="dropbtn"><span class="fa fa-bars"></span> 6.3.0</button>
<div class="dropdown-content"></div>
</div>
<li span=4>
<div class="search-container">
<form method="get" id="search" action="https://google.com/search" target="_blank">
<input type="hidden" name="as_q" value="site:bndtools.org OR site:bnd.discourse.group"/>
<input type="text" name="q" placeholder="Search…" aria-label="Search https://google.com for bnd specific"/>
<button type="submit" class="fa fa-search"></button>
</form>
</div>
</ul>
<div class=menu-link span=0><a href="https://github.com/bndtools/bnd" target="_"><img
style="position:absolute;top:0;right:0;margin:0;padding:0;z-index:100"
src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67"
alt="Fork me on GitHub"
data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a></div>
<ul class=container12>
<li span=3>
<div>
<ul class="side-nav">
<li><a href="/releases/6.3.0/chapters/110-introduction.html">Introduction</a>
<li><a href="/releases/6.3.0/chapters/120-install.html">How to install bnd</a>
<li><a href="/releases/6.3.0/chapters/123-tour-workspace.html">Guided Tour</a>
<li><a href="/releases/6.3.0/chapters/125-tour-features.html">Guided Tour Workspace & Projects</a>
<li><a href="/releases/6.3.0/chapters/130-concepts.html">Concepts</a>
<li class=selected>Best practices
<li><a href="/releases/6.3.0/chapters/150-build.html">Build</a>
<li><a href="/releases/6.3.0/chapters/155-project-setup.html">Project Setup</a>
<li><a href="/releases/6.3.0/chapters/160-jars.html">Generating JARs</a>
<li><a href="/releases/6.3.0/chapters/170-versioning.html">Versioning</a>
<li><a href="/releases/6.3.0/chapters/180-baselining.html">Baselining</a>
<li><a href="/releases/6.3.0/chapters/200-components.html">Service Components</a>
<li><a href="/releases/6.3.0/chapters/210-metatype.html">Metatype</a>
<li><a href="/releases/6.3.0/chapters/220-contracts.html">Contracts</a>
<li><a href="/releases/6.3.0/chapters/230-manifest-annotations.html">Bundle Annotations</a>
<li><a href="/releases/6.3.0/chapters/235-accessor-properties.html">Accessor Properties</a>
<li><a href="/releases/6.3.0/chapters/240-spi-annotations.html">SPI Annotations</a>
<li><a href="/releases/6.3.0/chapters/250-resolving.html">Resolving Dependencies</a>
<li><a href="/releases/6.3.0/chapters/300-launching.html">Launching</a>
<li><a href="/releases/6.3.0/chapters/305-startlevels.html">Startlevels</a>
<li><a href="/releases/6.3.0/chapters/310-testing.html">Testing</a>
<li><a href="/releases/6.3.0/chapters/315-launchpad-testing.html">Testing with Launchpad</a>
<li><a href="/releases/6.3.0/chapters/320-packaging.html">Packaging Applications</a>
<li><a href="/releases/6.3.0/chapters/330-jpms.html">JPMS Libraries</a>
<li><a href="/releases/6.3.0/chapters/390-wrapping.html">Wrapping Libraries to OSGi Bundles</a>
<li><a href="/releases/6.3.0/chapters/395-generating-documentation.html">Generating Documentation</a>
<li><a href="/releases/6.3.0/chapters/400-commands.html">Commands</a>
<li><a href="/releases/6.3.0/chapters/600-developer.html">For Developers</a>
<li><a href="/releases/6.3.0/chapters/650-windows.html">Tips for Windows users</a>
<li><a href="/releases/6.3.0/chapters/700-tools.html">Tools bound to bnd</a>
<li><a href="/releases/6.3.0/chapters/790-reference.html">Reference</a>
<li><a href="/releases/6.3.0/chapters/800-headers.html">Headers</a>
<li><a href="/releases/6.3.0/chapters/820-instructions.html">Instruction Reference</a>
<li><a href="/releases/6.3.0/chapters/825-instructions-ref.html">Instruction Index</a>
<li><a href="/releases/6.3.0/chapters/850-macros.html">Macro Reference</a>
<li><a href="/releases/6.3.0/chapters/855-macros-ref.html">Macro Index</a>
<li><a href="/releases/6.3.0/chapters/870-plugins.html">Plugins</a>
<li><a href="/releases/6.3.0/chapters/875-external-plugins.html">External Plugins</a>
<li><a href="/releases/6.3.0/chapters/880-settings.html">Settings</a>
<li><a href="/releases/6.3.0/chapters/900-errors.html">Errors</a>
<li><a href="/releases/6.3.0/chapters/910-warnings.html">Warnings</a>
<li><a href="/releases/6.3.0/chapters/920-faq.html">Frequently Asked Questions</a>
</ul>
</div>
<li span=9>
<div class=notes-margin>
<h1> Best practices
</h1>
<h2 id="workspaces">Workspaces</h2>
<p>The idea of a workspace is that it is cohesive. It contains a set of shared bundles and some of those bundles are exported to a repository. Other bundles are imported from repositories. This is the basic model of modularity.</p>
<p>This strongly implies that you should NOT share cnf between workspace, just like you should not share private fields from classes nor private classes from packages. So the idea is that your organizations has a number of workspaces that contain the code that has a strong relation. For example a product, your company service APIs, or shared base libraries. Since all these projects are in one workspace you get a lot of ease of use like refactoring and immediate feedback.</p>
<p>That said, there is often a desire to have some of the information, like the repositories in a shared place because you do not want to maintain it multiple times. Since bnd is completely based on inherited properties this is not that hard. The top of the properties are coming from the cnf/build.bnd file. Since this is a bnd file, you can actually include another bnd file there. Since this can be included via a URL, you can refer it to a file on your git repository. For convenience, you could make it refer to master but a better way is to make it refer to an actual commit. The reason is that if you checkout your project 5 years from now, it is unlikely that your build will be ok with the latest version of the included bnd file.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>build.bnd:
-include: https://examplegit.com/foo/bar/master/shared/shared.bnd
</code></pre></div></div>
<p>A more defined way to handle this long term versioning problem is to use git modules. They have a bad name but as far as I understand their bad name is because people don’t like that they are not automatically updated, which is exactly what you want when you want to build your project 5 years from now. Git modules require an explicit command to upgrade it to the latest or another version. The parent git repository stores the commit at which it is linked. With git modules you could make a subdirectory in cnf and then include a shared file from there:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>cnf
shared/
.git/
shared.bnd
build.bnd
build.bnd:
-include shared/shared.bnd
</code></pre></div></div>
<p>So to summarize, share workspaces, not projects. Use continuous integration that publishes your bundles to a repository that is shared with all. Share one bnd file with a git module.</p>
</div>
</ul>
<nav class=next-prev>
<a href='/releases/6.3.0/chapters/130-concepts.html'></a> <a href='/releases/6.3.0/chapters/150-build.html'></a>
</nav>
<footer class="container12" style="border-top: 1px solid black;padding:10px 0">
<ul span=12 row>
<li span=12>
<ul>
<li><a href="/releases/6.3.0/">GitHub</a>
</ul>
</ul>
</footer>
</body>
</html>