-
Notifications
You must be signed in to change notification settings - Fork 0
/
philosophy.html
798 lines (621 loc) · 35.1 KB
/
philosophy.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
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
<!DOCTYPE html>
<!--
| Generated by Apache Maven Doxia at 2016-04-26
| Rendered using Apache Maven Fluido Skin 1.3.1
-->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="Date-Revision-yyyymmdd" content="20160426" />
<meta http-equiv="Content-Language" content="en" />
<title>nar-maven-plugin - NAR Plugin</title>
<link rel="stylesheet" href="./css/apache-maven-fluido-1.3.1.min.css" />
<link rel="stylesheet" href="./css/site.css" />
<link rel="stylesheet" href="./css/print.css" media="print" />
<script type="text/javascript" src="./js/apache-maven-fluido-1.3.1.min.js"></script>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
<script type="text/javascript">_uacct = "UA-140879-1";
urchinTracker();</script>
</head>
<body class="topBarEnabled">
<a href="http://github.com/maven-nar/nar-maven-plugin">
<img style="position: absolute; top: 0; right: 0; border: 0; z-index: 10000;"
src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png"
alt="Fork me on GitHub">
</a>
<div id="topbar" class="navbar navbar-fixed-top ">
<div class="navbar-inner">
<div class="container-fluid">
<a data-target=".nav-collapse" data-toggle="collapse" class="btn btn-navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="index.html" title="NAR plugin for Maven">
<img src="images/nar-banner.png" alt="NAR plugin for Maven" />
</a>
<ul class="nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Overview <b class="caret"></b></a>
<ul class="dropdown-menu">
<li> <a href="index.html" title="Introduction">Introduction</a>
</li>
<li> <a href="philosophy.html" title="Philosophy">Philosophy</a>
</li>
<li> <a href="NARPlugin.ppt" title="Presentation (ppt)">Presentation (ppt)</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">User Info <b class="caret"></b></a>
<ul class="dropdown-menu">
<li> <a href="plugin-info.html" title="Goals">Goals</a>
</li>
<li> <a href="usage.html" title="Usage">Usage</a>
</li>
<li> <a href="lifecycle.html" title="Lifecycle">Lifecycle</a>
</li>
<li> <a href="configuration.html" title="Configuration">Configuration</a>
</li>
<li> <a href="https://github.com/maven-nar/nar-maven-plugin/wiki/Frequently_Asked_Questions" title="FAQ">FAQ</a>
</li>
<li> <a href="aol.html" title="AOL Properties">AOL Properties</a>
</li>
<li> <a href="examples.html" title="Examples">Examples</a>
</li>
<li> <a href="archetypes.html" title="Archetypes">Archetypes</a>
</li>
<li> <a href="properties.html" title="Properties">Properties</a>
</li>
<li> <a href="compatibility.html" title="Compatibility">Compatibility</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Developer Info <b class="caret"></b></a>
<ul class="dropdown-menu">
<li> <a href="narDependencies.html" title="NAR Dependencies">NAR Dependencies</a>
</li>
<li> <a href="https://github.com/maven-nar/nar-maven-plugin/issues" title="Bug Reports">Bug Reports</a>
</li>
<li> <a href="https://groups.google.com/forum/?fromgroups#!forum/maven-nar" title="Forum">Forum</a>
</li>
<li> <a href="apidocs/index.html" title="APIDocs">APIDocs</a>
</li>
<li> <a href="narLibrary.html" title="NAR Library">NAR Library</a>
</li>
<li> <a href="cpptasks.html" title="CPPTasks">CPPTasks</a>
</li>
<li> <a href="https://github.com/maven-nar/nar-maven-plugin" title="Git Browse nar-plugin">Git Browse nar-plugin</a>
</li>
<li> <a href="source-repository.html" title="Git Repository">Git Repository</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Project Documentation <b class="caret"></b></a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<a href="project-info.html" title="Project Information">Project Information</a>
<ul class="dropdown-menu">
<li> <a href="index.html" title="About">About</a>
</li>
<li> <a href="project-summary.html" title="Project Summary">Project Summary</a>
</li>
<li> <a href="dependency-info.html" title="Dependency Information">Dependency Information</a>
</li>
<li> <a href="license.html" title="Project License">Project License</a>
</li>
<li> <a href="team-list.html" title="Project Team">Project Team</a>
</li>
<li> <a href="source-repository.html" title="Source Repository">Source Repository</a>
</li>
<li> <a href="issue-tracking.html" title="Issue Tracking">Issue Tracking</a>
</li>
<li> <a href="mail-lists.html" title="Mailing Lists">Mailing Lists</a>
</li>
<li> <a href="dependency-management.html" title="Dependency Management">Dependency Management</a>
</li>
<li> <a href="dependencies.html" title="Dependencies">Dependencies</a>
</li>
<li> <a href="integration.html" title="Continuous Integration">Continuous Integration</a>
</li>
<li> <a href="plugin-management.html" title="Plugin Management">Plugin Management</a>
</li>
<li> <a href="plugins.html" title="Project Plugins">Project Plugins</a>
</li>
<li> <a href="distribution-management.html" title="Distribution Management">Distribution Management</a>
</li>
</ul>
</li>
<li class="dropdown-submenu">
<a href="project-reports.html" title="Project Reports">Project Reports</a>
<ul class="dropdown-menu">
<li> <a href="plugin-info.html" title="Plugin Documentation">Plugin Documentation</a>
</li>
<li> <a href="testapidocs/index.html" title="Test JavaDocs">Test JavaDocs</a>
</li>
<li> <a href="apidocs/index.html" title="JavaDocs">JavaDocs</a>
</li>
<li> <a href="xref-test/index.html" title="Test Source Xref">Test Source Xref</a>
</li>
<li> <a href="xref/index.html" title="Source Xref">Source Xref</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Maven Projects <b class="caret"></b></a>
<ul class="dropdown-menu">
<li> <a href="http://maven.apache.org/ant-tasks/index.html" title="Ant Tasks">Ant Tasks</a>
</li>
<li> <a href="http://maven.apache.org/archetype/index.html" title="Archetype">Archetype</a>
</li>
<li> <a href="http://maven.apache.org/doxia/index.html" title="Doxia">Doxia</a>
</li>
<li> <a href="http://maven.apache.org/jxr/index.html" title="JXR">JXR</a>
</li>
<li> <a href="http://maven.apache.org/maven-1.x/index.html" title="Maven 1.x">Maven 1.x</a>
</li>
<li> <a href="http://maven.apache.org/index.html" title="Maven 2 & 3">Maven 2 & 3</a>
</li>
<li> <a href="http://maven.apache.org/pom/index.html" title="Parent POMs">Parent POMs</a>
</li>
<li> <a href="http://maven.apache.org/plugins/index.html" title="Plugins">Plugins</a>
</li>
<li> <a href="http://maven.apache.org/plugin-tools/index.html" title="Plugin Tools">Plugin Tools</a>
</li>
<li> <a href="http://maven.apache.org/scm/index.html" title="SCM">SCM</a>
</li>
<li> <a href="http://maven.apache.org/shared/index.html" title="Shared Components">Shared Components</a>
</li>
<li> <a href="http://maven.apache.org/skins/index.html" title="Skins">Skins</a>
</li>
<li> <a href="http://maven.apache.org/surefire/index.html" title="Surefire">Surefire</a>
</li>
<li> <a href="http://maven.apache.org/wagon/index.html" title="Wagon">Wagon</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">ASF <b class="caret"></b></a>
<ul class="dropdown-menu">
<li> <a href="http://www.apache.org/foundation/how-it-works.html" title="How Apache Works">How Apache Works</a>
</li>
<li> <a href="http://www.apache.org/foundation/" title="Foundation">Foundation</a>
</li>
<li> <a href="http://www.apache.org/foundation/sponsorship.html" title="Sponsoring Apache">Sponsoring Apache</a>
</li>
<li> <a href="http://www.apache.org/foundation/thanks.html" title="Thanks">Thanks</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div id="banner">
<div class="pull-left">
<div id="bannerLeft">
<h2>$banner.name</h2>
</div>
</div>
<div class="pull-right"> <div id="bannerRight">
<h2>$banner.name</h2>
</div>
</div>
<div class="clear"><hr/></div>
</div>
<div id="breadcrumbs">
<ul class="breadcrumb">
<li class="">
<a href="http://www.apache.org/" class="externalLink" title="Apache">
Apache</a>
<span class="divider">/</span>
</li>
<li class="">
<a href="http://maven.apache.org/index.html" class="externalLink" title="Maven">
Maven</a>
<span class="divider">/</span>
</li>
<li class="">
<a href="http://maven.apache.org/plugins/index.html" class="externalLink" title="Plugins">
Plugins</a>
<span class="divider">/</span>
</li>
<li class="">
<a href="https://maven-nar.github.com/" class="externalLink" title="NAR plugin">
NAR plugin</a>
<span class="divider">/</span>
</li>
<li class="active ">NAR Plugin</li>
<li id="publishDate" class="pull-right"><span class="divider">|</span> Last Published: 2016-04-26</li>
<li id="projectVersion" class="pull-right">
Version: 3.4.1-SNAPSHOT
</li>
</ul>
</div>
<div class="row-fluid">
<div id="leftColumn" class="span3">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Overview</li>
<li>
<a href="index.html" title="Introduction">
<i class="none"></i>
Introduction</a>
</li>
<li class="active">
<a href="#"><i class="none"></i>Philosophy</a>
</li>
<li>
<a href="NARPlugin.ppt" title="Presentation (ppt)">
<i class="none"></i>
Presentation (ppt)</a>
</li>
<li class="nav-header">User Info</li>
<li>
<a href="plugin-info.html" title="Goals">
<i class="none"></i>
Goals</a>
</li>
<li>
<a href="usage.html" title="Usage">
<i class="none"></i>
Usage</a>
</li>
<li>
<a href="lifecycle.html" title="Lifecycle">
<i class="none"></i>
Lifecycle</a>
</li>
<li>
<a href="configuration.html" title="Configuration">
<i class="none"></i>
Configuration</a>
</li>
<li>
<a href="https://github.com/maven-nar/nar-maven-plugin/wiki/Frequently_Asked_Questions" class="externalLink" title="FAQ">
<i class="none"></i>
FAQ</a>
</li>
<li>
<a href="aol.html" title="AOL Properties">
<i class="none"></i>
AOL Properties</a>
</li>
<li>
<a href="examples.html" title="Examples">
<i class="none"></i>
Examples</a>
</li>
<li>
<a href="archetypes.html" title="Archetypes">
<i class="none"></i>
Archetypes</a>
</li>
<li>
<a href="properties.html" title="Properties">
<i class="none"></i>
Properties</a>
</li>
<li>
<a href="compatibility.html" title="Compatibility">
<i class="none"></i>
Compatibility</a>
</li>
<li class="nav-header">Developer Info</li>
<li>
<a href="narDependencies.html" title="NAR Dependencies">
<i class="none"></i>
NAR Dependencies</a>
</li>
<li>
<a href="https://github.com/maven-nar/nar-maven-plugin/issues" class="externalLink" title="Bug Reports">
<i class="none"></i>
Bug Reports</a>
</li>
<li>
<a href="https://groups.google.com/forum/?fromgroups#!forum/maven-nar" class="externalLink" title="Forum">
<i class="none"></i>
Forum</a>
</li>
<li>
<a href="apidocs/index.html" title="APIDocs">
<i class="none"></i>
APIDocs</a>
</li>
<li>
<a href="narLibrary.html" title="NAR Library">
<i class="none"></i>
NAR Library</a>
</li>
<li>
<a href="cpptasks.html" title="CPPTasks">
<i class="none"></i>
CPPTasks</a>
</li>
<li>
<a href="https://github.com/maven-nar/nar-maven-plugin" class="externalLink" title="Git Browse nar-plugin">
<i class="none"></i>
Git Browse nar-plugin</a>
</li>
<li>
<a href="source-repository.html" title="Git Repository">
<i class="none"></i>
Git Repository</a>
</li>
<li class="nav-header">Project Documentation</li>
<li>
<a href="project-info.html" title="Project Information">
<i class="icon-chevron-right"></i>
Project Information</a>
</li>
<li>
<a href="project-reports.html" title="Project Reports">
<i class="icon-chevron-right"></i>
Project Reports</a>
</li>
<li class="nav-header">Maven Projects</li>
<li>
<a href="http://maven.apache.org/ant-tasks/index.html" class="externalLink" title="Ant Tasks">
<i class="none"></i>
Ant Tasks</a>
</li>
<li>
<a href="http://maven.apache.org/archetype/index.html" class="externalLink" title="Archetype">
<i class="none"></i>
Archetype</a>
</li>
<li>
<a href="http://maven.apache.org/doxia/index.html" class="externalLink" title="Doxia">
<i class="none"></i>
Doxia</a>
</li>
<li>
<a href="http://maven.apache.org/jxr/index.html" class="externalLink" title="JXR">
<i class="none"></i>
JXR</a>
</li>
<li>
<a href="http://maven.apache.org/maven-1.x/index.html" class="externalLink" title="Maven 1.x">
<i class="none"></i>
Maven 1.x</a>
</li>
<li>
<a href="http://maven.apache.org/index.html" class="externalLink" title="Maven 2 & 3">
<i class="none"></i>
Maven 2 & 3</a>
</li>
<li>
<a href="http://maven.apache.org/pom/index.html" class="externalLink" title="Parent POMs">
<i class="none"></i>
Parent POMs</a>
</li>
<li>
<a href="http://maven.apache.org/plugins/index.html" class="externalLink" title="Plugins">
<i class="none"></i>
Plugins</a>
</li>
<li>
<a href="http://maven.apache.org/plugin-tools/index.html" class="externalLink" title="Plugin Tools">
<i class="none"></i>
Plugin Tools</a>
</li>
<li>
<a href="http://maven.apache.org/scm/index.html" class="externalLink" title="SCM">
<i class="none"></i>
SCM</a>
</li>
<li>
<a href="http://maven.apache.org/shared/index.html" class="externalLink" title="Shared Components">
<i class="none"></i>
Shared Components</a>
</li>
<li>
<a href="http://maven.apache.org/skins/index.html" class="externalLink" title="Skins">
<i class="none"></i>
Skins</a>
</li>
<li>
<a href="http://maven.apache.org/surefire/index.html" class="externalLink" title="Surefire">
<i class="none"></i>
Surefire</a>
</li>
<li>
<a href="http://maven.apache.org/wagon/index.html" class="externalLink" title="Wagon">
<i class="none"></i>
Wagon</a>
</li>
<li class="nav-header">ASF</li>
<li>
<a href="http://www.apache.org/foundation/how-it-works.html" class="externalLink" title="How Apache Works">
<i class="none"></i>
How Apache Works</a>
</li>
<li>
<a href="http://www.apache.org/foundation/" class="externalLink" title="Foundation">
<i class="none"></i>
Foundation</a>
</li>
<li>
<a href="http://www.apache.org/foundation/sponsorship.html" class="externalLink" title="Sponsoring Apache">
<i class="none"></i>
Sponsoring Apache</a>
</li>
<li>
<a href="http://www.apache.org/foundation/thanks.html" class="externalLink" title="Thanks">
<i class="none"></i>
Thanks</a>
</li>
</ul>
<hr />
<div id="poweredBy">
<div class="clear"></div>
<div class="clear"></div>
<div class="clear"></div>
<div class="clear"></div>
<a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
<img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" />
</a>
</div>
</div>
</div>
<div id="bodyColumn" class="span9" >
<div class="section">
<h2>NAR Philosophy<a name="NAR_Philosophy"></a></h2>
<p>In the NAR plugin we follow Maven's main principles:</p>
<ul>
<li><a href="#Convention over configuration">Convention over configuration</a></li>
<li><a href="#Reuse of build logic">Reuse of build logic</a></li>
<li><a href="#Declarative execution">Declarative execution</a></li>
<li><a href="#Coherent organization of dependencies">Coherent organization of dependencies</a></li></ul>
<p>below we explain how:</p>
<div class="section">
<h3><a name="Convention_over_configuration">Convention over configuration</a></h3>
<p>The NAR Plugin enables a cross-platform build technology for native artifacts using Maven. Though the user has full flexibility in the choice of compiler/linker and their options, sensible defaults are provided by the NAR Plugin. The three primary conventions for the NAR Plugin are:</p>
<ul>
<li><a href="#Standard directory layout for Native projects">Standard directory layout for Native projects</a></li>
<li><a href="#A single Native project produces a single output">A single Native project produces a single output</a></li>
<li><a href="#Standard naming conventions">Standard naming conventions</a></li></ul>
<p>and are detailed below:</p>
<div class="section">
<h4><a name="Standard_directory_layout_for_Native_projects">Standard directory layout for Native projects</a></h4>
<p>The NAR Plugin assumes to find its native sources and resources in a directory structure parallel to the java sources. Test sources and test resources are organized the same way.</p>
<div class="source">
<pre>/yourproject
/src
/main
/java
/resources
/include
/c++
/c
/fortran
/test
/java
/resources
/include
/c++
/c
/fortran </pre></div>
<p>Organizing the information this way means that it is easy to find, for both people and the plugins that need to work with them. </p></div>
<div class="section">
<h4><a name="A_single_Native_project_produces_a_single_output">A single Native project produces a single output</a></h4>
<p>Maven produces one primary output (jar, war, ...) per project. For the NAR Plugin the produced nar files are secondary outputs or artifacts attached to the primary output. There are several reasons why the native artifacts are not primary outputs:</p>
<ul>
<li>When building a Native library, the object files and the include headers make a complete set. There is not much use of one without the other. Object files for one architecture combined in a nar file are no different than object files for another achitecture, their functionality is the same, its just for different machines. Neither the nar file with the include headers nor the nar files with the machine specific object files is a good primary output, so both attach to a jar file.</li>
<li>When one builds a JNI library one needs both the java code in a jar file and native code in a shared library. The expected dependency is that the jar file needs the JNI library. However, javah generates the necessary header file from java, which would make the JNI library dependent on the jar file. Since this is impossible it would be better to attach the JNI library (in its nar file) as a secondary artifact to the primary nar file.</li>
<li>When depending on a native library the user should just specify the artifactId, groupId, version and type, but <b>not</b> the architecture, os and linker it was build with. The latter is a derived value of the executable or library one is building at this time. Not specifying architecture, os and linker also means that the POM is generic. Since nar files are by default (except for the -noarch nar) architecture-os-linker specific they need to be secondary artifacts.</li></ul></div>
<div class="section">
<h4><a name="Standard_naming_conventions">Standard naming conventions</a></h4>
<p>When maven produces a jar file it's normally named <tt>artifactId-version.jar</tt>. The NAR Plugin follows this convention for its attached artifacts:</p>
<dl>
<dt><tt>artifactId-version-noarch.nar</tt></dt>
<dd>contains the non architecture specific parts of the native library, such as include headers.</dd>
<dt><tt>artifactId-version-aol-type.nar</tt></dt>
<dd>contains the architecture specific parts of the native library, such as the library and object files. The <i>aol</i> is an Architecture-OS-Linker qualifier, for example: ppc-MacOSX-g++. The <i>type</i> specifies what binding the library is, for example: shared, static or jni.</dd></dl>
<p>Since the java compiler has a unified interface there is no need for any naming conventions here. Native compilers and linkers on different platforms tend to have radically different interfaces (command line options) so these were unified, allowing the user to switch on exception handling and debugging with the same tag in the configuration no matter which platform the NAR Plugin is running on. An example is below:</p>
<div class="source">
<pre>...
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<configuration>
<cpp>
<exceptions>false</exceptions>
<debug>true</debug>
</cpp>
</configuration>
</plugin>
...</pre></div></div></div>
<div class="section">
<h3><a name="Reuse_of_build_logic">Reuse of build logic</a></h3>
<p>The NAR Plugin provides multiple goals organized in the "nar" lifecycle. The "nar" lifecycle integrates nicely with the default "jar" lifecycle to build java and native files into nar artifacts in parallel. Each of the NAR Plugin goals can of course also be configured separately if needed.</p>
<p>Most NAR goals are executed using the NarManager, which provides an API that can also be used by other plugins when they need to deal with NAR artifacts.</p></div>
<div class="section">
<h3><a name="Declarative_execution">Declarative execution</a></h3>
<p>All logic in Maven is setup in a declarative fashion using the Project Object Model (POM). The NAR Plugin can be configured inside this model. Moreover the "nar" lifecycle can be used to automatically integrate all the NAR Plugin goals with the goals of the default "jar" lifecycle.</p>
<div class="section">
<h4>NAR's project object model (POM)<a name="NARs_project_object_model_POM"></a></h4>
<p>The POM below is an example of how to compile, link and test a native shared library, which depends on a native math library (nmath).</p>
<div class="source">
<pre><project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>nar</packaging>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<version>3.4.1-SNAPSHOT</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.freehep</groupId>
<artifactId>nmath</artifactId>
<version>4.5.1</version>
<type>nar</type>
</dependency>
</dependencies>
</project></pre></div>
<p>This POM will allow you to compile, link and test the java and native code in the project. The crucial part of the POM is the inclusion of the NAR plugin as an extension and the declaration of the "nar" packaging. The two will call the NAR Plugin goals as specified in the lifecycle.</p>
<p>For this POM the NAR Plugin will download and unpack the noarch and aol parts of the org.freehep nmath library version 4.5.1, for the platform you are running on.</p>
<p>Maven's Super POM is used for most of the default behaviour and the NAR Plugin's <a href="./aol.html">AOL Properties</a> are used for native defaults.</p></div>
<div class="section">
<h4>NAR's build lifecycle<a name="NARs_build_lifecycle"></a></h4>
<p>Maven's default build lifecycle, "jar", allows one to execute plugin goals as part of it, but this necessitates declaration of separate goals in each POM. To simplify the building of native artifacts we chose to define a "nar" lifecycle which calls all the goals the "jar" lifecycle has, interleaved with the goals of the NAR Plugin.</p></div></div>
<div class="section">
<h3><a name="Coherent_organization_of_dependencies">Coherent organization of dependencies</a></h3>
<p>Maven uses a local repository to resolve its dependencies. If not found one or more remote repositories are consulted to find a dependency. If found the dependency is downloaded to the local repository and used from there by any of the plugins.</p>
<p>The NAR Plugin uses the same organization of dependencies and repositories. When a user executes install or deploy on a NAR project the main nar file with its attached nar artifacts will be installed in the local repository or deployed in the remote repository.</p>
<p>A remote repository for the native math library would probably look like this (note the support for multiple platforms and multiple library bindings):</p>
<div class="source">
<pre>remoterepo/
org/
freehep/
nmath/
4.5.1/
nmath-4.5.1.pom
nmath-4.5.1.pom.sha1
nmath-4.5.1.jar
nmath-4.5.1.jar.sha1
nmath-4.5.1-noarch.nar
nmath-4.5.1-noarch.nar.sha1
nmath-4.5.1-MacOSX-g++-static.nar
nmath-4.5.1-MacOSX-g++-static.nar.sha1
nmath-4.5.1-MacOSX-g++-shared.nar
nmath-4.5.1-MacOSX-g++-shared.nar.sha1
nmath-4.5.1-Linux-g++-shared.nar
nmath-4.5.1-Linux-g++-shared.nar.sha1
nmath-4.5.1-Windows-msvc-shared.nar
nmath-4.5.1-Windows-msvc-shared.nar.sha1
...</pre></div>
<p>When a NAR dependency is encountered the main nar file is already downloaded into the local repository by maven itself. The nar-download goal will download any attached NAR artifacts into the local repository and store them alongside the main nar file and the POM. Note that for these main nar and attached nar files there is just one POM, since it is just one artifact. If the nar files are already in the local repository, due to someone calling nar-install on them, no extra download occurs.</p>
<p>Now that the POM, main nar and attached nar files are all in the local repository, the nar-unpack goal unpacks the nar files in an area in the target directory of the project. This is necessary because none of the native compiler/linker tools understands nar files. Compilation and linking can thus search the local target area.</p></div></div>
</div>
</div>
</div>
<hr/>
<footer>
<div class="container-fluid">
<div class="row-fluid">
<p >Copyright © 2005–2016
<a href="https://github.com/maven-nar">NAR Maven Plugin developers</a>.
All rights reserved.
</p>
</div>
</div>
</footer>
</body>
</html>