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 49646 - Need ability to create project templates without writing code
Summary: Need ability to create project templates without writing code
Status: RESOLVED WONTFIX
Alias: None
Product: projects
Classification: Unclassified
Component: Generic Infrastructure (show other bugs)
Version: 4.x
Hardware: All All
: P2 blocker with 1 vote (vote)
Assignee: Milos Kleint
URL:
Keywords:
: 59515 (view as bug list)
Depends on:
Blocks: 41535
  Show dependency tree
 
Reported: 2004-09-28 17:58 UTC by Jesse Glick
Modified: 2008-11-12 15:49 UTC (History)
5 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2004-09-28 17:58:17 UTC
Should be able to make templates for various
project types without writing a module: create
proj dir, initial metadata files, maybe initial
sources. Maybe permit macro substitutions or
something.

Later could add a GUI to manage them, but
initially just something a power user could do
after reading a how-to.
Comment 1 herkules 2004-10-04 13:42:31 UTC
Yes, please do so! 

Here's my use-case:

Our coding style requires that the Java source directory is called
'java' and not 'src'. This small glitch prevents me from creating new
projects with NetBeans. If I had a wish for free - our build.xml is
located in a separate directory 'etc', with ${basedir}==..

etc
-- build.xml
java
-- foo.bar....
test
-- test.foo.bar...


Could also solve issues like
http://www.netbeans.org/issues/show_bug.cgi?id=49780
Comment 2 Jesse Glick 2004-10-04 16:27:38 UTC
Of course you *can* create projects with sources in java/ using NB,
but you would need to manually clean up the layout (and
project.properties) on disk.

Currently we do not support placing build.xml in a subdirectory for
j2seproject's. I don't think we ever will. You can however do so for
freeform projects. As a rule, j2seproject's (or other fixed-form
project types) make some simplifying assumptions about the user's
project structure that allow the IDE to do more of the work setting
things up, while freeform projects permit a much broader set of
project layouts for those users who have a predefined project style
they want to adhere to.

BTW Joerg: when adding comments to an issue, generally you want to add
yourself to the CC list, or you will never see any responses.
Comment 3 Rich Unger 2005-01-25 02:09:17 UTC
I did something like this for sample projects distributed with
vbuilder.  Each sample comes as a module with a layer entry:

    <folder name="Templates">
        <folder name="Project">
            <folder name="Samples">
                <folder name="Speech">
                    <file name="banking.zip" url="banking.zip">
                        <attr name="template" boolvalue="true"/>
                        <attr name="instantiatingWizardURL"
urlvalue="nbresloc:/com/nuance/tools/samples/banking/resources/templateDoc.html"/>
                        <attr name="SystemFileSystem.localizingBundle"
stringvalue="com.nuance.tools.samples.banking.resources.Bundle"/>
                        <attr name="SystemFileSystem.icon"
urlvalue="nbresloc:/com/nuance/tools/samples/resources/projectTreeIcon.gif"/>
                        <attr name="instantiatingIterator"
newvalue="com.nuance.tools.samples.SampleProjectIterator"/>
                    </file>
                </folder>
            </folder>
        </folder>
    </folder>

and the implementation of SampleProjectIterator is just a single panel
for selecting the directory to unzip banking.zip into.  The unzipping
is done in instantiate() (after checking to make sure there isn't
already a project there by that name).

My implementation is too specific to my project type, but you get the
idea...
Comment 4 Jesse Glick 2005-06-01 21:02:25 UTC
*** Issue 59515 has been marked as a duplicate of this issue. ***
Comment 5 jessholle 2005-06-01 21:21:20 UTC
See issue 59515 for more extensive comments, but to be brief:

* NetBeans project configuration is very flexible but can have literally
unbounded complexity.
* Very few individuals within an organization will attain the skill to produce
and maintain such projects.
* These individuals need a way to package such project as templates for easy
"end-user" use by everyone else in a development organization.

Things I believe should be included are:
* Ability to declare custom project parameters/properties in the template that
will be presented/queried by the project creation wizard when one creates a
project from the given template.
* Ability to script (as part of the project template) creation of project
artifacts based on normal and custom project parameters/properties (and possibly
recreation/update on redefinition of project parameters via GUI).
  * Artifacts include build.xml, project.xml (e.g. to automate classpaths in
free-form projects), etc...
  * I have used Ant scripts from the command line for this purpose and it has
worked quite well for me.
Comment 6 Jesse Glick 2005-08-29 23:59:51 UTC
In NB 4.2 you will be able to use a wizard from the module development support
to create a module that supplies a project template (of whatever type) as a
subwizard in New Project. You don't have to write any code - a Java class for
the wizard is created for you which can be edited but need not be - but you do
have to make a module project and create an NBM from it etc., which may well be
too intimidating for most IDE users. On the other hand, the NBM thus created
should be easily portable to anyone else's IDE installation and can be managed
using the Module Manager and/or Update Center.

I would not want to provide anything too complex in the intermediate space (i.e.
stopping short of creating a module) because for "interesting" configuration you
are likely to want a GUI wizard anyway, and this really needs to use the IDE's
APIs for displaying wizard panels etc. But something reasonably simple and easy
to learn with some scriptability would be nice.

Jess Holle's idea for binding a template to an Ant target which would create the
project metadata files is intriguing. However it would not on its own deal with
parametrization of the template, except insofar as you can use <input> from the
target to ask the user some questions.
Comment 7 Milos Kleint 2008-10-14 12:51:33 UTC
well, I guess our time is better spent elsewhere. -> wontfix.

Please note that some project management systems like maven provide ways to generate projects from templates (called
archetypes). I suppose people wanting to have netbeans ant project templates could reuse that.
http://maven.apache.org/plugins/maven-archetype-plugin/
Comment 8 Jesse Glick 2008-11-07 03:26:59 UTC
IIRC Geertjan also had some blog posts about using Groovy to generate projects from template.
Comment 9 Geertjan Wielenga 2008-11-12 15:49:58 UTC
Yes, Groovy is perfect for this purpose. See this screencast for details:
http://netbeans.tv/screencasts/Groovy-Makes-Code-Generation-Simple-410/