Skip to content

Commit

Permalink
API to create RunConfig for a project-provided action.
Browse files Browse the repository at this point in the history
  • Loading branch information
sdedic committed Jan 26, 2023
1 parent 0e504e5 commit cb3a98e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
15 changes: 15 additions & 0 deletions java/maven/apichanges.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,21 @@ is the proper place.
<!-- ACTUAL CHANGES BEGIN HERE: -->

<changes>
<change id="runutils-createconfig-action">
<api name="general"/>
<summary></summary>
<version major="2" minor="157"/>
<date day="23" month="1" year="2023"/>
<author login="sdedic"/>
<compatibility addition="yes" semantic="compatible"/>
<description>
Added a <a href="@TOP@/org/netbeans/modules/maven/api/execute/RunUtils.html#createRunConfig-java.lang.String-org.netbeans.api.project.Project-org.netbeans.spi.project.ProjectConfiguration-org.openide.util.Lookup-">
RunUtils.createRunConfig()</a> variant that allows to create a <a href="@TOP@/org/netbeans/modules/maven/api/execute/RunConfig.html">RunConfig</a> for a project-defined action.
Clients can use this function to use all user customizations that may have been configured for the project action before executing it using
<a href="@TOP@/org/netbeans/modules/maven/api/execute/RunUtils.html#run-org.netbeans.modules.maven.api.execute.RunConfig-">RunUtils.run</a>.
</description>
<class package="org.netbeans.modules.maven.api.execute" name="RunUtils"/>
</change>
<change id="lifecycle-white-list">
<api name="general"/>
<summary>LifecycleParticipants can be ignored</summary>
Expand Down
2 changes: 1 addition & 1 deletion java/maven/nbproject/project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ javadoc.apichanges=${basedir}/apichanges.xml
javadoc.arch=${basedir}/arch.xml
javahelp.hs=maven.hs
extra.module.files=maven-nblib/
spec.version.base: 2.156
spec.version.base=2.157.0

# The CPExtender test fails in library processing (not randomly) since NetBeans 8.2; disabling.
test.excludes=**/CPExtenderTest.class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@
import org.netbeans.api.annotations.common.CheckForNull;
import org.netbeans.api.java.source.BuildArtifactMapper;
import org.netbeans.api.project.Project;
import org.netbeans.modules.maven.NbMavenProjectImpl;
import org.netbeans.modules.maven.api.Constants;
import org.netbeans.modules.maven.execute.ActionToGoalUtils;
import org.netbeans.modules.maven.execute.BeanRunConfig;
import org.netbeans.modules.maven.execute.MavenCommandLineExecutor;
import org.netbeans.spi.project.AuxiliaryProperties;
import org.netbeans.spi.project.ProjectConfiguration;
import org.openide.execution.ExecutorTask;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
import org.openide.windows.WindowManager;

Expand Down Expand Up @@ -98,6 +102,27 @@ public void run() {
public static ExecutorTask executeMaven(final RunConfig config) {
return MavenCommandLineExecutor.executeMaven(config, null, null);
}

/**
* Creates a {@link RunConfig} for the specified project action. Project configuration to be used can be also specified, which
* affects potentially the action's mapping and/or properties. If {@code null} is passed, the current/active configuration is used.
* If applied on non-Maven project, the method returns {@code null}, as well as if the requested action does not exist in the project
* or its requested (or active) configuration.
*
* @param action project action name
* @param prj the project
* @param c the configuration to use, use {@code null} for the active one.
* @param lookup lookup that becomes available to the action provider for possible further data / options
* @return configured {@link RunConfig} suitable for execution or {@code null} if the project is not maven, or action is unavailable.
* @since 2.157
*/
public static RunConfig createRunConfig(String action, Project prj, ProjectConfiguration c, Lookup lookup) {
NbMavenProjectImpl impl = prj.getLookup().lookup(NbMavenProjectImpl.class);
if (impl == null) {
return null;
}
return ActionToGoalUtils.createRunConfig(action, impl, c, lookup);
}

public static RunConfig createRunConfig(File execDir, Project prj, String displayName, List<String> goals)
{
Expand Down

0 comments on commit cb3a98e

Please sign in to comment.