JaroslavTulach commented on a change in pull request #2948:
URL: https://github.com/apache/netbeans/pull/2948#discussion_r634025457



##########
File path: 
enterprise/micronaut/src/org/netbeans/modules/micronaut/resources/layer.xml
##########
@@ -30,4 +30,17 @@
             </folder>
         </folder>
     </folder>
+    <folder name="Projects">
+        <folder name="org-netbeans-modules-maven">
+            <folder name="io.micronaut.build:micronaut-maven-plugin">
+                <folder name="Lookup">
+                    <file name="maven-project-actions.instance">
+                        <attr name="instanceOf" 
stringvalue="org.netbeans.spi.project.LookupProvider"/>
+                        <attr name="instanceCreate" 
methodvalue="org.netbeans.api.maven.MavenActions.forProjectLayer"/>
+                        <attr name="resource" 
stringvalue="nbres:/org/netbeans/modules/micronaut/resources/micronaut-actions.xml"/>

Review comment:
       Consider replacing this XML snippet with an annotation in the future.

##########
File path: 
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchDelegate.java
##########
@@ -172,13 +173,35 @@ public void progressHandleCreated(ProgressOperationEvent 
e) {
                         testProgressHandler != null ? Lookups.fixed(toRun, 
ioContext, progress, testProgressHandler) : Lookups.fixed(toRun, ioContext, 
progress),
                         Lookup.getDefault()
                 );
-
+                
+                ProjectConfiguration selectConfiguration = null;
+                Object o = launchArguments.get("launchConfiguration");
+                if (o instanceof String) {
+                    Project p = FileOwnerQuery.getOwner(toRun);
+                    if (p != null) {
+                        ProjectConfigurationProvider<ProjectConfiguration> pcp 
= p.getLookup().lookup(ProjectConfigurationProvider.class);
+                        if (pcp != null) {
+                            String n = (String)o;
+                            selectConfiguration = 
pcp.getConfigurations().stream().filter(c -> 
n.equals(c.getDisplayName())).findAny().orElse(null);

Review comment:
       Fine.

##########
File path: java/api.maven/src/org/netbeans/api/maven/MavenActions.java
##########
@@ -0,0 +1,82 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.api.maven;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.netbeans.api.project.Project;
+import org.netbeans.spi.project.LookupProvider;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.URLMapper;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.netbeans.modules.maven.spi.actions.AbstractMavenActionsProvider;
+
+/**
+ * APIs related to actions over the Maven project.
+ * <p>
+ * A API allows to <b>declaratively register actions</b> using project's 
Lookup. Action descriptions
+ * must be provided in {@code nbactions.xml} format and referenced from the 
Layer XML using URL (i.e. nbres: protocol).
+ * The {@code nbactions.xml} may contain descriptors of actions and even 
<b>profiles</b> which will be turned into
+ * {@link ProjectConfiguration}s. Actions in profiles may override the default 
action mappings, or supply completely new
+ * actions.
+ * <p/>
+ * <div class="nonnormative">
+ * This example shows how to declare actions in a modules' layer, and register 
actions when <code>org.netbeans.modules.maven:test.plugin</code>
+ * plugin is used by the maven project:
+ * {@codesnippet LayerActionsRegistration}

Review comment:
       Amazing usage of `@codesnippet`!

##########
File path: ide/projectapi/src/org/netbeans/spi/project/ActionProvider.java
##########
@@ -30,6 +30,9 @@
  * lookup does not enable the action for a given command on the selected file 
then
  * the first implementation found in default lookup that is enabled will be 
used.
  * </p>
+ * If the project supports {@link ProjectConfiguration}s, the ActionProvider 
implementation 
+ * must check {@link ProjectConfiguration} presence in the action's context 
Lookup whether the caller
+ * requested a specific configuration, and use it to process the requested 
action, if found.

Review comment:
       +1

##########
File path: java/maven/apichanges.xml
##########
@@ -83,6 +83,20 @@ is the proper place.
     <!-- ACTUAL CHANGES BEGIN HERE: -->
 
     <changes>
+        <change id="plugin-lookup">
+            <api name="general"/>
+            <summary>Plugin-dependent Lookup</summary>
+            <version major="2" minor="148"/>
+            <date day="15" month="5" year="2021"/>
+            <author login="sdedic"/>
+            <compatibility addition="yes" semantic="compatible"/>
+            <description>
+                <p>
+                    Services can be registered not also for a specific 
<i>maven plugin</i>

Review comment:
       "not also"? Did you want to write "now"? If so, then: _Register services 
for a specific ..._

##########
File path: 
java/java.lsp.server/src/org/netbeans/modules/java/lsp/server/debugging/launch/NbLaunchDelegate.java
##########
@@ -172,13 +173,35 @@ public void progressHandleCreated(ProgressOperationEvent 
e) {
                         testProgressHandler != null ? Lookups.fixed(toRun, 
ioContext, progress, testProgressHandler) : Lookups.fixed(toRun, ioContext, 
progress),
                         Lookup.getDefault()
                 );
-
+                
+                ProjectConfiguration selectConfiguration = null;
+                Object o = launchArguments.get("launchConfiguration");
+                if (o instanceof String) {
+                    Project p = FileOwnerQuery.getOwner(toRun);
+                    if (p != null) {
+                        ProjectConfigurationProvider<ProjectConfiguration> pcp 
= p.getLookup().lookup(ProjectConfigurationProvider.class);
+                        if (pcp != null) {
+                            String n = (String)o;
+                            selectConfiguration = 
pcp.getConfigurations().stream().filter(c -> 
n.equals(c.getDisplayName())).findAny().orElse(null);
+                        }
+                    }
+                }
+                List<? super Object> runContext = new ArrayList<>();
+                runContext.add(toRun);
+                runContext.add(params);
+                runContext.add(ioContext);
+                runContext.add(progress);
+                
                 Lookup lookup;
                 if (singleMethod != null) {
-                    lookup = Lookups.fixed(toRun, singleMethod, params, 
ioContext, progress);
-                } else {
-                    lookup = Lookups.fixed(toRun, ioContext, params, progress);
+                    runContext.add(singleMethod);
+                }
+                if (selectConfiguration != null) {
+                    runContext.add(selectConfiguration);

Review comment:
       Simpler than previous version with cloning, I'd say.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to