You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/08/10 19:43:14 UTC

[GitHub] [netbeans] sdedic opened a new pull request, #4495: Support for project output artifacts

sdedic opened a new pull request, #4495:
URL: https://github.com/apache/netbeans/pull/4495

   This PR actually consists of a series of features. I should probably make separate requests for that, but ... that would prolong the review process, I believe.
   
   The overall goal was to add a project query to get the project's output in form of an identifiable artifact(s) and their supposed (not built yet) or existing locations - and expose the analysis result through LSP.
   
   Overview:
   ## ProjectActionContext
   This one I wanted for a long time already. Many project APIs or services are likely to be affected by project configurations - and it's rather hard to invoke the services for a specific configuration, which is not the active one. By default UI works against the active configuration, which is fine, but API access should have an option to specify it.
   Adding configurations to all APIs is hard, and sometimes it is even impossible when the execution goes through some uncooperative layers.; the `ProjectActionContext` is a way how to pass the information 'out of band'.
   
   I needed to pass specifically project action to distinguish different types of build; for example Micronaut plugins (gradle, maven) support a regular build, and a native-image build, that produces different output(s).
   
   Important note for reviewers: while the ProjectActionContext allows to specify a profile or user properties, which can be ignored by the underlying project system, and give almost complete control over project model evaluation to the caller (at least for gradle and maven), I am not 100% sure if the properties + profiles is a good idea. A conservative approach would be to insist on creating a `ProjectConfiguration` for the profile+properties setup and use that.
   
   Reviewers, share your opinion on this; these ProjectActionContext properties could be eventually added (compatibly) later.
   
   ## ProjectArtifactsQuery
   this is a project query as usual, asking for project output with GAV coordinates (if applicable). I am almost sure the `ArtifactSpec` will satisfy PHP, too ... but I still keep it private until Gradle implementation is complete.
   
   The `Filter` specification does not cover all query cases, but works for the basic ones. When one wants "any output" and a specific output type / classifier.
   
   ## Micronaut support for native image build
   Added a project action and project action mapping for Maven to execute native-image build of the micronaut app. The action becomes available (and is configurable in project customizer) when one adds Micronaut plugin to the maven project build configuration.
   
   ## Maven fixes
   During implementation I've realized that the native-build action, contributed to the Maven by `MavenActionsProvider` is not visible in the customizer. I was little shocked when I realized that the customizer essentially hardcodes the list of (standard) actions and only displays user-defined ones in addition to the hardcoded list. I've corrected the behaviour of `M2Configuration` in that it lists just config-specific mappings, the others are retrieved through `ActionToGoalUtils`.
   I've also realized that the declarative actions lack proper support for I18N; so I've added a convenience lookup in ` Bundle.proeprties` using the action's (profile's) id, and in additiona specifying `displayName` that starts with '#' also makes a lookup, with the possbility to identify the Bundle path as well.
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] lkishalmi commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
lkishalmi commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r943803850


##########
ide/projectapi/src/org/netbeans/api/project/ProjectActionContext.java:
##########
@@ -0,0 +1,402 @@
+/*
+ * 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.project;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import org.netbeans.api.annotations.common.CheckForNull;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.project.Project;
+import org.netbeans.spi.project.ProjectConfiguration;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+
+/**
+ * This represents context for a project model query. The context describe a project action
+ * for which the query should be evaluated, project configuration (if not the active one), 
+ * and possible custom overrides.
+ * {@link ProjectConfiguration} or the IDE-supported project action and the associated properties, profiles, or Lookup may
+ * affect behaviour of queries across the IDE.
+ * <p>
+ * Properties map to user-settable properties of the build system, such as system properties in Maven
+ * or project properties in Gradle.
+ * <p>
+ * Profiles map to profiles in Maven, but do not have any effect in Gradle at the moment; this might change.
+ * <p>
+ * Instances of {@link ProjectActionContext} may be passed to some queries as (part of the) parameters explicitly. In case
+ * the API does not support such flexibility directly, the implementation(s) may - the context may be published for the
+ * query computation using {@link #apply}; the implementation may then use {@link #find} to obtain a {@link ProjectActionContext}
+ * effective for that project.
+ * <p>
+ * <b>Important note:</b> Not all project queries support {@link ProjectActionContext}. Queries which do should mention that
+ * fact in their documentation, or expose it in their APIs.
+ * 
+ * @author sdedic
+ * @since 1.89
+ */
+public final class ProjectActionContext {
+    private final Project project;
+
+    ProjectActionContext(Project project) {
+        this.project = project;
+    }
+   
+    /**
+     * The project action.
+     */
+    private String projectAction;
+    
+    /**
+     * The desired project configuration
+     */
+    private ProjectConfiguration configuration;
+    private Map<String, String> properties;
+    private Set<String> profiles;
+    private Lookup lookup;
+
+    /**
+     * Returns the project this context applies to. Having {@link Project} as a property allows multiple
+     * contexts, individually for each project, to be active.
+     * @return the target project.
+     */
+    public @NonNull Project getProject() {
+        return project;
+    }
+
+    /**
+     * Additional information for the underlying project implementation, similar to 
+     * context lookup in {@link org.netbeans.spi.project.ActionProvider#invokeAction}.
+     * Null if no specific info is present.
+     * 
+     * @return Lookup with additional information or {@code null}.
+     */
+    public @CheckForNull Lookup getLookup() {
+        return lookup;

Review Comment:
   Can return Lookup.EMPTY



##########
ide/projectapi/src/org/netbeans/api/project/ProjectActionContext.java:
##########
@@ -0,0 +1,402 @@
+/*
+ * 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.project;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import org.netbeans.api.annotations.common.CheckForNull;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.project.Project;
+import org.netbeans.spi.project.ProjectConfiguration;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+
+/**
+ * This represents context for a project model query. The context describe a project action
+ * for which the query should be evaluated, project configuration (if not the active one), 
+ * and possible custom overrides.
+ * {@link ProjectConfiguration} or the IDE-supported project action and the associated properties, profiles, or Lookup may
+ * affect behaviour of queries across the IDE.
+ * <p>
+ * Properties map to user-settable properties of the build system, such as system properties in Maven
+ * or project properties in Gradle.
+ * <p>
+ * Profiles map to profiles in Maven, but do not have any effect in Gradle at the moment; this might change.
+ * <p>
+ * Instances of {@link ProjectActionContext} may be passed to some queries as (part of the) parameters explicitly. In case
+ * the API does not support such flexibility directly, the implementation(s) may - the context may be published for the
+ * query computation using {@link #apply}; the implementation may then use {@link #find} to obtain a {@link ProjectActionContext}
+ * effective for that project.
+ * <p>
+ * <b>Important note:</b> Not all project queries support {@link ProjectActionContext}. Queries which do should mention that
+ * fact in their documentation, or expose it in their APIs.
+ * 
+ * @author sdedic
+ * @since 1.89
+ */
+public final class ProjectActionContext {
+    private final Project project;
+
+    ProjectActionContext(Project project) {
+        this.project = project;
+    }
+   
+    /**
+     * The project action.
+     */
+    private String projectAction;
+    
+    /**
+     * The desired project configuration
+     */
+    private ProjectConfiguration configuration;
+    private Map<String, String> properties;
+    private Set<String> profiles;
+    private Lookup lookup;
+
+    /**
+     * Returns the project this context applies to. Having {@link Project} as a property allows multiple
+     * contexts, individually for each project, to be active.
+     * @return the target project.
+     */
+    public @NonNull Project getProject() {
+        return project;
+    }
+
+    /**
+     * Additional information for the underlying project implementation, similar to 
+     * context lookup in {@link org.netbeans.spi.project.ActionProvider#invokeAction}.
+     * Null if no specific info is present.
+     * 
+     * @return Lookup with additional information or {@code null}.
+     */
+    public @CheckForNull Lookup getLookup() {
+        return lookup;
+    }
+
+    /**
+     * The project action in whose context the project queries are performed. May be
+     * left unspecified, so the implementation can choose an appropriate default behaviour.
+     * 
+     * @return project aciton or {@code null} for unspecified.
+     */
+    public @CheckForNull String getProjectAction() {
+        return projectAction;
+    }
+
+    /**
+     * The project configuration to use for the project query. Can be {@code null} to 
+     * indicate the project's default Configuration should be used.
+     * 
+     * @return the project's configuration or {@code null}.
+     */
+    public @CheckForNull ProjectConfiguration getConfiguration() {
+        return configuration;
+    }
+    
+    /**
+     * User-customized properties that should be effective during the computation. The same
+     * customization should be made during project action execution to obtain the same results as 
+     * evaluated by the query.
+     * 
+     * @return user properties, or {@code null} if unspecified.
+     */
+    public @CheckForNull Map<String, String> getProperties() {
+        return properties == null ? null : Collections.unmodifiableMap(properties);
+    }
+
+    /**
+     * Profiles or some project system features/tags that should be applied for the evaluation.
+     * @return applied profiles or {@code null} if unspecified.
+     */
+    public @CheckForNull Set<String> getProfiles() {
+        return profiles == null ? null : Collections.unmodifiableSet(profiles);

Review Comment:
   Collections.emptySet()



##########
ide/projectapi/src/org/netbeans/api/project/ProjectActionContext.java:
##########
@@ -0,0 +1,402 @@
+/*
+ * 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.project;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import org.netbeans.api.annotations.common.CheckForNull;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.project.Project;
+import org.netbeans.spi.project.ProjectConfiguration;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+
+/**
+ * This represents context for a project model query. The context describe a project action
+ * for which the query should be evaluated, project configuration (if not the active one), 
+ * and possible custom overrides.
+ * {@link ProjectConfiguration} or the IDE-supported project action and the associated properties, profiles, or Lookup may
+ * affect behaviour of queries across the IDE.
+ * <p>
+ * Properties map to user-settable properties of the build system, such as system properties in Maven
+ * or project properties in Gradle.
+ * <p>
+ * Profiles map to profiles in Maven, but do not have any effect in Gradle at the moment; this might change.
+ * <p>
+ * Instances of {@link ProjectActionContext} may be passed to some queries as (part of the) parameters explicitly. In case
+ * the API does not support such flexibility directly, the implementation(s) may - the context may be published for the
+ * query computation using {@link #apply}; the implementation may then use {@link #find} to obtain a {@link ProjectActionContext}
+ * effective for that project.
+ * <p>
+ * <b>Important note:</b> Not all project queries support {@link ProjectActionContext}. Queries which do should mention that
+ * fact in their documentation, or expose it in their APIs.
+ * 
+ * @author sdedic
+ * @since 1.89
+ */
+public final class ProjectActionContext {
+    private final Project project;
+
+    ProjectActionContext(Project project) {
+        this.project = project;
+    }
+   
+    /**
+     * The project action.
+     */
+    private String projectAction;
+    
+    /**
+     * The desired project configuration
+     */
+    private ProjectConfiguration configuration;
+    private Map<String, String> properties;
+    private Set<String> profiles;
+    private Lookup lookup;
+
+    /**
+     * Returns the project this context applies to. Having {@link Project} as a property allows multiple
+     * contexts, individually for each project, to be active.
+     * @return the target project.
+     */
+    public @NonNull Project getProject() {
+        return project;
+    }
+
+    /**
+     * Additional information for the underlying project implementation, similar to 
+     * context lookup in {@link org.netbeans.spi.project.ActionProvider#invokeAction}.
+     * Null if no specific info is present.
+     * 
+     * @return Lookup with additional information or {@code null}.
+     */
+    public @CheckForNull Lookup getLookup() {
+        return lookup;
+    }
+
+    /**
+     * The project action in whose context the project queries are performed. May be
+     * left unspecified, so the implementation can choose an appropriate default behaviour.
+     * 
+     * @return project aciton or {@code null} for unspecified.
+     */
+    public @CheckForNull String getProjectAction() {
+        return projectAction;
+    }
+
+    /**
+     * The project configuration to use for the project query. Can be {@code null} to 
+     * indicate the project's default Configuration should be used.
+     * 
+     * @return the project's configuration or {@code null}.
+     */
+    public @CheckForNull ProjectConfiguration getConfiguration() {
+        return configuration;
+    }
+    
+    /**
+     * User-customized properties that should be effective during the computation. The same
+     * customization should be made during project action execution to obtain the same results as 
+     * evaluated by the query.
+     * 
+     * @return user properties, or {@code null} if unspecified.
+     */
+    public @CheckForNull Map<String, String> getProperties() {
+        return properties == null ? null : Collections.unmodifiableMap(properties);

Review Comment:
   Collections.emtyMap()



##########
ide/projectapi/src/org/netbeans/api/project/ProjectActionContext.java:
##########
@@ -0,0 +1,402 @@
+/*
+ * 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.project;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import org.netbeans.api.annotations.common.CheckForNull;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.project.Project;
+import org.netbeans.spi.project.ProjectConfiguration;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+
+/**
+ * This represents context for a project model query. The context describe a project action
+ * for which the query should be evaluated, project configuration (if not the active one), 
+ * and possible custom overrides.
+ * {@link ProjectConfiguration} or the IDE-supported project action and the associated properties, profiles, or Lookup may
+ * affect behaviour of queries across the IDE.
+ * <p>
+ * Properties map to user-settable properties of the build system, such as system properties in Maven
+ * or project properties in Gradle.
+ * <p>
+ * Profiles map to profiles in Maven, but do not have any effect in Gradle at the moment; this might change.
+ * <p>
+ * Instances of {@link ProjectActionContext} may be passed to some queries as (part of the) parameters explicitly. In case
+ * the API does not support such flexibility directly, the implementation(s) may - the context may be published for the
+ * query computation using {@link #apply}; the implementation may then use {@link #find} to obtain a {@link ProjectActionContext}
+ * effective for that project.
+ * <p>
+ * <b>Important note:</b> Not all project queries support {@link ProjectActionContext}. Queries which do should mention that
+ * fact in their documentation, or expose it in their APIs.
+ * 
+ * @author sdedic
+ * @since 1.89
+ */
+public final class ProjectActionContext {
+    private final Project project;
+
+    ProjectActionContext(Project project) {
+        this.project = project;
+    }
+   
+    /**
+     * The project action.
+     */
+    private String projectAction;
+    
+    /**
+     * The desired project configuration
+     */
+    private ProjectConfiguration configuration;
+    private Map<String, String> properties;
+    private Set<String> profiles;
+    private Lookup lookup;
+
+    /**
+     * Returns the project this context applies to. Having {@link Project} as a property allows multiple
+     * contexts, individually for each project, to be active.
+     * @return the target project.
+     */
+    public @NonNull Project getProject() {

Review Comment:
   There are many possible null returns in this class. That should be avoided unless it brings a meaning.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r945579902


##########
ide/project.dependency/src/org/netbeans/modules/project/dependency/spi/ProjectDependenciesImplementation.java:
##########
@@ -32,16 +29,9 @@
  * @author sdedic
  */
 public interface ProjectDependenciesImplementation {

Review Comment:
   This "API" was never published, even as a friend.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r948054474


##########
ide/projectapi/src/org/netbeans/api/project/ProjectUtils.java:
##########
@@ -57,6 +61,65 @@ private ProjectUtils() {}
 
     private static final Logger LOG = Logger.getLogger(ProjectUtils.class.getName());
     
+    /**
+     * Returns the active configuration for the given project. Returns {@code null},
+     * if the project does not support configurations at all.
+     * 
+     * @param p the project
+     * @return the active configuration, or {@code null} if configurations are not supported.
+     * @since 1.89
+     */
+    public ProjectConfiguration getActiveConfiguration(@NonNull Project p) {
+        ProjectConfigurationProvider pcp = p.getLookup().lookup(ProjectConfigurationProvider.class);
+        if (pcp == null) {
+            return null;
+        }
+        return ProjectManager.mutex().readAccess(() -> pcp.getActiveConfiguration());
+    }
+    
+    /**
+     * Sets the active configuration to a project. The configuration should have been previously obtained by 
+     * {@link #getActiveConfiguration(org.netbeans.api.project.Project)} from the same project. The method
+     * returns {@code false}, if the configuration could not be set: if the project does not support configurations
+     * at all, or the project failed to switch the configurations. Since the active configuration setting is persisted,
+     * the method throws {@link IOException} if the setting save fails.
+     * 
+     * @param <C> configuration type
+     * @param p the project
+     * @param cfg configuration or {@code null} for default configuration.
+     * @return true, if the configuration was successfully set.
+     * @throws IOException when the selected configuration cannot be persisted.
+     * @since 1.89
+     */
+    public <C extends ProjectConfiguration> boolean setActiveConfiguration(@NonNull Project p, @NonNull C cfg) throws IOException {

Review Comment:
   The project API itself is using generics ... (?)



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic merged pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
sdedic merged PR #4495:
URL: https://github.com/apache/netbeans/pull/4495


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r945582178


##########
java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/commands/ProjectMetadataCommand.java:
##########
@@ -0,0 +1,180 @@
+/*
+ * 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.modules.nbcode.integration.commands;
+
+import com.google.gson.ExclusionStrategy;
+import com.google.gson.FieldAttributes;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.TypeAdapter;
+import com.google.gson.TypeAdapterFactory;
+import com.google.gson.reflect.TypeToken;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonToken;
+import com.google.gson.stream.JsonWriter;
+import java.io.IOException;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import org.eclipse.lsp4j.CodeAction;
+import org.eclipse.lsp4j.CodeActionParams;
+import org.netbeans.api.project.FileOwnerQuery;
+import org.netbeans.api.project.Project;
+import org.netbeans.api.project.ProjectActionContext;
+import org.netbeans.modules.java.lsp.server.protocol.CodeActionsProvider;
+import org.netbeans.modules.java.lsp.server.protocol.NbCodeLanguageClient;
+import org.netbeans.modules.parsing.api.ResultIterator;
+import org.netbeans.modules.project.dependency.ArtifactSpec;
+import org.netbeans.modules.project.dependency.ProjectArtifactsQuery;
+import org.netbeans.modules.project.dependency.ProjectArtifactsQuery.ArtifactsResult;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.RequestProcessor;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author sdedic
+ */
+@ServiceProvider(service = CodeActionsProvider.class)
+public class ProjectMetadataCommand extends CodeActionsProvider {
+    private static final String COMMAND_ARTIFACTS = "nbls.gcn.project.artifacts"; // NOI18N
+
+    private static final Set<String> COMMANDS = new HashSet<>(Arrays.asList(
+            COMMAND_ARTIFACTS
+    ));
+    private static final Set<String> ARTIFACT_BLOCK_FIELDS = new HashSet<>(Arrays.asList(
+        "data" // NOI18N
+    ));
+    
+    private static final RequestProcessor METADATA_PROCESSOR = new RequestProcessor(ProjectMetadataCommand.class);
+    
+    private final Gson gson;
+    
+    public ProjectMetadataCommand() {
+        gson = new GsonBuilder()
+             // block the opaque 'data' field 
+            .addSerializationExclusionStrategy(new ExclusionStrategy() {
+                    @Override
+                    public boolean shouldSkipField(FieldAttributes fa) {
+                        if (fa.getDeclaringClass() == ArtifactSpec.class) {
+                          return ARTIFACT_BLOCK_FIELDS.contains(fa.getName());
+                        }
+                        return false;
+                    }
+
+                    @Override
+                    public boolean shouldSkipClass(Class<?> type) {
+                        return false;
+                    }
+            })
+            // serialize FileObject as null|path
+            .registerTypeAdapterFactory(new TypeAdapterFactory() {
+                @Override
+                public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> tt) {
+                    if (tt.getRawType() != FileObject.class) {
+                        return null;
+                    }
+                    return new TypeAdapter<T>() {
+                        @Override
+                        public void write(JsonWriter writer, T t) throws IOException {
+                            FileObject f = (FileObject)t;
+                            writer.value(f == null ? null : f.getPath());
+                        }
+
+                        @Override
+                        public T read(JsonReader reader) throws IOException {
+                            if (reader.peek() == JsonToken.NULL) {
+                                reader.nextNull();
+                                return null;
+                            } else {
+                                String s = reader.nextString();
+                                if (s == null) {
+                                    return null;
+                                }
+                                FileObject fo = FileUtil.toFileObject(Paths.get(s).toFile());
+                                return (T)fo;
+                            }
+                        }
+                    };
+                }
+            })
+            .create();
+    }
+    
+    @Override
+    public List<CodeAction> getCodeActions(ResultIterator resultIterator, CodeActionParams params) throws Exception {
+        return Collections.emptyList();
+    }
+
+    @Override
+    public Set<String> getCommands() {
+        return COMMANDS;
+    }
+
+    @Override
+    public CompletableFuture<Object> processCommand(NbCodeLanguageClient client, String command, List<Object> arguments) {
+        if (arguments.size() < 1) {
+            throw new IllegalArgumentException("Expected at least project URI/path");
+        }
+        FileObject f = Utils.extractFileObject(arguments.get(0), gson);
+        Project p = FileOwnerQuery.getOwner(f);
+        if (p == null || p.getProjectDirectory() != f) {
+            throw new IllegalArgumentException("Not a project " + f);
+        }
+        String artifactType = null;
+        ProjectActionContext ctx = null;
+        
+        if (arguments.size() > 1) {
+            // 2nd parameter is the project action
+            Object o = arguments.get(1);
+            if (!(o instanceof JsonPrimitive)) {
+                throw new IllegalArgumentException("String or null expected as parameter #3, got " + o);
+            }
+            ctx = ProjectActionContext.newBuilder(p).forProjectAction(((JsonPrimitive)o).getAsString()).context();
+        }
+        if (arguments.size() > 2) {
+            // 3rd parameter is the type of artifact
+            Object o = arguments.get(2);
+            if (!(o instanceof JsonPrimitive)) {
+                throw new IllegalArgumentException("String or null expected as parameter #2, got " + o);
+            }
+            artifactType = ((JsonPrimitive)o).getAsString();
+        }
+        ProjectArtifactsQuery.Filter filter = ProjectArtifactsQuery.newQuery(artifactType, null, ctx);
+        CompletableFuture result = new CompletableFuture();
+        METADATA_PROCESSOR.post(() -> {
+            try {
+                ArtifactsResult arts = ProjectArtifactsQuery.findArtifacts(p, filter);

Review Comment:
   erm. not just the name, but also the location of the potential output. Yes, it's large, but NetBeans Project APIs themselves lack a description of usual project metadata, some identifier etc. The location of to-be-compiled output could be useful for packaging steps in NB, too.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] ppisl commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
ppisl commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r949140308


##########
ide/project.dependency/src/org/netbeans/modules/project/dependency/ArtifactSpec.java:
##########
@@ -75,17 +86,45 @@ public enum VersionKind {
         this.optional = optional;
         this.data = impl;
         this.type = type;
+        this.location = location;
         this.localFile = localFile;
     }
 
     public T getData() {
         return data;
     }
 
+    /**
+     * Returns local file which the artifact represents. For library (dependencies) artifacts,
+     * the file is the library consumed, e.g. from a local repository. For outputs, the artifact
+     * represents the build output, usually in project's build directory. Note that FileObject for 
+     * a dependency and its corresponding Project may not be the same.
+     * 

Review Comment:
   Probably there should be mentioned, that can return null, if the local file doesn't exist?



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r945582578


##########
java/maven.embedder/nbproject/project.xml:
##########
@@ -182,6 +182,7 @@
                 <friend>io.github.jeddict.runtime</friend>
                 <friend>io.github.jeddict.rest.generator</friend>
                 <!-- XXX <subpackages> not permitted by schema -->
+                <friend>org.netbeans.modules.micronaut</friend>

Review Comment:
   would be gradle+maven micronaut bridge modules more approppriate ?



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r948051871


##########
enterprise/micronaut/nbproject/project.xml:
##########
@@ -68,6 +68,32 @@
                         <specification-version>1.18</specification-version>
                     </run-dependency>
                 </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.maven</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>2</release-version>
+                        <specification-version>2.154</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.project.dependency</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <implementation-version/>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.maven.embedder</code-name-base>

Review Comment:
   Well. I gave a few thoughts to some abstraction, but ... even if I make some declarative support in the layer, the Micronaut will not be entirely indepenent: it would need to provide dual declarations anyway, since maven + gradle identifiers for the native-image plugin differ; so maybe there would not be a formal dependency, but actual yes.
   
   I thought about supporting some 'declarative' query, such as "give me a variable Foo", that would be registered in project type's XML area and translated to plugin-execution-goal-configuration (maven) or extension-property for gradle. But I'd fear that this query need not to satisfy further usecases from different future project-neutral queries: not all data are just variables to be picked up.
   
   I'd better wait with such support after more users appear, but this could be the an abstract way to query project's setup.
   



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r948053456


##########
ide/project.dependency/src/org/netbeans/modules/project/dependency/spi/ProjectArtifactsImplementation.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.modules.project.dependency.spi;
+
+import java.util.Collection;
+import java.util.List;
+import javax.swing.event.ChangeListener;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.project.dependency.ArtifactSpec;
+import org.netbeans.modules.project.dependency.ProjectArtifactsQuery;
+
+/**
+ *
+ * @author sdedic
+ */
+public interface ProjectArtifactsImplementation {
+    /**
+     * Finds project artifact(s) that match the query. 
+     * @param query the query to answer
+     * @param previous result of previous buildsteps
+     * @param all
+     * @return 
+     */
+    public Result findArtifacts(ProjectArtifactsQuery.Filter query);

Review Comment:
   addressed in 70dcb7f24620



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
sdedic commented on PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#issuecomment-1219442588

   One more reviewer / approver would be awesome...


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r947835631


##########
ide/projectapi/src/org/netbeans/api/project/ProjectActionContext.java:
##########
@@ -0,0 +1,402 @@
+/*
+ * 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.project;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import org.netbeans.api.annotations.common.CheckForNull;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.project.Project;
+import org.netbeans.spi.project.ProjectConfiguration;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+
+/**
+ * This represents context for a project model query. The context describe a project action
+ * for which the query should be evaluated, project configuration (if not the active one), 
+ * and possible custom overrides.
+ * {@link ProjectConfiguration} or the IDE-supported project action and the associated properties, profiles, or Lookup may
+ * affect behaviour of queries across the IDE.
+ * <p>
+ * Properties map to user-settable properties of the build system, such as system properties in Maven
+ * or project properties in Gradle.
+ * <p>
+ * Profiles map to profiles in Maven, but do not have any effect in Gradle at the moment; this might change.
+ * <p>
+ * Instances of {@link ProjectActionContext} may be passed to some queries as (part of the) parameters explicitly. In case
+ * the API does not support such flexibility directly, the implementation(s) may - the context may be published for the
+ * query computation using {@link #apply}; the implementation may then use {@link #find} to obtain a {@link ProjectActionContext}
+ * effective for that project.
+ * <p>
+ * <b>Important note:</b> Not all project queries support {@link ProjectActionContext}. Queries which do should mention that
+ * fact in their documentation, or expose it in their APIs.
+ * 
+ * @author sdedic
+ * @since 1.89
+ */
+public final class ProjectActionContext {
+    private final Project project;
+
+    ProjectActionContext(Project project) {
+        this.project = project;
+    }
+   
+    /**
+     * The project action.
+     */
+    private String projectAction;
+    
+    /**
+     * The desired project configuration
+     */
+    private ProjectConfiguration configuration;
+    private Map<String, String> properties;
+    private Set<String> profiles;
+    private Lookup lookup;
+
+    /**
+     * Returns the project this context applies to. Having {@link Project} as a property allows multiple
+     * contexts, individually for each project, to be active.
+     * @return the target project.
+     */
+    public @NonNull Project getProject() {
+        return project;
+    }
+
+    /**
+     * Additional information for the underlying project implementation, similar to 
+     * context lookup in {@link org.netbeans.spi.project.ActionProvider#invokeAction}.
+     * Null if no specific info is present.
+     * 
+     * @return Lookup with additional information or {@code null}.
+     */
+    public @CheckForNull Lookup getLookup() {
+        return lookup;

Review Comment:
   The little trouble is that it is the project implementation that decides which part may potentially affect the project data evaluation ... all stuff except the Lookup can be checked for 'no ops' (empty), the Lookup is ... well, peculiar. Eventually I could document that the exact value `Lookup.EMPTY` may be used for optimizations.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r945579309


##########
enterprise/micronaut/src/org/netbeans/modules/micronaut/maven/BuildActions.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.modules.micronaut.maven;
+
+import java.util.Arrays;
+import javax.swing.Action;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.maven.api.NbMavenProject;
+import org.netbeans.spi.project.ActionProvider;
+import org.netbeans.spi.project.ui.support.ProjectActionPerformer;
+import org.netbeans.spi.project.ui.support.ProjectSensitiveActions;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionRegistration;
+import org.openide.util.Lookup;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author sdedic
+ */
+public class BuildActions {
+    
+    @ActionID(id = "org.netbeans.modules.micronaut.maven.nativeBuild", category = "Project")
+    @ActionRegistration(displayName = "#LBL_NativeBuild", lazy=false)
+    @ActionReference(position = 520, path = "Projects/org-netbeans-modules-maven/Actions")
+    @NbBundle.Messages({
+        "LBL_NativeBuild=Build Native Executable"
+    })
+    public static Action    createNativeBuild() {
+        return ProjectSensitiveActions.projectSensitiveAction(new NativeBuildPerformer(), Bundle.LBL_NativeBuild(), null);
+    }
+    
+    private static class NativeBuildPerformer implements ProjectActionPerformer {
+        @Override
+        public boolean enable(Project project) {
+            NbMavenProject nbmp = project.getLookup().lookup(NbMavenProject.class);
+            if (nbmp == null) {
+                return false;
+            }
+            ActionProvider ap = project.getLookup().lookup(ActionProvider.class);
+            return 
+                    nbmp.getMavenProject().getPlugin("io.micronaut.build:micronaut-maven-plugin") != null &&

Review Comment:
   Hmmm, good catch, will try to use plain `isActionEnabled`.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] lkishalmi commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
lkishalmi commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r946308680


##########
ide/projectapi/src/org/netbeans/api/project/ProjectActionContext.java:
##########
@@ -0,0 +1,402 @@
+/*
+ * 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.project;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import org.netbeans.api.annotations.common.CheckForNull;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.project.Project;
+import org.netbeans.spi.project.ProjectConfiguration;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+
+/**
+ * This represents context for a project model query. The context describe a project action
+ * for which the query should be evaluated, project configuration (if not the active one), 
+ * and possible custom overrides.
+ * {@link ProjectConfiguration} or the IDE-supported project action and the associated properties, profiles, or Lookup may
+ * affect behaviour of queries across the IDE.
+ * <p>
+ * Properties map to user-settable properties of the build system, such as system properties in Maven
+ * or project properties in Gradle.
+ * <p>
+ * Profiles map to profiles in Maven, but do not have any effect in Gradle at the moment; this might change.
+ * <p>
+ * Instances of {@link ProjectActionContext} may be passed to some queries as (part of the) parameters explicitly. In case
+ * the API does not support such flexibility directly, the implementation(s) may - the context may be published for the
+ * query computation using {@link #apply}; the implementation may then use {@link #find} to obtain a {@link ProjectActionContext}
+ * effective for that project.
+ * <p>
+ * <b>Important note:</b> Not all project queries support {@link ProjectActionContext}. Queries which do should mention that
+ * fact in their documentation, or expose it in their APIs.
+ * 
+ * @author sdedic
+ * @since 1.89
+ */
+public final class ProjectActionContext {
+    private final Project project;
+
+    ProjectActionContext(Project project) {
+        this.project = project;
+    }
+   
+    /**
+     * The project action.
+     */
+    private String projectAction;
+    
+    /**
+     * The desired project configuration
+     */
+    private ProjectConfiguration configuration;
+    private Map<String, String> properties;
+    private Set<String> profiles;
+    private Lookup lookup;
+
+    /**
+     * Returns the project this context applies to. Having {@link Project} as a property allows multiple
+     * contexts, individually for each project, to be active.
+     * @return the target project.
+     */
+    public @NonNull Project getProject() {
+        return project;
+    }
+
+    /**
+     * Additional information for the underlying project implementation, similar to 
+     * context lookup in {@link org.netbeans.spi.project.ActionProvider#invokeAction}.
+     * Null if no specific info is present.
+     * 
+     * @return Lookup with additional information or {@code null}.
+     */
+    public @CheckForNull Lookup getLookup() {
+        return lookup;

Review Comment:
   Well if those shortcuts are important, then probably I'd intorduce a ```"boolean isShortcutAllowed()"``` method here to do the necessary checks inside here. Of course I assume that you can do shortcuts if no lookup + properties + profiles are present.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r945576684


##########
enterprise/micronaut/nbproject/project.xml:
##########
@@ -68,6 +68,32 @@
                         <specification-version>1.18</specification-version>
                     </run-dependency>
                 </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.maven</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>2</release-version>
+                        <specification-version>2.154</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.project.dependency</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <implementation-version/>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.maven.embedder</code-name-base>

Review Comment:
   re. depending from Micronaut no Gradle | Maven - agreed, a solution would be to create eager micronaut-maven + micronaut-gradle modules. 
   
   re. no real API - hm, I need to use the maven model types, i.e. `org.apache.maven.model.PluginExecution`. These are currently exposed to the module system by `maven.emebdder`. Is there a better way how to import those types ?



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] ppisl commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
ppisl commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r949140308


##########
ide/project.dependency/src/org/netbeans/modules/project/dependency/ArtifactSpec.java:
##########
@@ -75,17 +86,45 @@ public enum VersionKind {
         this.optional = optional;
         this.data = impl;
         this.type = type;
+        this.location = location;
         this.localFile = localFile;
     }
 
     public T getData() {
         return data;
     }
 
+    /**
+     * Returns local file which the artifact represents. For library (dependencies) artifacts,
+     * the file is the library consumed, e.g. from a local repository. For outputs, the artifact
+     * represents the build output, usually in project's build directory. Note that FileObject for 
+     * a dependency and its corresponding Project may not be the same.
+     * 

Review Comment:
   Probably there should be mentioned, that it can return null, if the local file doesn't exist?



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r948089723


##########
enterprise/micronaut/src/org/netbeans/modules/micronaut/maven/BuildActions.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.modules.micronaut.maven;
+
+import java.util.Arrays;
+import javax.swing.Action;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.maven.api.NbMavenProject;
+import org.netbeans.spi.project.ActionProvider;
+import org.netbeans.spi.project.ui.support.ProjectActionPerformer;
+import org.netbeans.spi.project.ui.support.ProjectSensitiveActions;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionRegistration;
+import org.openide.util.Lookup;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author sdedic
+ */
+public class BuildActions {
+    
+    @ActionID(id = "org.netbeans.modules.micronaut.maven.nativeBuild", category = "Project")
+    @ActionRegistration(displayName = "#LBL_NativeBuild", lazy=false)
+    @ActionReference(position = 520, path = "Projects/org-netbeans-modules-maven/Actions")
+    @NbBundle.Messages({
+        "LBL_NativeBuild=Build Native Executable"
+    })
+    public static Action    createNativeBuild() {
+        return ProjectSensitiveActions.projectSensitiveAction(new NativeBuildPerformer(), Bundle.LBL_NativeBuild(), null);
+    }
+    
+    private static class NativeBuildPerformer implements ProjectActionPerformer {
+        @Override
+        public boolean enable(Project project) {
+            NbMavenProject nbmp = project.getLookup().lookup(NbMavenProject.class);
+            if (nbmp == null) {
+                return false;
+            }
+            ActionProvider ap = project.getLookup().lookup(ActionProvider.class);
+            return 
+                    nbmp.getMavenProject().getPlugin("io.micronaut.build:micronaut-maven-plugin") != null &&

Review Comment:
   Addressed in 2917d2be433e



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] jtulach commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
jtulach commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r945562704


##########
enterprise/micronaut/nbproject/project.xml:
##########
@@ -68,6 +68,32 @@
                         <specification-version>1.18</specification-version>
                     </run-dependency>
                 </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.maven</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>2</release-version>
+                        <specification-version>2.154</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.project.dependency</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <implementation-version/>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.maven.embedder</code-name-base>

Review Comment:
   These modules don't provide real API. Depending on them from foreign "micronaut" module is strange. Also adding a dependency on Maven support, when "micronaut" supports both, Maven and Gradle is strange.



##########
ide/project.dependency/src/org/netbeans/modules/project/dependency/spi/ProjectArtifactsImplementation.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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.modules.project.dependency.spi;
+
+import java.util.Collection;
+import java.util.List;
+import javax.swing.event.ChangeListener;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.project.dependency.ArtifactSpec;
+import org.netbeans.modules.project.dependency.ProjectArtifactsQuery;
+
+/**
+ *
+ * @author sdedic
+ */
+public interface ProjectArtifactsImplementation {
+    /**
+     * Finds project artifact(s) that match the query. 
+     * @param query the query to answer
+     * @param previous result of previous buildsteps
+     * @param all
+     * @return 
+     */
+    public Result findArtifacts(ProjectArtifactsQuery.Filter query);

Review Comment:
   I prefer [singletonizer](https://bits.netbeans.org/14/javadoc/org-netbeans-api-java-classpath/org/netbeans/spi/java/queries/BinaryForSourceQueryImplementation2.html) SPI over `ProjectArtifactsImplementation` and `Result` inner class.



##########
java/java.lsp.server/nbcode/integration/src/org/netbeans/modules/nbcode/integration/commands/ProjectMetadataCommand.java:
##########
@@ -0,0 +1,180 @@
+/*
+ * 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.modules.nbcode.integration.commands;
+
+import com.google.gson.ExclusionStrategy;
+import com.google.gson.FieldAttributes;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonPrimitive;
+import com.google.gson.TypeAdapter;
+import com.google.gson.TypeAdapterFactory;
+import com.google.gson.reflect.TypeToken;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonToken;
+import com.google.gson.stream.JsonWriter;
+import java.io.IOException;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CompletableFuture;
+import org.eclipse.lsp4j.CodeAction;
+import org.eclipse.lsp4j.CodeActionParams;
+import org.netbeans.api.project.FileOwnerQuery;
+import org.netbeans.api.project.Project;
+import org.netbeans.api.project.ProjectActionContext;
+import org.netbeans.modules.java.lsp.server.protocol.CodeActionsProvider;
+import org.netbeans.modules.java.lsp.server.protocol.NbCodeLanguageClient;
+import org.netbeans.modules.parsing.api.ResultIterator;
+import org.netbeans.modules.project.dependency.ArtifactSpec;
+import org.netbeans.modules.project.dependency.ProjectArtifactsQuery;
+import org.netbeans.modules.project.dependency.ProjectArtifactsQuery.ArtifactsResult;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.RequestProcessor;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author sdedic
+ */
+@ServiceProvider(service = CodeActionsProvider.class)
+public class ProjectMetadataCommand extends CodeActionsProvider {
+    private static final String COMMAND_ARTIFACTS = "nbls.gcn.project.artifacts"; // NOI18N
+
+    private static final Set<String> COMMANDS = new HashSet<>(Arrays.asList(
+            COMMAND_ARTIFACTS
+    ));
+    private static final Set<String> ARTIFACT_BLOCK_FIELDS = new HashSet<>(Arrays.asList(
+        "data" // NOI18N
+    ));
+    
+    private static final RequestProcessor METADATA_PROCESSOR = new RequestProcessor(ProjectMetadataCommand.class);
+    
+    private final Gson gson;
+    
+    public ProjectMetadataCommand() {
+        gson = new GsonBuilder()
+             // block the opaque 'data' field 
+            .addSerializationExclusionStrategy(new ExclusionStrategy() {
+                    @Override
+                    public boolean shouldSkipField(FieldAttributes fa) {
+                        if (fa.getDeclaringClass() == ArtifactSpec.class) {
+                          return ARTIFACT_BLOCK_FIELDS.contains(fa.getName());
+                        }
+                        return false;
+                    }
+
+                    @Override
+                    public boolean shouldSkipClass(Class<?> type) {
+                        return false;
+                    }
+            })
+            // serialize FileObject as null|path
+            .registerTypeAdapterFactory(new TypeAdapterFactory() {
+                @Override
+                public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> tt) {
+                    if (tt.getRawType() != FileObject.class) {
+                        return null;
+                    }
+                    return new TypeAdapter<T>() {
+                        @Override
+                        public void write(JsonWriter writer, T t) throws IOException {
+                            FileObject f = (FileObject)t;
+                            writer.value(f == null ? null : f.getPath());
+                        }
+
+                        @Override
+                        public T read(JsonReader reader) throws IOException {
+                            if (reader.peek() == JsonToken.NULL) {
+                                reader.nextNull();
+                                return null;
+                            } else {
+                                String s = reader.nextString();
+                                if (s == null) {
+                                    return null;
+                                }
+                                FileObject fo = FileUtil.toFileObject(Paths.get(s).toFile());
+                                return (T)fo;
+                            }
+                        }
+                    };
+                }
+            })
+            .create();
+    }
+    
+    @Override
+    public List<CodeAction> getCodeActions(ResultIterator resultIterator, CodeActionParams params) throws Exception {
+        return Collections.emptyList();
+    }
+
+    @Override
+    public Set<String> getCommands() {
+        return COMMANDS;
+    }
+
+    @Override
+    public CompletableFuture<Object> processCommand(NbCodeLanguageClient client, String command, List<Object> arguments) {
+        if (arguments.size() < 1) {
+            throw new IllegalArgumentException("Expected at least project URI/path");
+        }
+        FileObject f = Utils.extractFileObject(arguments.get(0), gson);
+        Project p = FileOwnerQuery.getOwner(f);
+        if (p == null || p.getProjectDirectory() != f) {
+            throw new IllegalArgumentException("Not a project " + f);
+        }
+        String artifactType = null;
+        ProjectActionContext ctx = null;
+        
+        if (arguments.size() > 1) {
+            // 2nd parameter is the project action
+            Object o = arguments.get(1);
+            if (!(o instanceof JsonPrimitive)) {
+                throw new IllegalArgumentException("String or null expected as parameter #3, got " + o);
+            }
+            ctx = ProjectActionContext.newBuilder(p).forProjectAction(((JsonPrimitive)o).getAsString()).context();
+        }
+        if (arguments.size() > 2) {
+            // 3rd parameter is the type of artifact
+            Object o = arguments.get(2);
+            if (!(o instanceof JsonPrimitive)) {
+                throw new IllegalArgumentException("String or null expected as parameter #2, got " + o);
+            }
+            artifactType = ((JsonPrimitive)o).getAsString();
+        }
+        ProjectArtifactsQuery.Filter filter = ProjectArtifactsQuery.newQuery(artifactType, null, ctx);
+        CompletableFuture result = new CompletableFuture();
+        METADATA_PROCESSOR.post(() -> {
+            try {
+                ArtifactsResult arts = ProjectArtifactsQuery.findArtifacts(p, filter);

Review Comment:
   All the changes _just_ to get name of artifact to VSCode TypeScript side...



##########
java/maven/src/org/netbeans/modules/maven/api/NbMavenProject.java:
##########
@@ -286,6 +287,22 @@ public void removePropertyChangeListener(PropertyChangeListener propertyChangeLi
         return project.getOriginalMavenProject();
     }
     
+    /**
+     * Returns a project evaluated for a certain purpose. The while {@link #getMavenProject}
+     * works with the <b>active configuration</b> and does not apply any action-specific properties,
+     * this method tries to apply mappings, configurations, etc when loading the project model.
+     * <p>
+     * Note that loading an evaluated project may take significant time (comparable to loading
+     * the base project itself). The implementation might optimize if the passed context does not
+     * prescribe different profiles, properties etc than have been used for the default model.
+     * 
+     * @param context the loading context
+     * @return evaluated project

Review Comment:
   Missing versioning, I assume.



##########
java/java.lsp.server/nbcode/integration/nbproject/project.xml:
##########
@@ -214,6 +214,14 @@
                         <specification-version>9.24</specification-version>
                     </run-dependency>
                 </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.project.dependency</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <implementation-version/>

Review Comment:
   Implementation dependency!?



##########
java/maven.embedder/nbproject/project.xml:
##########
@@ -182,6 +182,7 @@
                 <friend>io.github.jeddict.runtime</friend>
                 <friend>io.github.jeddict.rest.generator</friend>
                 <!-- XXX <subpackages> not permitted by schema -->
+                <friend>org.netbeans.modules.micronaut</friend>

Review Comment:
   I don't like this. `micronaut` module shall not have direct dependency on Maven (embedder).



##########
enterprise/micronaut/src/org/netbeans/modules/micronaut/maven/BuildActions.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.modules.micronaut.maven;
+
+import java.util.Arrays;
+import javax.swing.Action;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.maven.api.NbMavenProject;
+import org.netbeans.spi.project.ActionProvider;
+import org.netbeans.spi.project.ui.support.ProjectActionPerformer;
+import org.netbeans.spi.project.ui.support.ProjectSensitiveActions;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionRegistration;
+import org.openide.util.Lookup;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author sdedic
+ */
+public class BuildActions {
+    
+    @ActionID(id = "org.netbeans.modules.micronaut.maven.nativeBuild", category = "Project")
+    @ActionRegistration(displayName = "#LBL_NativeBuild", lazy=false)
+    @ActionReference(position = 520, path = "Projects/org-netbeans-modules-maven/Actions")
+    @NbBundle.Messages({
+        "LBL_NativeBuild=Build Native Executable"
+    })
+    public static Action    createNativeBuild() {
+        return ProjectSensitiveActions.projectSensitiveAction(new NativeBuildPerformer(), Bundle.LBL_NativeBuild(), null);
+    }
+    
+    private static class NativeBuildPerformer implements ProjectActionPerformer {
+        @Override
+        public boolean enable(Project project) {
+            NbMavenProject nbmp = project.getLookup().lookup(NbMavenProject.class);
+            if (nbmp == null) {
+                return false;
+            }
+            ActionProvider ap = project.getLookup().lookup(ActionProvider.class);
+            return 
+                    nbmp.getMavenProject().getPlugin("io.micronaut.build:micronaut-maven-plugin") != null &&

Review Comment:
   I was hoping this (presence of some plugin) could be specified declaratively. Isn't there already a support for a plugin to trigger some configuration and configurations adding some actions?



##########
ide/project.dependency/src/org/netbeans/modules/project/dependency/spi/ProjectDependenciesImplementation.java:
##########
@@ -32,16 +29,9 @@
  * @author sdedic
  */
 public interface ProjectDependenciesImplementation {

Review Comment:
   Removing methods from `spi` package? Isn't that an API change?



##########
ide/projectapi/src/org/netbeans/api/project/ProjectUtils.java:
##########
@@ -57,6 +61,65 @@ private ProjectUtils() {}
 
     private static final Logger LOG = Logger.getLogger(ProjectUtils.class.getName());
     
+    /**
+     * Returns the active configuration for the given project. Returns {@code null},
+     * if the project does not support configurations at all.
+     * 
+     * @param p the project
+     * @return the active configuration, or {@code null} if configurations are not supported.
+     * @since 1.89
+     */
+    public ProjectConfiguration getActiveConfiguration(@NonNull Project p) {
+        ProjectConfigurationProvider pcp = p.getLookup().lookup(ProjectConfigurationProvider.class);
+        if (pcp == null) {
+            return null;
+        }
+        return ProjectManager.mutex().readAccess(() -> pcp.getActiveConfiguration());
+    }
+    
+    /**
+     * Sets the active configuration to a project. The configuration should have been previously obtained by 
+     * {@link #getActiveConfiguration(org.netbeans.api.project.Project)} from the same project. The method
+     * returns {@code false}, if the configuration could not be set: if the project does not support configurations
+     * at all, or the project failed to switch the configurations. Since the active configuration setting is persisted,
+     * the method throws {@link IOException} if the setting save fails.
+     * 
+     * @param <C> configuration type
+     * @param p the project
+     * @param cfg configuration or {@code null} for default configuration.
+     * @return true, if the configuration was successfully set.
+     * @throws IOException when the selected configuration cannot be persisted.
+     * @since 1.89
+     */
+    public <C extends ProjectConfiguration> boolean setActiveConfiguration(@NonNull Project p, @NonNull C cfg) throws IOException {

Review Comment:
   This would type the same without generics.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r946083824


##########
ide/projectapi/src/org/netbeans/api/project/ProjectActionContext.java:
##########
@@ -0,0 +1,402 @@
+/*
+ * 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.project;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import org.netbeans.api.annotations.common.CheckForNull;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.project.Project;
+import org.netbeans.spi.project.ProjectConfiguration;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+
+/**
+ * This represents context for a project model query. The context describe a project action
+ * for which the query should be evaluated, project configuration (if not the active one), 
+ * and possible custom overrides.
+ * {@link ProjectConfiguration} or the IDE-supported project action and the associated properties, profiles, or Lookup may
+ * affect behaviour of queries across the IDE.
+ * <p>
+ * Properties map to user-settable properties of the build system, such as system properties in Maven
+ * or project properties in Gradle.
+ * <p>
+ * Profiles map to profiles in Maven, but do not have any effect in Gradle at the moment; this might change.
+ * <p>
+ * Instances of {@link ProjectActionContext} may be passed to some queries as (part of the) parameters explicitly. In case
+ * the API does not support such flexibility directly, the implementation(s) may - the context may be published for the
+ * query computation using {@link #apply}; the implementation may then use {@link #find} to obtain a {@link ProjectActionContext}
+ * effective for that project.
+ * <p>
+ * <b>Important note:</b> Not all project queries support {@link ProjectActionContext}. Queries which do should mention that
+ * fact in their documentation, or expose it in their APIs.
+ * 
+ * @author sdedic
+ * @since 1.89
+ */
+public final class ProjectActionContext {
+    private final Project project;
+
+    ProjectActionContext(Project project) {
+        this.project = project;
+    }
+   
+    /**
+     * The project action.
+     */
+    private String projectAction;
+    
+    /**
+     * The desired project configuration
+     */
+    private ProjectConfiguration configuration;
+    private Map<String, String> properties;
+    private Set<String> profiles;
+    private Lookup lookup;
+
+    /**
+     * Returns the project this context applies to. Having {@link Project} as a property allows multiple
+     * contexts, individually for each project, to be active.
+     * @return the target project.
+     */
+    public @NonNull Project getProject() {
+        return project;
+    }
+
+    /**
+     * Additional information for the underlying project implementation, similar to 
+     * context lookup in {@link org.netbeans.spi.project.ActionProvider#invokeAction}.
+     * Null if no specific info is present.
+     * 
+     * @return Lookup with additional information or {@code null}.
+     */
+    public @CheckForNull Lookup getLookup() {
+        return lookup;

Review Comment:
   Hm, with all those nulls (including this one), I intended to signal explicitly "no value". For example, if no Lookup + properties + profiles are present the implementation can take a great shortcut (= no customization to the project model or services).



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r948044818


##########
ide/projectapi/src/org/netbeans/api/project/ProjectActionContext.java:
##########
@@ -0,0 +1,402 @@
+/*
+ * 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.project;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import org.netbeans.api.annotations.common.CheckForNull;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.project.Project;
+import org.netbeans.spi.project.ProjectConfiguration;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+
+/**
+ * This represents context for a project model query. The context describe a project action
+ * for which the query should be evaluated, project configuration (if not the active one), 
+ * and possible custom overrides.
+ * {@link ProjectConfiguration} or the IDE-supported project action and the associated properties, profiles, or Lookup may
+ * affect behaviour of queries across the IDE.
+ * <p>
+ * Properties map to user-settable properties of the build system, such as system properties in Maven
+ * or project properties in Gradle.
+ * <p>
+ * Profiles map to profiles in Maven, but do not have any effect in Gradle at the moment; this might change.
+ * <p>
+ * Instances of {@link ProjectActionContext} may be passed to some queries as (part of the) parameters explicitly. In case
+ * the API does not support such flexibility directly, the implementation(s) may - the context may be published for the
+ * query computation using {@link #apply}; the implementation may then use {@link #find} to obtain a {@link ProjectActionContext}
+ * effective for that project.
+ * <p>
+ * <b>Important note:</b> Not all project queries support {@link ProjectActionContext}. Queries which do should mention that
+ * fact in their documentation, or expose it in their APIs.
+ * 
+ * @author sdedic
+ * @since 1.89
+ */
+public final class ProjectActionContext {
+    private final Project project;
+
+    ProjectActionContext(Project project) {
+        this.project = project;
+    }
+   
+    /**
+     * The project action.
+     */
+    private String projectAction;
+    
+    /**
+     * The desired project configuration
+     */
+    private ProjectConfiguration configuration;
+    private Map<String, String> properties;
+    private Set<String> profiles;
+    private Lookup lookup;
+
+    /**
+     * Returns the project this context applies to. Having {@link Project} as a property allows multiple
+     * contexts, individually for each project, to be active.
+     * @return the target project.
+     */
+    public @NonNull Project getProject() {
+        return project;
+    }
+
+    /**
+     * Additional information for the underlying project implementation, similar to 
+     * context lookup in {@link org.netbeans.spi.project.ActionProvider#invokeAction}.
+     * Null if no specific info is present.
+     * 
+     * @return Lookup with additional information or {@code null}.
+     */
+    public @CheckForNull Lookup getLookup() {
+        return lookup;
+    }
+
+    /**
+     * The project action in whose context the project queries are performed. May be
+     * left unspecified, so the implementation can choose an appropriate default behaviour.
+     * 
+     * @return project aciton or {@code null} for unspecified.
+     */
+    public @CheckForNull String getProjectAction() {
+        return projectAction;
+    }
+
+    /**
+     * The project configuration to use for the project query. Can be {@code null} to 
+     * indicate the project's default Configuration should be used.
+     * 
+     * @return the project's configuration or {@code null}.
+     */
+    public @CheckForNull ProjectConfiguration getConfiguration() {
+        return configuration;
+    }
+    
+    /**
+     * User-customized properties that should be effective during the computation. The same
+     * customization should be made during project action execution to obtain the same results as 
+     * evaluated by the query.
+     * 
+     * @return user properties, or {@code null} if unspecified.
+     */
+    public @CheckForNull Map<String, String> getProperties() {
+        return properties == null ? null : Collections.unmodifiableMap(properties);
+    }
+
+    /**
+     * Profiles or some project system features/tags that should be applied for the evaluation.
+     * @return applied profiles or {@code null} if unspecified.
+     */
+    public @CheckForNull Set<String> getProfiles() {
+        return profiles == null ? null : Collections.unmodifiableSet(profiles);

Review Comment:
   Addressed in a1c2f1b8c6b2



##########
ide/projectapi/src/org/netbeans/api/project/ProjectActionContext.java:
##########
@@ -0,0 +1,402 @@
+/*
+ * 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.project;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import org.netbeans.api.annotations.common.CheckForNull;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.project.Project;
+import org.netbeans.spi.project.ProjectConfiguration;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+
+/**
+ * This represents context for a project model query. The context describe a project action
+ * for which the query should be evaluated, project configuration (if not the active one), 
+ * and possible custom overrides.
+ * {@link ProjectConfiguration} or the IDE-supported project action and the associated properties, profiles, or Lookup may
+ * affect behaviour of queries across the IDE.
+ * <p>
+ * Properties map to user-settable properties of the build system, such as system properties in Maven
+ * or project properties in Gradle.
+ * <p>
+ * Profiles map to profiles in Maven, but do not have any effect in Gradle at the moment; this might change.
+ * <p>
+ * Instances of {@link ProjectActionContext} may be passed to some queries as (part of the) parameters explicitly. In case
+ * the API does not support such flexibility directly, the implementation(s) may - the context may be published for the
+ * query computation using {@link #apply}; the implementation may then use {@link #find} to obtain a {@link ProjectActionContext}
+ * effective for that project.
+ * <p>
+ * <b>Important note:</b> Not all project queries support {@link ProjectActionContext}. Queries which do should mention that
+ * fact in their documentation, or expose it in their APIs.
+ * 
+ * @author sdedic
+ * @since 1.89
+ */
+public final class ProjectActionContext {
+    private final Project project;
+
+    ProjectActionContext(Project project) {
+        this.project = project;
+    }
+   
+    /**
+     * The project action.
+     */
+    private String projectAction;
+    
+    /**
+     * The desired project configuration
+     */
+    private ProjectConfiguration configuration;
+    private Map<String, String> properties;
+    private Set<String> profiles;
+    private Lookup lookup;
+
+    /**
+     * Returns the project this context applies to. Having {@link Project} as a property allows multiple
+     * contexts, individually for each project, to be active.
+     * @return the target project.
+     */
+    public @NonNull Project getProject() {
+        return project;
+    }
+
+    /**
+     * Additional information for the underlying project implementation, similar to 
+     * context lookup in {@link org.netbeans.spi.project.ActionProvider#invokeAction}.
+     * Null if no specific info is present.
+     * 
+     * @return Lookup with additional information or {@code null}.
+     */
+    public @CheckForNull Lookup getLookup() {
+        return lookup;
+    }
+
+    /**
+     * The project action in whose context the project queries are performed. May be
+     * left unspecified, so the implementation can choose an appropriate default behaviour.
+     * 
+     * @return project aciton or {@code null} for unspecified.
+     */
+    public @CheckForNull String getProjectAction() {
+        return projectAction;
+    }
+
+    /**
+     * The project configuration to use for the project query. Can be {@code null} to 
+     * indicate the project's default Configuration should be used.
+     * 
+     * @return the project's configuration or {@code null}.
+     */
+    public @CheckForNull ProjectConfiguration getConfiguration() {
+        return configuration;
+    }
+    
+    /**
+     * User-customized properties that should be effective during the computation. The same
+     * customization should be made during project action execution to obtain the same results as 
+     * evaluated by the query.
+     * 
+     * @return user properties, or {@code null} if unspecified.
+     */
+    public @CheckForNull Map<String, String> getProperties() {
+        return properties == null ? null : Collections.unmodifiableMap(properties);

Review Comment:
   Addressed in a1c2f1b8c6b2



##########
ide/projectapi/src/org/netbeans/api/project/ProjectActionContext.java:
##########
@@ -0,0 +1,402 @@
+/*
+ * 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.project;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import org.netbeans.api.annotations.common.CheckForNull;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.project.Project;
+import org.netbeans.spi.project.ProjectConfiguration;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+
+/**
+ * This represents context for a project model query. The context describe a project action
+ * for which the query should be evaluated, project configuration (if not the active one), 
+ * and possible custom overrides.
+ * {@link ProjectConfiguration} or the IDE-supported project action and the associated properties, profiles, or Lookup may
+ * affect behaviour of queries across the IDE.
+ * <p>
+ * Properties map to user-settable properties of the build system, such as system properties in Maven
+ * or project properties in Gradle.
+ * <p>
+ * Profiles map to profiles in Maven, but do not have any effect in Gradle at the moment; this might change.
+ * <p>
+ * Instances of {@link ProjectActionContext} may be passed to some queries as (part of the) parameters explicitly. In case
+ * the API does not support such flexibility directly, the implementation(s) may - the context may be published for the
+ * query computation using {@link #apply}; the implementation may then use {@link #find} to obtain a {@link ProjectActionContext}
+ * effective for that project.
+ * <p>
+ * <b>Important note:</b> Not all project queries support {@link ProjectActionContext}. Queries which do should mention that
+ * fact in their documentation, or expose it in their APIs.
+ * 
+ * @author sdedic
+ * @since 1.89
+ */
+public final class ProjectActionContext {
+    private final Project project;
+
+    ProjectActionContext(Project project) {
+        this.project = project;
+    }
+   
+    /**
+     * The project action.
+     */
+    private String projectAction;
+    
+    /**
+     * The desired project configuration
+     */
+    private ProjectConfiguration configuration;
+    private Map<String, String> properties;
+    private Set<String> profiles;
+    private Lookup lookup;
+
+    /**
+     * Returns the project this context applies to. Having {@link Project} as a property allows multiple
+     * contexts, individually for each project, to be active.
+     * @return the target project.
+     */
+    public @NonNull Project getProject() {
+        return project;
+    }
+
+    /**
+     * Additional information for the underlying project implementation, similar to 
+     * context lookup in {@link org.netbeans.spi.project.ActionProvider#invokeAction}.
+     * Null if no specific info is present.
+     * 
+     * @return Lookup with additional information or {@code null}.
+     */
+    public @CheckForNull Lookup getLookup() {
+        return lookup;

Review Comment:
   Addressed in a1c2f1b8c6b2



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r948045747


##########
ide/projectapi/src/org/netbeans/api/project/ProjectActionContext.java:
##########
@@ -0,0 +1,402 @@
+/*
+ * 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.project;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+import java.util.concurrent.Callable;
+import org.netbeans.api.annotations.common.CheckForNull;
+import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.project.Project;
+import org.netbeans.spi.project.ProjectConfiguration;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
+import org.openide.util.lookup.ProxyLookup;
+
+/**
+ * This represents context for a project model query. The context describe a project action
+ * for which the query should be evaluated, project configuration (if not the active one), 
+ * and possible custom overrides.
+ * {@link ProjectConfiguration} or the IDE-supported project action and the associated properties, profiles, or Lookup may
+ * affect behaviour of queries across the IDE.
+ * <p>
+ * Properties map to user-settable properties of the build system, such as system properties in Maven
+ * or project properties in Gradle.
+ * <p>
+ * Profiles map to profiles in Maven, but do not have any effect in Gradle at the moment; this might change.
+ * <p>
+ * Instances of {@link ProjectActionContext} may be passed to some queries as (part of the) parameters explicitly. In case
+ * the API does not support such flexibility directly, the implementation(s) may - the context may be published for the
+ * query computation using {@link #apply}; the implementation may then use {@link #find} to obtain a {@link ProjectActionContext}
+ * effective for that project.
+ * <p>
+ * <b>Important note:</b> Not all project queries support {@link ProjectActionContext}. Queries which do should mention that
+ * fact in their documentation, or expose it in their APIs.
+ * 
+ * @author sdedic
+ * @since 1.89
+ */
+public final class ProjectActionContext {
+    private final Project project;
+
+    ProjectActionContext(Project project) {
+        this.project = project;
+    }
+   
+    /**
+     * The project action.
+     */
+    private String projectAction;
+    
+    /**
+     * The desired project configuration
+     */
+    private ProjectConfiguration configuration;
+    private Map<String, String> properties;
+    private Set<String> profiles;
+    private Lookup lookup;
+
+    /**
+     * Returns the project this context applies to. Having {@link Project} as a property allows multiple
+     * contexts, individually for each project, to be active.
+     * @return the target project.
+     */
+    public @NonNull Project getProject() {

Review Comment:
   this particular one does not ;))  the others were addressed in a1c2f1b8c6b2



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
sdedic commented on PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#issuecomment-1211593249

   added @lkishalmi  since I'm going to make equivalent changes for Gradle in a separate PR. Please comment on the APIs.


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r948089723


##########
enterprise/micronaut/src/org/netbeans/modules/micronaut/maven/BuildActions.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * 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.modules.micronaut.maven;
+
+import java.util.Arrays;
+import javax.swing.Action;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.maven.api.NbMavenProject;
+import org.netbeans.spi.project.ActionProvider;
+import org.netbeans.spi.project.ui.support.ProjectActionPerformer;
+import org.netbeans.spi.project.ui.support.ProjectSensitiveActions;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionRegistration;
+import org.openide.util.Lookup;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author sdedic
+ */
+public class BuildActions {
+    
+    @ActionID(id = "org.netbeans.modules.micronaut.maven.nativeBuild", category = "Project")
+    @ActionRegistration(displayName = "#LBL_NativeBuild", lazy=false)
+    @ActionReference(position = 520, path = "Projects/org-netbeans-modules-maven/Actions")
+    @NbBundle.Messages({
+        "LBL_NativeBuild=Build Native Executable"
+    })
+    public static Action    createNativeBuild() {
+        return ProjectSensitiveActions.projectSensitiveAction(new NativeBuildPerformer(), Bundle.LBL_NativeBuild(), null);
+    }
+    
+    private static class NativeBuildPerformer implements ProjectActionPerformer {
+        @Override
+        public boolean enable(Project project) {
+            NbMavenProject nbmp = project.getLookup().lookup(NbMavenProject.class);
+            if (nbmp == null) {
+                return false;
+            }
+            ActionProvider ap = project.getLookup().lookup(ActionProvider.class);
+            return 
+                    nbmp.getMavenProject().getPlugin("io.micronaut.build:micronaut-maven-plugin") != null &&

Review Comment:
   Addressed in 2917d2be433e The project action ID is enabled based on plugin's presence, so the UI action will enable/disable itself accordingly.



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on a diff in pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
sdedic commented on code in PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#discussion_r948055771


##########
java/java.lsp.server/nbcode/integration/nbproject/project.xml:
##########
@@ -214,6 +214,14 @@
                         <specification-version>9.24</specification-version>
                     </run-dependency>
                 </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.project.dependency</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <implementation-version/>

Review Comment:
   Yes, since the `project.dependency` is still not public - planning to open it before NB16



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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


[GitHub] [netbeans] sdedic commented on pull request #4495: Support for project output artifacts

Posted by GitBox <gi...@apache.org>.
sdedic commented on PR #4495:
URL: https://github.com/apache/netbeans/pull/4495#issuecomment-1220563760

   2 approvals; going to merge soon, after rebasing to master (minor clash) + consolidating fixes (less clutter).


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

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