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 52691

Summary: Better heuristics for detecting targets
Product: projects Reporter: _ tboudreau <tboudreau>
Component: Ant FreeformAssignee: David Konecny <dkonecny>
Status: RESOLVED FIXED    
Severity: blocker CC: apireviews, dkonecny
Priority: P2 Keywords: API, API_REVIEW_FAST
Version: 4.x   
Hardware: All   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: proposed API change

Description _ tboudreau 2004-12-20 18:33:11 UTC
For my Javapolis preso, it actually took considerable work to 
locate a project which worked really well with Project With 
Existing Ant Script - that is, the wizard would find all the targets 
with no problems.  JEdit turned out to the be the best bet.

A few minor improvements to the search heuristics could help 
this make a great first impression for a wider variety of projects 
(and this is an important first impression to make - this is 
feature is a "delighter").  Suggestions:

If no "build" target, check for "compile" target
If no "compile" target, check for "[xxx].jar" target
(optional: look for things that call javac and if only one use that?)

If no "javadoc" target check for "javadocs", "docs", "doc", 
optionally anything that invokes the javadoc task... 


A quick survey of a few open source projects would probably 
suffice to find the most common patterns for target naming and 
make sure they work well.
Comment 1 Jesse Glick 2004-12-20 20:45:35 UTC
Implemented in TargetMappingPanel - currently just looks for Ant
target names exactly matching IDE command name, which is not enough.

BTW we may need to make an API change to support this well - the
constructor for TargetDescriptor
(org.netbeans.modules.ant.freeform.spi) only permits one String
defaultTarget, but it should probably be a list of regular expressions
matching likely targets, or something like that.
Comment 2 David Konecny 2005-01-07 14:11:12 UTC
Created attachment 19548 [details]
proposed API change
Comment 3 David Konecny 2005-01-07 14:19:32 UTC
This is trivial change in not yet released API and therefore I would
like to do incompatible change and fix all clients. This is friend API
and so I know all the clients.

The change is in TargetDescriptor which attribute will be changed from
String (name of Ant target to which IDE action usually maps) to List
of regular expressions.

Thanks for review.
Comment 4 Jesse Glick 2005-01-07 15:00:01 UTC
I guess that's a List<String>? Or List<Pattern>?
Comment 5 David Konecny 2005-01-07 16:47:39 UTC
List<String>. I will add the comment to signature.

Or do you think it should be Pattern? It would be more efficient but
on the other hand performance is not concern here and String is
simpler for clients.
Comment 6 David Konecny 2005-01-17 21:37:01 UTC
Neccessary API change finished. Initial list of regular expressions is:

build = "build", "compile", "jar", "dist", "all", ".*jar.*"

clean = "clean", ".*clean.*"

javadoc = "javadoc", "javadocs", "docs", "doc", ".*javadoc.*", ".*doc.*"

run = "run", "start", ".*run.*", ".*start.*"

test = "test", ".*test.*"

debug = "debug", ".*debug.*"

Can be easily extended/changed. Tested on couple of foreign Ant
projects and work way better.

Fill free to suggest other expressions or directly fix it in
ant/freeform/src/org/netbeans/modules/ant/freeform/ui/TargetMappingPanel.java

Fixed in:
Checking in ant/freeform/manifest.mf;
new revision: 1.7; previous revision: 1.6
Checking in
ant/freeform/src/org/netbeans/modules/ant/freeform/spi/TargetDescriptor.java;
new revision: 1.3; previous revision: 1.2
Checking in
ant/freeform/src/org/netbeans/modules/ant/freeform/ui/TargetMappingPanel.java;
new revision: 1.29; previous revision: 1.28
Checking in java/freeform/nbproject/project.xml;
new revision: 1.5; previous revision: 1.4
Checking in web/freeform/nbproject/project.xml;
new revision: 1.5; previous revision: 1.4
Checking in
web/freeform/src/org/netbeans/modules/web/freeform/WebProjectNature.java;
new revision: 1.4; previous revision: 1.3
Checking in j2ee/ejbfreeform/nbproject/project.xml;
new revision: 1.6; previous revision: 1.5
Checking in
j2ee/ejbfreeform/src/org/netbeans/modules/j2ee/ejbfreeform/EJBProjectNature.java;
new revision: 1.6; previous revision: 1.5
Comment 7 Martin Adamek 2005-01-27 15:04:01 UTC
*** Issue 53540 has been marked as a duplicate of this issue. ***