This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 233079
Collapse All | Expand All

(-)maven.util/arch.xml (+1115 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE api-answers PUBLIC "-//NetBeans//DTD Arch Answers//EN" "../nbbuild/antsrc/org/netbeans/nbbuild/Arch.dtd" [
3
  <!ENTITY api-questions SYSTEM "../nbbuild/antsrc/org/netbeans/nbbuild/Arch-api-questions.xml">
4
]>
5
6
<api-answers
7
  question-version="1.29"
8
  author="yourname@netbeans.org"
9
>
10
11
  &api-questions;
12
13
14
<!--
15
        <question id="arch-overall" when="init">
16
            Describe the overall architecture. 
17
            <hint>
18
            What will be API for 
19
            <a href="http://wiki.netbeans.org/API_Design#Separate_API_for_clients_from_support_API">
20
                clients and what support API</a>? 
21
            What parts will be pluggable?
22
            How will plug-ins be registered? Please use <code>&lt;api type="export"/&gt;</code>
23
            to describe your general APIs and specify their
24
            <a href="http://wiki.netbeans.org/API_Stability#Private">
25
            stability categories</a>.
26
            If possible please provide simple diagrams.
27
            </hint>
28
        </question>
29
-->
30
 <answer id="arch-overall">
31
   <p>The purpose of this module is to provide an easy way to read and set Maven
32
      plugin parameters in POM.xml project file without having implementation
33
      dependencies on several Maven modules.
34
  </p>
35
  <p>
36
    </p>
37
 </answer>
38
39
40
41
<!--
42
        <question id="arch-quality" when="init">
43
            How will the <a href="http://www.netbeans.org/community/guidelines/q-evangelism.html">quality</a>
44
            of your code be tested and 
45
            how are future regressions going to be prevented?
46
            <hint>
47
            What kind of testing do
48
            you want to use? How much functionality, in which areas,
49
            should be covered by the tests? How you find out that your
50
            project was successful?
51
            </hint>
52
        </question>
53
-->
54
 <answer id="arch-quality">
55
  <p>
56
   All public API methods will be covered by unit tests.
57
  </p>
58
 </answer>
59
60
61
62
<!--
63
        <question id="arch-time" when="init">
64
            What are the time estimates of the work?
65
            <hint>
66
            Please express your estimates of how long the design, implementation,
67
            stabilization are likely to last. How many people will be needed to
68
            implement this and what is the expected milestone by which the work should be 
69
            ready?
70
            </hint>
71
        </question>
72
-->
73
 <answer id="arch-time">
74
  <p>
75
   2 man days.
76
  </p>
77
 </answer>
78
79
80
81
<!--
82
        <question id="arch-usecases" when="init">
83
            <hint>
84
                Content of this answer will be displayed as part of page at
85
                http://www.netbeans.org/download/dev/javadoc/usecases.html 
86
                You can use tags &lt;usecase name="name&gt; regular html description &lt;/usecase&gt;
87
                and if you want to use an URL you can prefix if with @TOP@ to begin
88
                at the root of your javadoc
89
            </hint>
90
        
91
            Describe the main <a href="http://wiki.netbeans.org/API_Design#The_Importance_of_Being_Use_Case_Oriented">
92
            use cases</a> of the new API. Who will use it under
93
            what circumstances? What kind of code would typically need to be written
94
            to use the module?
95
        </question>
96
-->
97
 <answer id="arch-usecases">
98
  <p>
99
   The main use case is implementing a panel to be added to Maven project properties
100
      window to adjust properties of a Maven plugin used in that project.
101
  </p>
102
  <pre>
103
import org.netbeans.modules.maven.util.MavenCategoryProvider;
104
105
@MavenCategoryProvider.Registration(artifactId = "my-special-artifactd", groupId = "my.special.maven.groupid")
106
public class ProjectCustomizerImpl extends MavenCategoryProvider {
107
108
109
    @Override
110
    public ProjectCustomizer.Category createCategory( Lookup lkp ) {
111
      //will be called only when the Maven project contains plugin with my.special.maven.groupid and my-special-artifactd
112
    }
113
114
    @Override
115
    public JComponent createComponent( ProjectCustomizer.Category ctgr, Lookup lkp ) {
116
      return new MyCustomizerPanel( ctgr, getPluginParameters() );
117
    }
118
}
119
120
class MyCustomizerPanel extends JPanel {
121
122
    MyCustomizerPanel( ProjectCustomizer.Category category, final MavenPluginParameters pluginParameters ) {
123
124
        Object initialValue = pluginParameters.getParameter( "myParamName", "myplugin.myproperty.name" );
125
126
        category.setOkButtonListener(new ActionListener() {
127
            @Override
128
            public void actionPerformed( ActionEvent e ) {
129
                pluginParameters.setParameter( "myParamName", "some value" );
130
            }
131
        } );
132
    }
133
}
134
135
  </pre>
136
 </answer>
137
138
139
140
<!--
141
        <question id="arch-what" when="init">
142
            What is this project good for?
143
            <hint>
144
            Please provide here a few lines describing the project, 
145
            what problem it should solve, provide links to documentation, 
146
            specifications, etc.
147
            </hint>
148
        </question>
149
-->
150
 <answer id="arch-what">
151
  <p>
152
   Read and set Maven project properties.
153
  </p>
154
 </answer>
155
156
157
158
<!--
159
        <question id="arch-where" when="impl">
160
            Where one can find sources for your module?
161
            <hint>
162
                Please provide link to the Hg web client at
163
                http://hg.netbeans.org/
164
                or just use tag defaultanswer generate='here'
165
            </hint>
166
        </question>
167
-->
168
 <answer id="arch-where">
169
  <defaultanswer generate='here' />
170
 </answer>
171
172
173
174
<!--
175
        <question id="compat-deprecation" when="init">
176
            How the introduction of your project influences functionality
177
            provided by previous version of the product?
178
            <hint>
179
            If you are planning to deprecate/remove/change any existing APIs,
180
            list them here accompanied with the reason explaining why you
181
            are doing so.
182
            </hint>
183
        </question>
184
-->
185
 <answer id="compat-deprecation">
186
  <p>
187
   This module does not deprecate nor replace any existing APIs.
188
  </p>
189
 </answer>
190
191
192
193
<!--
194
        <question id="compat-i18n" when="impl">
195
            Is your module correctly internationalized?
196
            <hint>
197
            Correct internationalization means that it obeys instructions 
198
            at <a href="http://www.netbeans.org/download/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/i18n-branding.html">
199
            NetBeans I18N pages</a>.
200
            </hint>
201
        </question>
202
-->
203
 <answer id="compat-i18n">
204
  <p>
205
   Does not apply.
206
  </p>
207
 </answer>
208
209
210
211
<!--
212
        <question id="compat-standards" when="init">
213
            Does the module implement or define any standards? Is the 
214
            implementation exact or does it deviate somehow?
215
        </question>
216
-->
217
 <answer id="compat-standards">
218
  <p>
219
   Does not apply.
220
  </p>
221
 </answer>
222
223
224
225
<!--
226
        <question id="compat-version" when="impl">
227
            Can your module coexist with earlier and future
228
            versions of itself? Can you correctly read all old settings? Will future
229
            versions be able to read your current settings? Can you read
230
            or politely ignore settings stored by a future version?
231
            
232
            <hint>
233
            Very helpful for reading settings is to store version number
234
            there, so future versions can decide whether how to read/convert
235
            the settings and older versions can ignore the new ones.
236
            </hint>
237
        </question>
238
-->
239
 <answer id="compat-version">
240
  <p>
241
   Future versions of this module should be backwards compatible.
242
  </p>
243
 </answer>
244
245
246
247
<!--
248
        <question id="dep-jre" when="final">
249
            Which version of JRE do you need (1.2, 1.3, 1.4, etc.)?
250
            <hint>
251
            It is expected that if your module runs on 1.x that it will run 
252
            on 1.x+1 if no, state that please. Also describe here cases where
253
            you run different code on different versions of JRE and why.
254
            </hint>
255
        </question>
256
-->
257
 <answer id="dep-jre">
258
  <p>
259
   Same as the rest of the IDE.
260
  </p>
261
 </answer>
262
263
264
265
<!--
266
        <question id="dep-jrejdk" when="final">
267
            Do you require the JDK or is the JRE enough?
268
        </question>
269
-->
270
 <answer id="dep-jrejdk">
271
  <p>
272
   JDK required.
273
  </p>
274
 </answer>
275
276
277
278
<!--
279
        <question id="dep-nb" when="init">
280
            What other NetBeans projects and modules does this one depend on?
281
            <hint>
282
            Depending on other NetBeans projects influnces the ability of
283
            users of your work to customize their own branded version of
284
            NetBeans by enabling and disabling some modules. Too
285
            much dependencies restrict this kind of customization. If that
286
            is your case, then you may want to split your functionality into
287
            pieces of autoload, eager and regular modules which can be
288
            enabled independently. Usually the answer to this question
289
            is generated from your <code>project.xml</code> file, but
290
            if it is not guessed correctly, you can suppress it by
291
            specifying &lt;defaultanswer generate="none"/&gt; and
292
            write here your own. Please describe such projects as imported APIs using
293
            the <code>&lt;api name="identification" type="import or export" category="stable" url="where is the description" /&gt;</code>.
294
            By doing this information gets listed in the summary page of your
295
            javadoc.
296
            </hint>
297
        </question>
298
-->
299
 <answer id="dep-nb">
300
  <defaultanswer generate='here' />
301
 </answer>
302
303
304
305
<!--
306
        <question id="dep-non-nb" when="init">
307
            What other projects outside NetBeans does this one depend on?
308
            
309
            <hint>
310
            Depending on 3rd party libraries is always problematic,
311
            especially if they are not open source, as that complicates
312
            the licensing scheme of NetBeans. Please enumerate your
313
            external dependencies here, so it is correctly understood since
314
            the begining what are the legal implications of your project.
315
            Also please note that
316
            some non-NetBeans projects are packaged as NetBeans modules
317
            (see <a href="http://libs.netbeans.org/">libraries</a>) and
318
            it is preferred to use this approach when more modules may
319
            depend and share such third-party libraries.
320
            </hint>
321
        </question>
322
-->
323
 <answer id="dep-non-nb">
324
  <p>
325
   No extra dependencies.
326
  </p>
327
 </answer>
328
329
330
331
<!--
332
        <question id="dep-platform" when="init">
333
            On which platforms does your module run? Does it run in the same
334
            way on each?
335
            <hint>
336
            If you plan any dependency on OS or any usage of native code,
337
            please describe why you are doing so and describe how you envision
338
            to enforce the portability of your code.
339
            Please note that there is a support for <a href="http://www.netbeans.org/download/dev/javadoc/org-openide-modules/org/openide/modules/doc-files/api.html#how-os-specific">OS conditionally
340
            enabled modules</a> which together with autoload/eager modules
341
            can allow you to enable to provide the best OS aware support
342
            on certain OSes while providing compatibility bridge on the not
343
            supported ones.
344
            Also please list the supported
345
            OSes/HW platforms and mentioned the lovest version of JDK required
346
            for your project to run on. Also state whether JRE is enough or
347
            you really need JDK.
348
            </hint>
349
        </question>
350
-->
351
 <answer id="dep-platform">
352
  <p>
353
   All platforms the IDE supports.
354
  </p>
355
 </answer>
356
357
358
359
<!--
360
        <question id="deploy-dependencies" when="final">
361
            What do other modules need to do to declare a dependency on this one,
362
            in addition to or instead of the normal module dependency declaration
363
            (e.g. tokens to require)?
364
            <hint>
365
                Provide a sample of the actual lines you would add to a module manifest
366
                to declare a dependency, for example OpenIDE-Module-Requires: some.token.
367
                If other modules should not depend on this module, or should just use a
368
                simple regular module dependency, you can just answer "nothing". If you
369
                intentionally expose a semistable API to clients using implementation
370
                dependencies, you should mention that here (but there is no need to give
371
                an example of usage).
372
            </hint>
373
        </question>
374
-->
375
 <answer id="deploy-dependencies">
376
  <p>
377
   No special dependencies.
378
  </p>
379
 </answer>
380
381
382
383
<!--
384
        <question id="deploy-jar" when="impl">
385
            Do you deploy just module JAR file(s) or other files as well?
386
            <hint>
387
            Usually a module consist of one JAR file (perhaps with Class-Path
388
            extensions) and also a configuration file that enables it. If you
389
            have any other files, use
390
            &lt;api group="java.io.File" name="yourname" type="export" category="friend"&gt;...&lt;/api&gt;
391
            to define the location, name and stability of your files (of course
392
            changing "yourname" and "friend" to suit your needs).
393
            
394
            If it uses more than one JAR, describe where they are located, how
395
            they refer to each other. 
396
            If it consist of module JAR(s) and other files, please describe
397
            what is their purpose, why other files are necessary. Please 
398
            make sure that installation/uninstallation leaves the system 
399
            in state as it was before installation.
400
            </hint>
401
        </question>
402
-->
403
 <answer id="deploy-jar">
404
  <p>
405
   Only JAR.
406
  </p>
407
 </answer>
408
409
410
411
<!--
412
        <question id="deploy-nbm" when="impl">
413
            Can you deploy an NBM via the Update Center?
414
            <hint>
415
            If not why?
416
            </hint>
417
        </question>
418
-->
419
 <answer id="deploy-nbm">
420
  <p>
421
   Yes.
422
  </p>
423
 </answer>
424
425
426
427
<!--
428
        <question id="deploy-packages" when="init">
429
            Are packages of your module made inaccessible by not declaring them
430
            public?
431
            
432
            <hint>
433
            By default NetBeans build harness treats all packages are private.
434
            If you export some of them - either as public or friend packages,
435
            you should have a reason. If the reason is described elsewhere
436
            in this document, you can ignore this question.
437
            </hint>
438
        </question>
439
-->
440
 <answer id="deploy-packages">
441
  <p>
442
   There are public packages in this module.
443
      <api name="MavenPluginProperties" group="java" type="export" category="devel" />
444
  </p>
445
 </answer>
446
447
448
449
<!--
450
        <question id="deploy-shared" when="final">
451
            Do you need to be installed in the shared location only, or in the user directory only,
452
            or can your module be installed anywhere?
453
            <hint>
454
            Installation location shall not matter, if it does explain why.
455
            Consider also whether <code>InstalledFileLocator</code> can help.
456
            </hint>
457
        </question>
458
-->
459
 <answer id="deploy-shared">
460
  <p>
461
   No special installation requirements.
462
  </p>
463
 </answer>
464
465
466
467
<!--
468
        <question id="exec-ant-tasks" when="impl">
469
            Do you define or register any ant tasks that other can use?
470
            
471
            <hint>
472
            If you provide an ant task that users can use, you need to be very
473
            careful about its syntax and behaviour, as it most likely forms an
474
	          API for end users and as there is a lot of end users, their reaction
475
            when such API gets broken can be pretty strong.
476
            </hint>
477
        </question>
478
-->
479
 <answer id="exec-ant-tasks">
480
  <p>
481
   No ant tasks.
482
  </p>
483
 </answer>
484
485
486
487
<!--
488
        <question id="exec-classloader" when="impl">
489
            Does your code create its own class loader(s)?
490
            <hint>
491
            A bit unusual. Please explain why and what for.
492
            </hint>
493
        </question>
494
-->
495
 <answer id="exec-classloader">
496
  <p>
497
   No custom class loaders.
498
  </p>
499
 </answer>
500
501
502
503
<!--
504
        <question id="exec-component" when="impl">
505
            Is execution of your code influenced by any (string) property
506
            of any of your components?
507
            
508
            <hint>
509
            Often <code>JComponent.getClientProperty</code>, <code>Action.getValue</code>
510
            or <code>PropertyDescriptor.getValue</code>, etc. are used to influence
511
            a behavior of some code. This of course forms an interface that should
512
            be documented. Also if one depends on some interface that an object
513
            implements (<code>component instanceof Runnable</code>) that forms an
514
            API as well.
515
            </hint>
516
        </question>
517
-->
518
 <answer id="exec-component">
519
  <p>
520
   No
521
  </p>
522
 </answer>
523
524
525
526
<!--
527
        <question id="exec-introspection" when="impl">
528
            Does your module use any kind of runtime type information (<code>instanceof</code>,
529
            work with <code>java.lang.Class</code>, etc.)?
530
            <hint>
531
            Check for cases when you have an object of type A and you also
532
            expect it to (possibly) be of type B and do some special action. That
533
            should be documented. The same applies on operations in meta-level
534
            (Class.isInstance(...), Class.isAssignableFrom(...), etc.).
535
            </hint>
536
        </question>
537
-->
538
 <answer id="exec-introspection">
539
  <p>
540
   No
541
  </p>
542
 </answer>
543
544
545
546
<!--
547
        <question id="exec-privateaccess" when="final">
548
            Are you aware of any other parts of the system calling some of 
549
            your methods by reflection?
550
            <hint>
551
            If so, describe the "contract" as an API. Likely private or friend one, but
552
            still API and consider rewrite of it.
553
            </hint>
554
        </question>
555
-->
556
 <answer id="exec-privateaccess">
557
  <p>
558
   No
559
  </p>
560
 </answer>
561
562
563
564
<!--
565
        <question id="exec-process" when="impl">
566
            Do you execute an external process from your module? How do you ensure
567
            that the result is the same on different platforms? Do you parse output?
568
            Do you depend on result code?
569
            <hint>
570
            If you feed an input, parse the output please declare that as an API.
571
            </hint>
572
        </question>
573
-->
574
 <answer id="exec-process">
575
  <p>
576
   No
577
  </p>
578
 </answer>
579
580
581
582
<!--
583
        <question id="exec-property" when="impl">
584
            Is execution of your code influenced by any environment or
585
            Java system (<code>System.getProperty</code>) property?
586
            On a similar note, is there something interesting that you
587
            pass to <code>java.util.logging.Logger</code>? Or do you observe
588
            what others log?
589
            <hint>
590
            If there is a property that can change the behavior of your 
591
            code, somebody will likely use it. You should describe what it does 
592
            and the <a href="http://wiki.netbeans.org/API_Stability">stability category</a>
593
            of this API. You may use
594
            <pre>
595
                &lt;api type="export" group="property" name="id" category="private" url="http://..."&gt;
596
                    description of the property, where it is used, what it influence, etc.
597
                &lt;/api&gt;            
598
            </pre>
599
            </hint>
600
        </question>
601
-->
602
 <answer id="exec-property">
603
  <p>
604
   No
605
  </p>
606
 </answer>
607
608
609
610
<!--
611
        <question id="exec-reflection" when="impl">
612
            Does your code use Java Reflection to execute other code?
613
            <hint>
614
            This usually indicates a missing or insufficient API in the other
615
            part of the system. If the other side is not aware of your dependency
616
            this contract can be easily broken.
617
            </hint>
618
        </question>
619
-->
620
 <answer id="exec-reflection">
621
  <p>
622
   No
623
  </p>
624
 </answer>
625
626
627
628
<!--
629
        <question id="exec-threading" when="init">
630
            What threading models, if any, does your module adhere to? How the
631
            project behaves with respect to threading?
632
            <hint>
633
                Is your API threadsafe? Can it be accessed from any threads or
634
                just from some dedicated ones? Any special relation to AWT and
635
                its Event Dispatch thread? Also
636
                if your module calls foreign APIs which have a specific threading model,
637
                indicate how you comply with the requirements for multithreaded access
638
                (synchronization, mutexes, etc.) applicable to those APIs.
639
                If your module defines any APIs, or has complex internal structures
640
                that might be used from multiple threads, declare how you protect
641
                data against concurrent access, race conditions, deadlocks, etc.,
642
                and whether such rules are enforced by runtime warnings, errors, assertions, etc.
643
                Examples: a class might be non-thread-safe (like Java Collections); might
644
                be fully thread-safe (internal locking); might require access through a mutex
645
                (and may or may not automatically acquire that mutex on behalf of a client method);
646
                might be able to run only in the event queue; etc.
647
                Also describe when any events are fired: synchronously, asynchronously, etc.
648
                Ideas: <a href="http://core.netbeans.org/proposals/threading/index.html#recommendations">Threading Recommendations</a> (in progress)
649
            </hint>
650
        </question>
651
-->
652
 <answer id="exec-threading">
653
  <p>
654
   All API methods are thread safe.
655
  </p>
656
 </answer>
657
658
659
660
<!--
661
        <question id="format-clipboard" when="impl">
662
            Which data flavors (if any) does your code read from or insert to
663
            the clipboard (by access to clipboard on means calling methods on <code>java.awt.datatransfer.Transferable</code>?
664
            
665
            <hint>
666
            Often Node's deal with clipboard by usage of <code>Node.clipboardCopy, Node.clipboardCut and Node.pasteTypes</code>.
667
            Check your code for overriding these methods.
668
            </hint>
669
        </question>
670
-->
671
 <answer id="format-clipboard">
672
  <p>
673
   No clipboard interaction.
674
  </p>
675
 </answer>
676
677
678
679
<!--
680
        <question id="format-dnd" when="impl">
681
            Which protocols (if any) does your code understand during Drag &amp; Drop?
682
            <hint>
683
            Often Node's deal with clipboard by usage of <code>Node.drag, Node.getDropType</code>. 
684
            Check your code for overriding these methods. Btw. if they are not overridden, they
685
            by default delegate to <code>Node.clipboardCopy, Node.clipboardCut and Node.pasteTypes</code>.
686
            </hint>
687
        </question>
688
-->
689
 <answer id="format-dnd">
690
  <p>
691
   No dnd.
692
  </p>
693
 </answer>
694
695
696
697
<!--
698
        <question id="format-types" when="impl">
699
            Which protocols and file formats (if any) does your module read or write on disk,
700
            or transmit or receive over the network? Do you generate an ant build script?
701
            Can it be edited and modified? 
702
            
703
            <hint>
704
            <p>
705
            Files can be read and written by other programs, modules and users. If they influence
706
            your behaviour, make sure you either document the format or claim that it is a private
707
            api (using the &lt;api&gt; tag). 
708
            </p>
709
            
710
            <p>
711
            If you generate an ant build file, this is very likely going to be seen by end users and
712
            they will be attempted to edit it. You should be ready for that and provide here a link
713
            to documentation that you have for such purposes and also describe how you are going to
714
            understand such files during next release, when you (very likely) slightly change the 
715
            format.
716
            </p>
717
            </hint>
718
        </question>
719
-->
720
 <answer id="format-types">
721
  <p>
722
   No direct disk access.
723
  </p>
724
 </answer>
725
726
727
728
<!--
729
        <question id="lookup-lookup" when="init">
730
            Does your module use <code>org.openide.util.Lookup</code>
731
            or any similar technology to find any components to communicate with? Which ones?
732
            
733
            <hint>
734
            NetBeans is build around a generic registry of services called
735
            lookup. It is preferable to use it for registration and discovery
736
            if possible. See
737
            <a href="http://www.netbeans.org/download/dev/javadoc/org-openide-util/org/openide/util/lookup/doc-files/index.html">
738
            The Solution to Comunication Between Components
739
            </a>. If you do not plan to use lookup and insist usage
740
            of other solution, then please describe why it is not working for
741
            you.
742
            <br/>
743
            When filling the final version of your arch document, please
744
            describe the interfaces you are searching for, where 
745
            are defined, whether you are searching for just one or more of them,
746
            if the order is important, etc. Also classify the stability of such
747
            API contract. Use &lt;api group=&amp;lookup&amp; /&gt; tag, so
748
            your information gets listed in the summary page of your javadoc.
749
            </hint>
750
        </question>
751
-->
752
 <answer id="lookup-lookup">
753
  <p>
754
   Uses Lookup passed into project customizer to find Maven model handle.
755
  </p>
756
 </answer>
757
758
759
760
<!--
761
        <question id="lookup-register" when="final">
762
            Do you register anything into lookup for other code to find?
763
            <hint>
764
            Do you register using layer file or using a declarative annotation such as <code>@ServiceProvider</code>?
765
            Who is supposed to find your component?
766
            </hint>
767
        </question>
768
-->
769
 <answer id="lookup-register">
770
  <p>
771
   No
772
  </p>
773
 </answer>
774
775
776
777
<!--
778
        <question id="lookup-remove" when="final">
779
            Do you remove entries of other modules from lookup?
780
            <hint>
781
            Why? Of course, that is possible, but it can be dangerous. Is the module
782
            your are masking resource from aware of what you are doing?
783
            </hint>
784
        </question>
785
-->
786
 <answer id="lookup-remove">
787
  <p>
788
   No
789
  </p>
790
 </answer>
791
792
793
794
<!--
795
        <question id="perf-exit" when="final">
796
            Does your module run any code on exit?
797
        </question>
798
-->
799
 <answer id="perf-exit">
800
  <p>
801
   No
802
  </p>
803
 </answer>
804
805
806
807
<!--
808
        <question id="perf-huge_dialogs" when="final">
809
            Does your module contain any dialogs or wizards with a large number of
810
            GUI controls such as combo boxes, lists, trees, or text areas?
811
        </question>
812
-->
813
 <answer id="perf-huge_dialogs">
814
  <p>
815
   No
816
  </p>
817
 </answer>
818
819
820
821
<!--
822
        <question id="perf-limit" when="init">
823
            Are there any hard-coded or practical limits in the number or size of
824
            elements your code can handle?
825
            <hint>
826
                Most of algorithms have increasing memory and speed complexity
827
                with respect to size of data they operate on. What is the critical
828
                part of your project that can be seen as a bottleneck with
829
                respect to speed or required memory? What are the practical
830
                sizes of data you tested your project with? What is your estimate
831
                of potential size of data that would cause visible performance
832
                problems? Is there some kind of check to detect such situation
833
                and prevent "hard" crashes - for example the CloneableEditorSupport
834
                checks for size of a file to be opened in editor
835
                and if it is larger than 1Mb it shows a dialog giving the
836
                user the right to decide - e.g. to cancel or commit suicide.
837
            </hint>
838
        </question>
839
-->
840
 <answer id="perf-limit">
841
  <p>
842
   No
843
  </p>
844
 </answer>
845
846
847
848
<!--
849
        <question id="perf-mem" when="final">
850
            How much memory does your component consume? Estimate
851
            with a relation to the number of windows, etc.
852
        </question>
853
-->
854
 <answer id="perf-mem">
855
  <p>
856
   No UI components.
857
  </p>
858
 </answer>
859
860
861
862
<!--
863
        <question id="perf-menus" when="final">
864
            Does your module use dynamically updated context menus, or
865
            context-sensitive actions with complicated and slow enablement logic?
866
            <hint>
867
                If you do a lot of tricks when adding actions to regular or context menus, you can significantly
868
                slow down display of the menu, even when the user is not using your action. Pay attention to
869
                actions you add to the main menu bar, and to context menus of foreign nodes or components. If
870
                the action is conditionally enabled, or changes its display dynamically, you need to check the
871
                impact on performance. In some cases it may be more appropriate to make a simple action that is
872
                always enabled but does more detailed checks in a dialog if it is actually run.
873
            </hint>
874
        </question>
875
-->
876
 <answer id="perf-menus">
877
  <p>
878
   No menus.
879
  </p>
880
 </answer>
881
882
883
884
<!--
885
        <question id="perf-progress" when="final">
886
            Does your module execute any long-running tasks?
887
            
888
            <hint>Long running tasks should never block 
889
            AWT thread as it badly hurts the UI
890
            <a href="http://performance.netbeans.org/responsiveness/issues.html">
891
            responsiveness</a>.
892
            Tasks like connecting over
893
            network, computing huge amount of data, compilation
894
            be done asynchronously (for example
895
            using <code>RequestProcessor</code>), definitively it should 
896
            not block AWT thread.
897
            </hint>
898
        </question>
899
-->
900
 <answer id="perf-progress">
901
  <p>
902
   No long running tasks.
903
  </p>
904
 </answer>
905
906
907
908
<!--
909
        <question id="perf-scale" when="init">
910
            Which external criteria influence the performance of your
911
            program (size of file in editor, number of files in menu, 
912
            in source directory, etc.) and how well your code scales?
913
            <hint>
914
            Please include some estimates, there are other more detailed 
915
            questions to answer in later phases of implementation. 
916
            </hint>
917
        </question>
918
-->
919
 <answer id="perf-scale">
920
  <p>
921
   Does not apply.
922
  </p>
923
 </answer>
924
925
926
927
<!--
928
        <question id="perf-spi" when="init">
929
            How the performance of the plugged in code will be enforced?
930
            <hint>
931
            If you allow foreign code to be plugged into your own module, how
932
            do you enforce that it will behave correctly and quickly and will not
933
            negatively influence the performance of your own module?
934
            </hint>
935
        </question>
936
-->
937
 <answer id="perf-spi">
938
  <p>
939
   No plugged in code.
940
  </p>
941
 </answer>
942
943
944
945
<!--
946
        <question id="perf-startup" when="final">
947
            Does your module run any code on startup?
948
        </question>
949
-->
950
 <answer id="perf-startup">
951
  <p>
952
   No
953
  </p>
954
 </answer>
955
956
957
958
<!--
959
        <question id="perf-wakeup" when="final">
960
            Does any piece of your code wake up periodically and do something
961
            even when the system is otherwise idle (no user interaction)?
962
        </question>
963
-->
964
 <answer id="perf-wakeup">
965
  <p>
966
   No
967
  </p>
968
 </answer>
969
970
971
972
<!--
973
        <question id="resources-file" when="final">
974
            Does your module use <code>java.io.File</code> directly?
975
            
976
            <hint>
977
            NetBeans provide a logical wrapper over plain files called 
978
            <code>org.openide.filesystems.FileObject</code> that
979
            provides uniform access to such resources and is the preferred
980
            way that should be used. But of course there can be situations when
981
            this is not suitable.
982
            </hint>
983
        </question>
984
-->
985
 <answer id="resources-file">
986
  <p>
987
   No
988
  </p>
989
 </answer>
990
991
992
993
<!--
994
        <question id="resources-layer" when="final">
995
            Does your module provide own layer? Does it create any files or
996
            folders in it? What it is trying to communicate by that and with which 
997
            components?
998
            
999
            <hint>
1000
            NetBeans allows automatic and declarative installation of resources 
1001
            by module layers. Module register files into appropriate places
1002
            and other components use that information to perform their task
1003
            (build menu, toolbar, window layout, list of templates, set of
1004
            options, etc.). 
1005
            </hint>
1006
        </question>
1007
-->
1008
 <answer id="resources-layer">
1009
  <p>
1010
   No
1011
  </p>
1012
 </answer>
1013
1014
1015
1016
<!--
1017
        <question id="resources-mask" when="final">
1018
            Does your module mask/hide/override any resources provided by other modules in
1019
            their layers?
1020
            
1021
            <hint>
1022
            If you mask a file provided by another module, you probably depend
1023
            on that and do not want the other module to (for example) change
1024
            the file's name. That module shall thus make that file available as an API
1025
            of some stability category.
1026
            </hint>
1027
        </question>
1028
-->
1029
 <answer id="resources-mask">
1030
  <p>
1031
   No
1032
  </p>
1033
 </answer>
1034
1035
1036
1037
<!--
1038
        <question id="resources-preferences" when="final">
1039
            Does your module uses preferences via Preferences API? Does your module use NbPreferences or
1040
            or regular JDK Preferences ? Does it read, write or both ? 
1041
            Does it share preferences with other modules ? If so, then why ?
1042
            <hint>
1043
                You may use
1044
                    &lt;api type="export" group="preferences"
1045
                    name="preference node name" category="private"&gt;
1046
                    description of individual keys, where it is used, what it
1047
                    influences, whether the module reads/write it, etc.
1048
                    &lt;/api&gt;
1049
                Due to XML ID restrictions, rather than /org/netbeans/modules/foo give the "name" as org.netbeans.modules.foo.
1050
                Note that if you use NbPreferences this name will then be the same as the code name base of the module.
1051
            </hint>
1052
        </question>
1053
-->
1054
 <answer id="resources-preferences">
1055
  <p>
1056
   No
1057
  </p>
1058
 </answer>
1059
1060
1061
1062
<!--
1063
        <question id="resources-read" when="final">
1064
            Does your module read any resources from layers? For what purpose?
1065
            
1066
            <hint>
1067
            As this is some kind of intermodule dependency, it is a kind of API.
1068
            Please describe it and classify according to 
1069
            <a href="http://wiki.netbeans.org/API_Design#What_is_an_API.3F">
1070
            common stability categories</a>.
1071
            </hint>
1072
        </question>
1073
-->
1074
 <answer id="resources-read">
1075
  <p>
1076
   No
1077
  </p>
1078
 </answer>
1079
1080
1081
1082
<!--
1083
        <question id="security-grant" when="final">
1084
            Does your code grant additional rights to some other code?
1085
            <hint>Avoid using a class loader that adds extra
1086
            permissions to loaded code unless really necessary.
1087
            Also note that your API implementation
1088
            can also expose unneeded permissions to enemy code by
1089
            calling AccessController.doPrivileged().</hint>
1090
        </question>
1091
-->
1092
 <answer id="security-grant">
1093
  <p>
1094
   No
1095
  </p>
1096
 </answer>
1097
1098
1099
1100
<!--
1101
        <question id="security-policy" when="final">
1102
            Does your functionality require modifications to the standard policy file?
1103
            <hint>Your code might pass control to third-party code not
1104
            coming from trusted domains. This could be code downloaded over the
1105
            network or code coming from libraries that are not bundled
1106
            with NetBeans. Which permissions need to be granted to which domains?</hint>
1107
        </question>
1108
-->
1109
 <answer id="security-policy">
1110
  <p>
1111
   No
1112
  </p>
1113
 </answer>
1114
1115
</api-answers>
(-)maven.util/build.xml (+5 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project basedir="." default="netbeans" name="maven.util">
3
    <description>Builds, tests, and runs the project org.netbeans.modules.maven.util</description>
4
    <import file="../nbbuild/templates/projectized.xml"/>
5
</project>
(-)maven.util/manifest.mf (+5 lines)
Line 0 Link Here
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.maven.util/1
3
OpenIDE-Module-Implementation-Version: 1
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/maven/util/Bundle.properties
5
(-)maven.util/nbproject/project.properties (+4 lines)
Line 0 Link Here
1
javac.source=1.6
2
javac.compilerargs=-Xlint -Xlint:-serial
3
javadoc.arch=${basedir}/arch.xml
4
spec.version.base=1.0
(-)maven.util/nbproject/project.xml (+89 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://www.netbeans.org/ns/project/1">
3
    <type>org.netbeans.modules.apisupport.project</type>
4
    <configuration>
5
        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
6
            <code-name-base>org.netbeans.modules.maven.util</code-name-base>
7
            <module-dependencies>
8
                <dependency>
9
                    <code-name-base>org.netbeans.modules.maven</code-name-base>
10
                    <build-prerequisite/>
11
                    <compile-dependency/>
12
                    <run-dependency>
13
                        <release-version>2</release-version>
14
                    </run-dependency>
15
                </dependency>
16
                <dependency>
17
                    <code-name-base>org.netbeans.modules.maven.embedder</code-name-base>
18
                    <build-prerequisite/>
19
                    <compile-dependency/>
20
                    <run-dependency>
21
                        <release-version>2</release-version>
22
                    </run-dependency>
23
                </dependency>
24
                <dependency>
25
                    <code-name-base>org.netbeans.modules.maven.model</code-name-base>
26
                    <build-prerequisite/>
27
                    <compile-dependency/>
28
                    <run-dependency>
29
                        <release-version>1</release-version>
30
                    </run-dependency>
31
                </dependency>
32
                <dependency>
33
                    <code-name-base>org.netbeans.modules.projectapi</code-name-base>
34
                    <build-prerequisite/>
35
                    <compile-dependency/>
36
                    <run-dependency>
37
                        <release-version>1</release-version>
38
                        <specification-version>1.54</specification-version>
39
                    </run-dependency>
40
                </dependency>
41
                <dependency>
42
                    <code-name-base>org.netbeans.modules.projectuiapi</code-name-base>
43
                    <build-prerequisite/>
44
                    <compile-dependency/>
45
                    <run-dependency>
46
                        <release-version>1</release-version>
47
                        <specification-version>1.72</specification-version>
48
                    </run-dependency>
49
                </dependency>
50
                <dependency>
51
                    <code-name-base>org.netbeans.modules.xml.xam</code-name-base>
52
                    <build-prerequisite/>
53
                    <compile-dependency/>
54
                    <run-dependency>
55
                        <release-version>1</release-version>
56
                        <specification-version>1.25.0.1</specification-version>
57
                    </run-dependency>
58
                </dependency>
59
                <dependency>
60
                    <code-name-base>org.openide.filesystems</code-name-base>
61
                    <build-prerequisite/>
62
                    <compile-dependency/>
63
                    <run-dependency>
64
                        <specification-version>8.8</specification-version>
65
                    </run-dependency>
66
                </dependency>
67
                <dependency>
68
                    <code-name-base>org.openide.util</code-name-base>
69
                    <build-prerequisite/>
70
                    <compile-dependency/>
71
                    <run-dependency>
72
                        <specification-version>8.33</specification-version>
73
                    </run-dependency>
74
                </dependency>
75
                <dependency>
76
                    <code-name-base>org.openide.util.lookup</code-name-base>
77
                    <build-prerequisite/>
78
                    <compile-dependency/>
79
                    <run-dependency>
80
                        <specification-version>8.22</specification-version>
81
                    </run-dependency>
82
                </dependency>
83
            </module-dependencies>
84
            <public-packages>
85
                <package>org.netbeans.modules.maven.util</package>
86
            </public-packages>
87
        </data>
88
    </configuration>
89
</project>
(-)maven.util/src/org/netbeans/modules/maven/util/Bundle.properties (+1 lines)
Line 0 Link Here
1
OpenIDE-Module-Name=Maven Utilities
(-)maven.util/src/org/netbeans/modules/maven/util/impl/MavenCategoryProviderAnnotationProcessor.java (+188 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2009 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.maven.util.impl;
44
45
import java.lang.annotation.Annotation;
46
import java.util.Arrays;
47
import java.util.HashSet;
48
import java.util.Set;
49
import javax.annotation.processing.Processor;
50
import javax.annotation.processing.RoundEnvironment;
51
import javax.annotation.processing.SupportedSourceVersion;
52
import javax.lang.model.SourceVersion;
53
import javax.lang.model.element.Element;
54
import static javax.lang.model.element.ElementKind.CLASS;
55
import static javax.lang.model.element.ElementKind.METHOD;
56
import javax.lang.model.element.ExecutableElement;
57
import javax.lang.model.element.Modifier;
58
import javax.lang.model.element.TypeElement;
59
import javax.lang.model.type.TypeMirror;
60
import javax.lang.model.util.ElementFilter;
61
import org.netbeans.modules.maven.util.MavenCategoryProvider;
62
import org.netbeans.modules.maven.util.MavenCategoryProvider.Registration;
63
import org.openide.filesystems.annotations.LayerBuilder.File;
64
import org.openide.filesystems.annotations.LayerGeneratingProcessor;
65
import org.openide.filesystems.annotations.LayerGenerationException;
66
import org.openide.util.lookup.ServiceProvider;
67
68
@ServiceProvider(service = Processor.class)
69
@SupportedSourceVersion(SourceVersion.RELEASE_6)
70
public class MavenCategoryProviderAnnotationProcessor extends LayerGeneratingProcessor {
71
72
    public @Override Set<String> getSupportedAnnotationTypes() {
73
        return new HashSet<String>(Arrays.asList(
74
                Registration.class.getCanonicalName()
75
        ));
76
    }
77
78
    @Override
79
    protected boolean handleProcess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws LayerGenerationException {
80
        if (roundEnv.processingOver()) {
81
            return false;
82
        }
83
        for (Element e : roundEnv.getElementsAnnotatedWith(Registration.class)) {
84
            Registration r = e.getAnnotation(Registration.class);
85
            if (r == null) {
86
                continue;
87
            }
88
            handle(e, r);
89
        }
90
        return true;
91
    }
92
93
    private void handle(Element e, Registration r) throws LayerGenerationException {
94
        String path = "Projects/org-netbeans-modules-maven/Customizer"; //NOI18N
95
        if (r.category().length() > 0) {
96
            path += "/" + r.category();
97
        }
98
        boolean addsFolder = r.categoryLabel().length() > 0;
99
        if (addsFolder) {
100
            handleFolder(path, e, r);
101
        }
102
        File f = layer(e).instanceFile(path, null, MavenCategoryProvider.class, r, null);
103
        f.methodvalue("instanceCreate", "org.netbeans.modules.maven.util.ProxyCategoryProvider", "create"); //NOI18N
104
        f.position(addsFolder ? 0 : r.position());
105
        if( r.groupId().isEmpty() )
106
            throw new LayerGenerationException("Must specify groupId", e, processingEnv, r); //NOI18N
107
        f.stringvalue( "groupId", r.groupId());
108
        if( r.artifactId().isEmpty() )
109
            throw new LayerGenerationException("Must specify artifactId", e, processingEnv, r); //NOI18N
110
        f.stringvalue( "artifactId", r.artifactId()); //NOI18N
111
112
        String[] clazzOrMethod = instantiableClassOrMethod(e, r, null);
113
        String clazz = clazzOrMethod[0];
114
        String method = clazzOrMethod[1];
115
        if( null == method ) {
116
            f.newvalue("categoryProvider", clazz); //NOI18N
117
        } else {
118
            f.methodvalue( "categoryProvider", clazz, method); //NOI18N
119
        }
120
        f.write();
121
    }
122
123
    private void handleFolder(String path, Element e, Registration r) throws LayerGenerationException {
124
        if (r.category().length() == 0) {
125
            throw new LayerGenerationException("Must specify category", e, processingEnv, r); //NOI18N
126
        }
127
        layer(e).folder(path).bundlevalue("displayName", r.categoryLabel(), r, "categoryLabel").position(r.position()).write(); //NOI18N
128
    }
129
130
131
132
    private String[] instantiableClassOrMethod(Element originatingElement, Annotation annotation, String annotationMethod) throws IllegalArgumentException, LayerGenerationException {
133
        Class<?> type = MavenCategoryProvider.class;
134
        if (originatingElement == null) {
135
            throw new IllegalArgumentException("Only applicable to builders with exactly one associated element");
136
        }
137
        TypeMirror typeMirror = type != null ?
138
            processingEnv.getTypeUtils().getDeclaredType(
139
                processingEnv.getElementUtils().getTypeElement(type.getName().replace('$', '.'))) :
140
            null;
141
        switch (originatingElement.getKind()) {
142
            case CLASS: {
143
                String clazz = processingEnv.getElementUtils().getBinaryName((TypeElement) originatingElement).toString();
144
                if (originatingElement.getModifiers().contains(Modifier.ABSTRACT)) {
145
                    throw new LayerGenerationException(clazz + " must not be abstract", originatingElement, processingEnv, annotation, annotationMethod);
146
                }
147
                {
148
                    boolean hasDefaultCtor = false;
149
                    for (ExecutableElement constructor : ElementFilter.constructorsIn(originatingElement.getEnclosedElements())) {
150
                        if (constructor.getParameters().isEmpty()) {
151
                            hasDefaultCtor = true;
152
                            break;
153
                        }
154
                    }
155
                    if (!hasDefaultCtor) {
156
                        throw new LayerGenerationException(clazz + " must have a no-argument constructor", originatingElement, processingEnv, annotation, annotationMethod);
157
                    }
158
                }
159
                if (typeMirror != null && !processingEnv.getTypeUtils().isAssignable(originatingElement.asType(), typeMirror)) {
160
                    throw new LayerGenerationException(clazz + " is not assignable to " + typeMirror, originatingElement, processingEnv, annotation, annotationMethod);
161
                }
162
                if (!originatingElement.getModifiers().contains(Modifier.PUBLIC)) {
163
                    throw new LayerGenerationException(clazz + " is not public", originatingElement, processingEnv, annotation, annotationMethod);
164
                }
165
                if (((TypeElement) originatingElement).getNestingKind().isNested() && !originatingElement.getModifiers().contains(Modifier.STATIC)) {
166
                    throw new LayerGenerationException(clazz + " is nested but not static", originatingElement, processingEnv, annotation, annotationMethod);
167
                }
168
                return new String[] {clazz, null};
169
            }
170
            case METHOD: {
171
                String clazz = processingEnv.getElementUtils().getBinaryName((TypeElement) originatingElement.getEnclosingElement()).toString();
172
                String method = originatingElement.getSimpleName().toString();
173
                if (!originatingElement.getModifiers().contains(Modifier.STATIC)) {
174
                    throw new LayerGenerationException(clazz + "." + method + " must be static", originatingElement, processingEnv, annotation, annotationMethod);
175
                }
176
                if (!((ExecutableElement) originatingElement).getParameters().isEmpty()) {
177
                    throw new LayerGenerationException(clazz + "." + method + " must not take arguments", originatingElement, processingEnv, annotation, annotationMethod);
178
                }
179
                if (typeMirror != null && !processingEnv.getTypeUtils().isAssignable(((ExecutableElement) originatingElement).getReturnType(), typeMirror)) {
180
                    throw new LayerGenerationException(clazz + "." + method + " is not assignable to " + typeMirror, originatingElement, processingEnv, annotation, annotationMethod);
181
                }
182
                return new String[] {clazz, method};
183
            }
184
            default:
185
                throw new LayerGenerationException("Annotated element is not loadable as an instance", originatingElement, processingEnv, annotation, annotationMethod);
186
        }
187
    }
188
}
(-)maven.util/src/org/netbeans/modules/maven/util/MavenCategoryProvider.java (+125 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.maven.util;
43
44
import java.lang.annotation.ElementType;
45
import java.lang.annotation.Retention;
46
import java.lang.annotation.RetentionPolicy;
47
import java.lang.annotation.Target;
48
import org.netbeans.spi.project.ui.support.ProjectCustomizer;
49
50
/**
51
 * Allows to register project customizer panels for Maven projects that have
52
 * specific Maven plugins in their POM.
53
 * 
54
 * @author S. Aubrecht
55
 */
56
public abstract class MavenCategoryProvider implements ProjectCustomizer.CompositeCategoryProvider {
57
58
    private MavenPluginParameters pluginParameters;
59
60
    final void setPluginParameters( MavenPluginParameters params ) {
61
        this.pluginParameters = params;
62
    }
63
64
    /**
65
     * Access utility methods to get/set Maven plugin parameters.
66
     * @return Plugin parameters or null when not registered properly (without annotations).
67
     */
68
    public final MavenPluginParameters getPluginParameters(){
69
        return pluginParameters;
70
    }
71
    
72
    /**
73
     * Used to register customizer panels for Maven projects that have specific
74
     * plugin in their POM.
75
     * There are three ways this annotation can be used:
76
     * <ol>
77
     * <li>Register a "leaf" panel with no children.
78
     *     {@link #category} can be omitted for a top-level panel;
79
     *     if specified, the panel is placed in the named subcategory.
80
     *     {@link #categoryLabel} should not be specified.
81
     *     The annotation must be placed on a class or factory method implementing {@link CompositeCategoryProvider}.
82
     * <li>Register a category folder with no panel.
83
     *     {@link #category} must be specified; the last path component is the
84
     *     folder being defined, and any previous components are parent folders.
85
     *     {@link #categoryLabel} must be specified.
86
     *     The annotation must be placed on some package declaration (in {@code package-info.java}).
87
     * <li>Register a category folder also with its own panel (i.e. {@code Self}).
88
     *     {@link #category} and {@link #categoryLabel} must be specified as for #2,
89
     *     but the annotation must be on a provider implementation as for #1.
90
     * </ol>
91
     * To represent hierarchies of panels, the {@link #category} of a #1 can
92
     * match the {@link #category} of a #2 or #3, and the {@link #category} of a #2 or #3
93
     * preceding the last {@code /} can match the {@link #category} of another #2 or #3.
94
     * <p>Multiple registrations may be made in one place using {@link Registrations}.
95
     */
96
    @Target({ElementType.TYPE, ElementType.METHOD})
97
    @Retention(RetentionPolicy.SOURCE)
98
    public @interface Registration {
99
100
        /**
101
         * Maven plugin group id that the project customizer applies to.
102
         */
103
        String groupId();
104
105
        /**
106
         * Maven artifact id that the project customizer applies to.
107
         */
108
        String artifactId();
109
110
        /**
111
         * Category folder (perhaps multiple components separated by {@code /})
112
         * in which to place this panel or which is the name of this panel folder.
113
         */
114
        String category() default "";
115
        /**
116
         * Display name when defining a category folder.
117
         * Can use {@code pkg.of.Bundle#key_name} syntax.
118
         */
119
        String categoryLabel() default "";
120
        /**
121
         * Position of this panel or subfolder within its folder.
122
         */
123
        int position() default Integer.MAX_VALUE;
124
    }
125
}
(-)maven.util/src/org/netbeans/modules/maven/util/MavenPluginParameters.java (+166 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
package org.netbeans.modules.maven.util;
43
44
import org.apache.maven.project.MavenProject;
45
import org.netbeans.modules.maven.api.NbMavenProject;
46
import org.netbeans.modules.maven.api.PluginPropertyUtils;
47
import org.netbeans.modules.maven.api.customizer.ModelHandle2;
48
import org.netbeans.modules.maven.model.ModelOperation;
49
import org.netbeans.modules.maven.model.pom.Build;
50
import org.netbeans.modules.maven.model.pom.Configuration;
51
import org.netbeans.modules.maven.model.pom.POMComponentFactory;
52
import org.netbeans.modules.maven.model.pom.POMModel;
53
import org.netbeans.modules.maven.model.pom.Plugin;
54
import org.openide.util.Lookup;
55
56
57
/**
58
 * Convenience methods to retrieve and set plugin parameters in Maven POM.
59
 * 
60
 * @author S. Aubrecht
61
 */
62
public final class MavenPluginParameters {
63
64
    private final Lookup lkp;
65
    private final String groupId;
66
    private final String artifactId;
67
68
    private MavenPluginParameters( Lookup lkp, String groupId, String artifactId ) {
69
        this.lkp = lkp;
70
        this.groupId = groupId;
71
        this.artifactId = artifactId;
72
    }
73
74
    /**
75
     * Creates a new instance for the given group and artifact id.
76
     * @param lkp
77
     * @param groupId
78
     * @param artifactId
79
     * @return
80
     */
81
    static MavenPluginParameters create( Lookup lkp, String groupId, String artifactId ) {
82
        return new MavenPluginParameters( lkp, groupId, artifactId );
83
    }
84
85
    /**
86
     * Retrieve Maven plugin version info.
87
     * @return Version number for the given plugin or null.
88
     */
89
    public String getPluginVersion() {
90
        NbMavenProject nbMaven = lkp.lookup( NbMavenProject.class );
91
92
        return PluginPropertyUtils.getPluginVersion( nbMaven.getMavenProject(), groupId, artifactId );
93
    }
94
95
    /**
96
     * Retrieve Maven plugin configuration property.
97
     * @param paramName Plugin parameter name.
98
     * @param expressionProperty User property name.
99
     * @return Parameter value or null if the parameter isn't defined.
100
     */
101
    public String getParameter( String paramName, String expressionProperty ) {
102
        NbMavenProject nbMaven = lkp.lookup( NbMavenProject.class );
103
        MavenProject prj = nbMaven.getMavenProject();
104
            return PluginPropertyUtils.getPluginProperty( prj, groupId, artifactId, paramName, null, expressionProperty );
105
    }
106
107
    /**
108
     * Change/add property for the given Maven plugin.
109
     * @param paramName Parameter name
110
     * @param propertyValue Parameter value
111
     */
112
    public void setParameter( String paramName, String propertyValue ) {
113
        ModelHandle2 mh = lkp.lookup( ModelHandle2.class);
114
        NbMavenProject nbMaven = lkp.lookup( NbMavenProject.class );
115
        mh.addPOMModification( new ParameterOperation( nbMaven, groupId, artifactId, paramName, propertyValue));
116
    }
117
118
119
    private static class ParameterOperation implements ModelOperation<POMModel> {
120
121
        private final NbMavenProject nbMaven;
122
        private final String groupId;
123
        private final String artifactId;
124
        private final String name;
125
        private final String value;
126
127
        public ParameterOperation( NbMavenProject nbMaven, String groupId, String artifacId, String paramName, String paramValue ) {
128
            this.nbMaven = nbMaven;
129
            this.groupId = groupId;
130
            this.artifactId = artifacId;
131
            this.name = paramName;
132
            this.value = paramValue;
133
        }
134
135
        @Override
136
        public void performOperation( POMModel model ) {
137
            //new approach, assume all plugins conform to the new setting.
138
            POMComponentFactory fact = model.getFactory();
139
140
            //check if compiler/resources plugins are configured and update them to ${project.source.encoding expression
141
            Build bld = model.getProject().getBuild();
142
            if( bld == null ) {
143
                bld = fact.createBuild();
144
                model.getProject().setBuild( bld );
145
                return;
146
            }
147
148
            Plugin plugin = bld.findPluginById( groupId, artifactId );
149
            if( plugin == null ) {
150
                plugin = fact.createPlugin();
151
                plugin.setArtifactId( artifactId );
152
                plugin.setGroupId( groupId );
153
                plugin.setVersion( PluginPropertyUtils.getPluginVersion( nbMaven.getMavenProject(), groupId, artifactId ) );
154
                bld.addPlugin( plugin );
155
            }
156
            Configuration conf = plugin.getConfiguration();
157
            if( conf == null ) {
158
                conf = fact.createConfiguration();
159
                plugin.setConfiguration( conf );
160
            }
161
            if( conf != null ) {
162
                conf.setSimpleParameter( name, value );
163
            }
164
        }
165
    };
166
}
(-)maven.util/src/org/netbeans/modules/maven/util/ProxyCategoryProvider.java (-20 / +47 lines)
Lines 39-84 Link Here
39
 *
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
41
 */
42
package org.netbeans.modules.deploy.ios.customizer;
42
package org.netbeans.modules.maven.util;
43
43
44
import java.util.HashMap;
45
import java.util.Map;
44
import javax.swing.JComponent;
46
import javax.swing.JComponent;
45
import org.netbeans.spi.project.ui.support.ProjectCustomizer;
47
import org.netbeans.spi.project.ui.support.ProjectCustomizer;
46
import org.netbeans.api.project.Project;
48
import org.netbeans.api.project.Project;
47
import org.netbeans.modules.maven.api.NbMavenProject;
49
import org.netbeans.modules.maven.api.NbMavenProject;
48
import org.netbeans.modules.maven.api.PluginPropertyUtils;
50
import org.netbeans.modules.maven.api.PluginPropertyUtils;
49
import org.openide.util.Lookup;
51
import org.openide.util.Lookup;
50
import org.openide.util.NbBundle;
51
52
52
/**
53
/**
54
 * Category provider that delegates to a different category provider - if the Maven
55
 * project POM contains the desired plugin.
53
 *
56
 *
54
 * @author  S. Aubrecht
57
 * @author  S. Aubrecht
55
 */
58
 */
56
@ProjectCustomizer.CompositeCategoryProvider.Registration(
59
final class ProxyCategoryProvider implements ProjectCustomizer.CompositeCategoryProvider {
57
projectType = "org-netbeans-modules-maven", position = 450)
58
public class ProjectCustomizerImpl implements ProjectCustomizer.CompositeCategoryProvider {
59
60
60
    private static final String CAT_IPHONE = "deploy-ios-iphone"; //NOI18N
61
    private final Map args;
61
    private static final String CAT_IPAD = "deploy-ios-ipad"; //NOI18N
62
    private MavenCategoryProvider theProvider;
62
    private static final String CAT_IOS = "deploy-ios"; //NOI18N
63
63
64
    public ProxyCategoryProvider() {
65
        this( new HashMap(0) );
66
    }
67
68
    private ProxyCategoryProvider( Map args ) {
69
        this.args = args;
70
    }
71
72
    static ProjectCustomizer.CompositeCategoryProvider create( Map args ) {
73
        return new ProxyCategoryProvider( args );
74
    }
75
64
    @Override
76
    @Override
65
    public ProjectCustomizer.Category createCategory( Lookup lkp ) {
77
    public ProjectCustomizer.Category createCategory( Lookup lkp ) {
66
        if( isSupportedProject( lkp ) ) {
78
        if( isSupportedProject( lkp ) ) {
67
            ProjectCustomizer.Category catIPhone = ProjectCustomizer.Category.create( CAT_IPHONE, NbBundle.getMessage(ProjectCustomizerImpl.class, "Cat_Iphone"), null, null );
79
            createProvider( lkp );
68
            ProjectCustomizer.Category catIPad = ProjectCustomizer.Category.create( CAT_IPAD, NbBundle.getMessage(ProjectCustomizerImpl.class, "Cat_IPAD"), null, null );
80
            if( null != theProvider ) {
69
            return ProjectCustomizer.Category.create( CAT_IOS, NbBundle.getMessage(ProjectCustomizerImpl.class, "Cat_IOS"), null, new ProjectCustomizer.Category[] { catIPhone, catIPad } );
81
                return theProvider.createCategory( lkp );
70
        }
82
        }
83
        }
71
        return null;
84
        return null;
72
    }
85
    }
73
86
74
    @Override
87
    @Override
75
    public JComponent createComponent( ProjectCustomizer.Category ctgr, Lookup lkp ) {
88
    public JComponent createComponent( ProjectCustomizer.Category ctgr, Lookup lkp ) {
76
        if( CAT_IOS.equals( ctgr.getName() ) ) {
89
        if( null != theProvider ) {
77
            return new IOSMainCustomizer(ctgr, lkp);
90
            return theProvider.createComponent( ctgr, lkp );
78
        } else if( CAT_IPHONE.equals( ctgr.getName() ) ) {
79
            return new IPhoneCustomizer(ctgr, lkp);
80
        } else if( CAT_IPAD.equals( ctgr.getName() ) ) {
81
            return new IPadCustomizer(ctgr, lkp);
82
        }
91
        }
83
        return null;
92
        return null;
84
    }
93
    }
Lines 86-94 Link Here
86
    private boolean isSupportedProject( Lookup lkp ) {
95
    private boolean isSupportedProject( Lookup lkp ) {
87
        Project prj = lkp.lookup( Project.class );
96
        Project prj = lkp.lookup( Project.class );
88
        NbMavenProject nbMaven = prj.getLookup().lookup( NbMavenProject.class );
97
        NbMavenProject nbMaven = prj.getLookup().lookup( NbMavenProject.class );
98
        if( null == nbMaven )
99
            return false;
100
        String groupId = getGroupId();
101
        String artifactId = getArtifactId();
102
        if( null == groupId || null == artifactId )
103
            return false;
104
        return null != PluginPropertyUtils.getPluginVersion( nbMaven.getMavenProject(), groupId, artifactId );
105
    }
89
106
90
        return null != PluginPropertyUtils.getPluginVersion( nbMaven.getMavenProject(), 
107
    private void createProvider( Lookup lkp ) {
91
                AbstractCustomizerPanel.MAVEN_GROUP_ID,
108
        if( null == theProvider ) {
92
                AbstractCustomizerPanel.MAVEN_ARTIFACT_ID );
109
            theProvider = ( MavenCategoryProvider) args.get( "categoryProvider" );
110
            theProvider.setPluginParameters( MavenPluginParameters.create( lkp, getGroupId(), getArtifactId()));
93
    }
111
    }
94
}
112
}
113
114
    private String getGroupId() {
115
        return (String) args.get( "groupId" ); //NOI18N
116
    }
117
118
    private String getArtifactId() {
119
        return (String) args.get( "artifactId" ); //NOI18N
120
    }
121
}

Return to bug 233079