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.
Created attachment 99350 [details] screent1.png: IDE Variables are working with predefined actions like "Build". When having a maven project in NB6.8, IDE Variables (http://wiki.netbeans.org/IDEVariables) can be used with default actions like "build" oder "clean and build". One can make use of a default action (i.e. "Build") specify a maven property (i.e. "mas.home") and pass the content of the IDE variable (i.e. "MAS_HOME" -> "C:\Test") to it (see screen1.png attachment). This works quite well. The property "mas.home" cann then be used in the Maven pom.xml file ... But when one want to use the variable in the same way with a custom action, the content of the maven property will be "${IDE_VARIABLE_NAME}". In this example: "${MAS_HOME}" instead of "C:\Test" (see screen2.png attachment) Expected behavior: The IDE Variables can be used with the predefined actions, as well as with custom actions.
Created attachment 99351 [details] screent2.png: IDE Variables are NOT working with custom actions
Tested NetBeans IDE 6.9 Beta (Build 201004200117)... Same issue here. IDE Variables are not working with custom actions ....
Ah, forgot to mention: Is seems to be OS independant. Tested with Win7 64bit + JDK1.6.0_18 32bit as well as with Ubuntu 10.04 64bit with JDK 1.6.0_20 64bit
Reassigning.
Am I allowed to set the target milestone, or is someone else setting it? Of course I want to have the issues fixed as soon as possible :-)
The assignee sets the target milestone when evaluating the issue. Of course we would like to have bugs fixed as soon as possible, but there is quite a backlog of Maven-related bugs. If you feel comfortable playing with NetBeans source code, a patch for the issue (including a unit test if possible) would make a quick fix much more likely.
Hehe. If someone could point me to the place/sub-project I will. I already downloaded the source. But it's too much for a NB source beginner like to to find the entry point ...
Somewhere under maven/src I think.
Tried a 2nd time to get some details about this issue with help of NB sourcecode... I found out, that in Project "maven" in package "org.netbeans.modules.maven" in class "ActionProviderImpl", the default goals get the IDE variables in method "public void invokeAction(final String action, final Lookup lookup)". There's a lookup for "ReplaceTokenProvider" which brings all replacement-stuff: ---- Collection<? extends ReplaceTokenProvider> replacers = project.getLookup().lookupAll(ReplaceTokenProvider.class); HashMap<String, String> replacements = new HashMap<String, String>(); for (ReplaceTokenProvider prov : replacers) { replacements.putAll(prov.createReplacements(convertedAction, lookup)); } Lookup enhanced = new ProxyLookup(lookup, Lookups.fixed(replacements)); RunConfig rc = ActionToGoalUtils.createRunConfig(convertedAction, project, enhanced); if (rc == null) { Logger.getLogger(ActionProviderImpl.class.getName()).log(Level.INFO, "No handling for action: {0}. Ignoring.", action); //NOI18N } else { if (rc instanceof BeanRunConfig) { BeanRunConfig brc = (BeanRunConfig)rc; if (brc.getPreExecutionActionName() != null) { RunConfig rc2 = ActionToGoalUtils.createRunConfig(brc.getPreExecutionActionName(), project, enhanced); if (rc2 != null) { brc.setPreExecution(rc2); } } } setupTaskName(action, rc, lookup); runGoal(rc, true); } ---- As far as I understood, the "replacements" variable contains all keys with their related replacements. The replacements then somehow get into the runconfig via another lookup-call via a "proxy" ?! I had a look at the custom goals. There the behevior is different. The class same class contains a inner class called "CustomAction". In the "actionPerformedMethod" the runconfig is created and passed to method "runGoal". ---- private final class CustomAction extends AbstractAction { private NetbeansActionMapping mapping; private boolean showUI; private CustomAction(String name, NetbeansActionMapping mapp, boolean showUI) { mapping = mapp; putValue(Action.NAME, name); this.showUI = showUI; } @Override public void actionPerformed(java.awt.event.ActionEvent e) { if (!showUI) { ModelRunConfig rc = new ModelRunConfig(project, mapping, mapping.getActionName(), null); rc.setShowDebug(MavenSettings.getDefault().isShowDebug()); rc.setTaskDisplayName(NbBundle.getMessage(ActionProviderImpl.class, "TXT_Build")); setupTaskName("custom", rc, Lookup.EMPTY); //NOI18N runGoal(rc, true); //NOI18N return; } RunGoalsPanel pnl = new RunGoalsPanel(); . . . . ---- If I'm right, one should get the replacements here and modify the "NetbeansActionMapping" variable instance called "mapping" accordingly. I opened the "maven" project and set the checkmark for opening all required projects. But I still have errors in nearly all of the related projects (most of them are about junit etc.?!). So I'm currently not able to do some tests. But maybe my findings can help fixing this issue...
(In reply to comment #9) > I opened the "maven" project and set the checkmark for opening all required > projects. You do not need to open required projects. There will be a lot of them, mostly irrelevant to this issue. > But I still have errors in nearly all of the related projects (most > of them are about junit etc.?!). Try: ant -Dcluster.config=java to build the IDE, which will ensure that external libraries are downloaded etc.
Created attachment 100288 [details] Patch that adds IDE Variable support to custom NB Maven goals Apply to file maven/src/org/netbeans/modules/maven/ActionProviderImpl.java
Yeeha ... Finally I got it working. I compiled the complete project via console and opened the Maven project with NB. I still got errors about JUnit etc. But I was able to test my modification with "run" from project's context menu. I'm not sure how to integrate a unit test for this, as the IDE Variable is coming from a live installation. Either the fix is small enough so that no unit test is needed, or you give me again a hint on how to integrate such a test.
Would be great if someone can can give a comment/feedback for the patch I provided 5 weeks ago...
Can confirm bug, will test patch.
Thanks a lot ...
Actually using a somewhat more general patch, after some investigation.
core-main #b36a1110da98
Integrated into 'main-golden', will be available in build *201007300001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main/rev/b36a1110da98 User: Jesse Glick <jglick@netbeans.org> Log: #186552: IDE Variables are not working with maven project + custom actions