diff --git a/java/maven/apichanges.xml b/java/maven/apichanges.xml index 3b2f5a33aaf1..8854fb3799e7 100644 --- a/java/maven/apichanges.xml +++ b/java/maven/apichanges.xml @@ -83,6 +83,21 @@ is the proper place. + + + + + + + + + Added a + RunUtils.createRunConfig() variant that allows to create a RunConfig 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 + RunUtils.run. + + + LifecycleParticipants can be ignored diff --git a/java/maven/nbproject/project.properties b/java/maven/nbproject/project.properties index eaeea266d4d7..40de3798717b 100644 --- a/java/maven/nbproject/project.properties +++ b/java/maven/nbproject/project.properties @@ -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 diff --git a/java/maven/src/org/netbeans/modules/maven/api/execute/RunUtils.java b/java/maven/src/org/netbeans/modules/maven/api/execute/RunUtils.java index a007d79b57da..a8d81316bfcb 100644 --- a/java/maven/src/org/netbeans/modules/maven/api/execute/RunUtils.java +++ b/java/maven/src/org/netbeans/modules/maven/api/execute/RunUtils.java @@ -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; @@ -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 goals) {