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.

Bug 268677 - Declarative support for creating projects from Archetypes
Summary: Declarative support for creating projects from Archetypes
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: Dev
Hardware: PC Linux
: P3 normal (vote)
Assignee: Jaroslav Tulach
URL:
Keywords: API_REVIEW_FAST
Depends on:
Blocks:
 
Reported: 2016-10-25 13:24 UTC by Jaroslav Tulach
Modified: 2016-11-06 02:49 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Initial sketch of how the support could work (30.42 KB, patch)
2016-10-25 13:33 UTC, Jaroslav Tulach
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jaroslav Tulach 2016-10-25 13:24:31 UTC
I'd like to simplify and enhance the co-operation between NetBeans and Maven archetypes. I'd like to create a system where one can declaratively describe a project template (consisting of a reference to Maven archetype and a UI to configure it) and register it in the IDE. No (or minimum) of Java code required to do so.

There already is [@TemplateRegistration](http://bits.netbeans.org/8.1/javadoc/org-netbeans-api-templates/org/netbeans/api/templates/TemplateRegistration.html) which supports declarative (via HTML) UI. However as of 8.2 it works only for file based templates - I'd like to enhance it to work with project templates as well.
Comment 1 Jaroslav Tulach 2016-10-25 13:33:23 UTC
Created attachment 162627 [details]
Initial sketch of how the support could work

I am trying to change the existing HTML UI Wizard to use the new FileBuilder API instead of direct DataObject.createFromTemplate - Sváťo, I hope that is move towards right direction.


The Maven project implements CreateFromTemplateHandler which recognizes property like files with extension ".archetype" that contain information like artifactId, groupId, version of the archetype and when instantiated they use "mvn" to create the project. Tomáši, is it OK approach?

I suffer writing tests. I am not sure if anyone tried to test instantiation of a maven archetype in a unit test. There are tons of problematic dependencies.
Comment 2 Tomas Stupka 2016-10-25 16:53:22 UTC
> The Maven project implements CreateFromTemplateHandler which recognizes property like files with extension ".archetype" 
> that contain information like artifactId, groupId, version of the archetype 
> and when instantiated they use "mvn" to create the project. Tomáši, is it OK approach?
no objections

> I suffer writing tests. I am not sure if anyone tried to test instantiation of a maven archetype in a unit test. There are tons of problematic dependencies.
hm, when run from tests inputouput returns IOProvider.TrivialOW which runs into stactraceoverflow and mavenExecutor can't determine the maven executable home dir properly ...
invoking via NbModuleSuite.createConfiguration(...) isn't an option?
Comment 3 Jaroslav Tulach 2016-10-25 19:20:39 UTC
(In reply to Tomas Stupka from comment #2)
> hm, when run from tests inputouput returns IOProvider.TrivialOW which runs
> into stactraceoverflow and mavenExecutor can't determine the maven
> executable home dir properly ...
> invoking via NbModuleSuite.createConfiguration(...) isn't an option?

I tried it, but then the layer generated by the test isn't found and maybe there were other problems. In the current version I replaced it with MockExecuteMaven, where I can just simulate what real Maven would do.
Comment 4 Jaroslav Tulach 2016-10-25 20:14:02 UTC
Cleaned-up version that contains simple test that mocks the call into "mvn archetype":

http://hg.netbeans.org/ergonomics/rev/76d9cafcee35
Comment 5 Jaroslav Tulach 2016-10-26 19:28:49 UTC
Here is the documentation for the "UI for Maven Archetype" feature:
http://hg.netbeans.org/ergonomics/rev/ae57f97b7285
Comment 6 Jaroslav Tulach 2016-10-31 15:59:32 UTC
Here is a bit more test coverage: https://hg.netbeans.org/ergonomics/rev/580eb081e506

Unless there are objections, I will merge tomorrow.
Comment 7 Jaroslav Tulach 2016-11-01 05:50:15 UTC
Merged as http://hg.netbeans.org/ergonomics/rev/dc9f6a45afa9
Comment 8 Quality Engineering 2016-11-02 03:04:20 UTC
Integrated into 'main-silver', will be available in build *201611020002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/76d9cafcee35
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #268677: Recognizing .archetype template files and using them to instantiate projects via mvn archetype
Comment 9 Quality Engineering 2016-11-06 02:49:39 UTC
Integrated into 'main-silver', will be available in build *201611060001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/34963a717456
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #268677: Fixing broken link reference and adding apichanges note about the new Maven Archetype UI