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 229192 - nbactions.xml actions not active in non-default profiles
Summary: nbactions.xml actions not active in non-default profiles
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.3
Hardware: PC Linux
: P2 normal (vote)
Assignee: Jaroslav Tulach
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-30 07:32 UTC by Jaroslav Tulach
Modified: 2014-07-23 02:09 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Support for <profiles> section in nbactions.xml (31.46 KB, patch)
2014-07-15 09:48 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 2013-04-30 07:32:17 UTC
In NetBeans 7.3 I tried to create a pom.xml with multiple profiles and then associate "Run Project" action with set of goals (same in all profiles). Looks like having nbactions.xml with:

+    <action>
+        <actionName>run</actionName>
+        <goals>
+            <goal>process-classes</goal>
+            <goal>bck2brwsr:brwsr</goal>
+        </goals>
+    </action>

is not enough. The "Run Project" then works on default configuration, but not on any other.
Comment 1 Jaroslav Tulach 2013-04-30 07:39:12 UTC
I managed to work around the problem by tripplicating the configuration:
https://java.net/projects/html/sources/87451/diff//?rev1=1&rev2=2
Thus lowering priority. Still, it would be more effective if nbactions.xml was inherited into all configurations. 

Possibly, following enhancement would be even better. Just a single nbactions.xml with "activeProfile(s)" element(s):

<action>
  <actionName>run</actionName>
  <goals>
     <goal>process-classes</goal>
     <goal>bck2brwsr:brwsr</goal>
   </goals>

   <activeProfile>*</activeProfile>
</action>
<action>
  <actionName>debug</actionName>
  <goals>
     <goal>process-classes</goal>
     <goal>bck2brwsr:brwsr</goal>
   </goals>
   <properties>...</properties>

   <activeProfile>fxbrwsr</activeProfile>
   <activeProfile>default</activeProfile>
</action>

Just an thought...
Comment 2 Jaroslav Tulach 2014-07-15 09:43:08 UTC
I need this to address https://java.net/bugzilla/show_bug.cgi?id=6150

Probably better it would be to mimic the profile syntax from settings.xml and pom.xml. Here is an example:

<?xml version="1.0" encoding="UTF-8"?>
<actions>
    <action>
        <actionName>run</actionName>
        <goals>
            <goal>process-classes</goal>
            <goal>exec:java</goal>
        </goals>
    </action>
    <profiles>
        <profile>
            <id>bck2brwsr</id>
            <actions>
                <action>
                    <actionName>run</actionName>
                    <displayName>Run in a Browser</displayName>
                    <goals>
                        <goal>clean</goal>
                        <goal>package</goal>
                        <goal>bck2brwsr:show</goal>
                    </goals>
                    <activatedProfiles>
                        <activatedProfile>bck2brwsr</activatedProfile>
                    </activatedProfiles>
                    <properties>
                        <skipTests>true</skipTests>
                     </properties>
                </action>
            </actions>
        </profile>
    </profiles>
</actions>

I'll attach a patch. Can we integrate the change for NetBeans 8.0.1?
Comment 3 Jaroslav Tulach 2014-07-15 09:48:34 UTC
Created attachment 148060 [details]
Support for <profiles> section in nbactions.xml

I tried as much as I could to not change the API in the *.api.* packages.
Comment 4 Tomas Stupka 2014-07-15 15:16:45 UTC
(In reply to Jaroslav Tulach from comment #3)
> Created attachment 148060 [details]
> Support for <profiles> section in nbactions.xml
> 
> I tried as much as I could to not change the API in the *.api.* packages.
ok
Comment 5 Jaroslav Tulach 2014-07-15 17:23:29 UTC
changeset:   5323d799eef3
tag:         tip
user:        Jaroslav Tulach <jtulach@netbeans.org>
date:        Tue Jul 15 19:21:12 2014 +0200
summary:     #229192: Documenting the introduction of profiles

changeset:   39761cbe2787
user:        Jaroslav Tulach <jtulach@netbeans.org>
date:        Tue Jul 15 17:13:49 2014 +0200
summary:     #229192: Supporting different profiles in a single nbactions.xml
Comment 6 Milos Kleint 2014-07-17 09:15:24 UTC
just a few comments:

I lived under impression that nbactions.xml mapping is used if nbactions-profileX.xml doesn't exist. Maybe that got broken lately (or I'm hallucinating, both is possible). 

how will the added code changes interact with the UI customizer panel edits? This appears to be a backend only change for projects which edit the nbactions.xml file manually?

In general I don't follow how introducing <profiles> from Comment 2 improves the situation in anything but number of files. You still appear to require 1 definition per profile without any inheritance or delegation. 

Additionally there is a terminology confusion here, actions don't work per "profile" id, but per "configuration" id. For maven profiles we dynamically create configuration instance with profile.id == configuration.id, but users can define custom persisted configurations typically to enable multiple profiles at the same time and to add properties next to profiles. 
Additionally the single action mapping already contains <<activatedProfiles> element (that enables profiles for that given configuration-action combo only.

a rewrite for action mapping subsystem is long overdue (my fault) but I'm not sure if this is a correct long term approach to tackle the problem.
Comment 7 Quality Engineering 2014-07-18 01:52:39 UTC
Integrated into 'main-silver', will be available in build *201407180001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/39761cbe2787
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #229192: Supporting different profiles in a single nbactions.xml
Comment 8 Quality Engineering 2014-07-23 02:09:23 UTC
Integrated into 'main-silver', will be available in build *201407230001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/89ce8aec1248
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: Refinement to #229192: fallback to main list of actions