public final class RunUtils extends Object
Modifier and Type | Field and Description |
---|---|
static String |
PROP_AUGMENTED_BUILD |
static String |
PROP_COMPILE_ON_SAVE |
static String |
PROP_DEFAULT_CLI |
static String |
PROP_INCLUDE_OPEN_PROJECTS |
static String |
PROP_JDK_PLATFORM |
Modifier and Type | Method and Description |
---|---|
static boolean |
cancelGradle(RunConfig config)
Enable plugins to Cancel a currently running Gradle execution.
|
static RunConfig |
createRunConfig(Project project,
String action,
String displayName,
Lookup context,
GradleExecConfiguration cfg,
Set<RunConfig.ExecFlag> flags,
String... args)
Create Gradle execution configuration (context).
|
static RunConfig |
createRunConfig(Project project,
String action,
String displayName,
Set<RunConfig.ExecFlag> flags,
String... args)
Create Gradle execution configuration (context).
|
static RunConfig |
createRunConfig(Project project,
String action,
String displayName,
String[] args)
|
static RunConfig |
createRunConfigForAction(Project project,
String action,
String displayName,
Lookup context,
GradleExecConfiguration cfg,
Set<RunConfig.ExecFlag> flags,
boolean allowDisabled,
String... args)
Create Gradle execution configuration (context).
|
static String[] |
evaluateActionArgs(Project project,
String action,
String argLine,
Lookup context)
Replace the tokens in
argLine provided by the project for
the action using the given context; |
static File |
evaluateGradleDistribution(Project project,
boolean forceCompatibility)
Deprecated.
|
static ExecutorTask |
executeGradle(RunConfig config,
String initialOutput)
Executes a Gradle build with the given configuration.
|
static FileObject |
extractFileObjectfromLookup(Lookup lookup) |
static FileObject[] |
extractFileObjectsfromLookup(Lookup lookup) |
static ActionMapping |
findActionMapping(Project project,
String action,
GradleExecConfiguration cfg)
Finds an action mapping for the given action and (optional) configuration.
|
static ProjectActionMappingProvider |
findActionProvider(Project p,
Lookup context)
Returns an action mapping provider for the specified project and context.
|
static Pair |
getActivePlatform(Project project)
Deprecated.
This method has been deprecated without having a
replacement in this module. The current implementation serves
binary compatibility purposes only.
|
static Pair |
getActivePlatform(String activePlatformId)
Deprecated.
This method has been deprecated without having a
replacement in this module. The current implementation serves
binary compatibility purposes only.
|
static JavaRuntimeManager.JavaRuntime |
getActiveRuntime(Project project)
Return the current active JavaRuntime used by the specified project.
|
static GradleDistributionManager.GradleDistribution |
getCompatibleGradleDistribution(Project prj)
Returns the GradleDistribution for the given project which is compatible
with the JVM runtime, the IDE is running on
.
|
static GradleCommandLine |
getDefaultCommandLine(Project project) |
static boolean |
isAugmentedBuildEnabled(Project project) |
static boolean |
isCompileOnSaveEnabled(Project project)
Deprecated.
In order to discourage the usage of this call.
|
static boolean |
isIncludeOpenProjectsEnabled(Project project)
Returns true if the include open projects checkbox is marked
in the project configuration.
|
static boolean |
isProjectTrusted(Project project,
boolean interactive)
Check if the given project is trusted for execution.
|
static void |
setActiveRuntime(Project project,
JavaRuntimeManager.JavaRuntime runtime)
Sets the active JavaRuntime on the specified project root.
|
static ReplaceTokenProvider |
simpleReplaceTokenProvider(String token,
String value) |
public static final String PROP_JDK_PLATFORM
public static final String PROP_COMPILE_ON_SAVE
public static final String PROP_AUGMENTED_BUILD
public static final String PROP_INCLUDE_OPEN_PROJECTS
public static final String PROP_DEFAULT_CLI
public static FileObject extractFileObjectfromLookup(Lookup lookup)
public static FileObject[] extractFileObjectsfromLookup(Lookup lookup)
public static ExecutorTask executeGradle(RunConfig config, String initialOutput)
config
- the configuration of the Gradle executioninitialOutput
- the initial message to be displayed,
can be null
for no message.public static RunConfig createRunConfig(Project project, String action, String displayName, Set<RunConfig.ExecFlag> flags, String... args)
project
- The Gradle projectaction
- The name of the IDE action that's going to be executeddisplayName
- The display name of the output tabflags
- Execution flags.args
- Gradle command line argumentspublic static RunConfig createRunConfig(Project project, String action, String displayName, Lookup context, GradleExecConfiguration cfg, Set<RunConfig.ExecFlag> flags, String... args)
GradleExecConfiguration
is recorded in
the RunConfig.getExecConfig()
. If null
is passed, the
active project's configuration is recorded.project
- The Gradle projectaction
- The name of the IDE action that's going to be executeddisplayName
- The display name of the output tabflags
- Execution flags.args
- Gradle command line argumentscontext
- action infocation contextcfg
- the desired configuration, or null
.public static ActionMapping findActionMapping(Project project, String action, GradleExecConfiguration cfg)
null
,
which means the project's active configuration.project
- the projectaction
- action namecfg
- optional configuration or null
null
, if the action is not defined for the project or is disabled.public static RunConfig createRunConfigForAction(Project project, String action, String displayName, Lookup context, GradleExecConfiguration cfg, Set<RunConfig.ExecFlag> flags, boolean allowDisabled, String... args)
project
- The Gradle projectaction
- The name of the IDE actiondisplayName
- The display name of the output tabflags
- Execution flags.args
- Gradle command line argumentscontext
- action infocation contextcfg
- the desired configuration, or null
.@Deprecated public static RunConfig createRunConfig(Project project, String action, String displayName, String[] args)
RunUtils.createRunConfig(org.netbeans.api.project.Project, java.lang.String, java.lang.String, java.util.Set, java.lang.String...)
instead.project
- The Gradle projectaction
- The name of the IDE action that's going to be executeddisplayName
- The display name of the output tabargs
- Gradle command line argumentspublic static boolean cancelGradle(RunConfig config)
config
- the RunConfig with which the Gradle execution has been started.true
if the current execution was cancelled successfully,
false
if the execution was already cancelled or it cannot
be cancelled for some reason.public static GradleDistributionManager.GradleDistribution getCompatibleGradleDistribution(Project prj)
prj
- the project@Deprecated public static boolean isCompileOnSaveEnabled(Project project)
project
- public static boolean isAugmentedBuildEnabled(Project project)
public static boolean isIncludeOpenProjectsEnabled(Project project)
project
- the given project.public static boolean isProjectTrusted(Project project, boolean interactive)
Starting with version 2.8, the presence and order of individual options can be customized by branding. This allows integrators to select appropriate choices. The supported options are:
org.netbeans.modules.gradle.api.execute.TrustProjectOption.TrustOnce
- trusts just in this session. Equivalent of ProjectTrust.trustProject(org.netbeans.api.project.Project, boolean)
called with permanently = false
.
org.netbeans.modules.gradle.api.execute.TrustProjectOption.PermanentTrust
- trusts the project permanently. Equivalent of ProjectTrust.trustProject(org.netbeans.api.project.Project, boolean)
called with permanently = true
. This option is only present if the passed project
is not null
and has ProjectInformation
in it.
org.netbeans.modules.gradle.api.execute.TrustProjectOption.RunAlways
- sets total trust in gradle scripts, see GradleSettings.setGradleExecutionRule(org.netbeans.modules.gradle.spi.GradleSettings.GradleExecutionRule)
.
Bundle.properties
branding in org.netbeans.modules.gradle.api.execute
package:
org.netbeans.modules.gradle.api.execute.TrustProjectOption.TrustOnce=1 org.netbeans.modules.gradle.api.execute.TrustProjectOption.PermanentTrust=-2 org.netbeans.modules.gradle.api.execute.TrustProjectOption.RunAlways=3This branding enables all supported options, and will make the "Trust Permanently" the default one.
project
- the project to be checkedinteractive
- ask for permission from UI.public static GradleCommandLine getDefaultCommandLine(Project project)
@Deprecated public static File evaluateGradleDistribution(Project project, boolean forceCompatibility)
public static String[] evaluateActionArgs(Project project, String action, String argLine, Lookup context)
argLine
provided by the project
for
the action using the given context;project
- the that holds the ReplaceTokenProvider
-s.argLine
- a string which might hold tokens to be replaced.action
- the action name to do the replacement for. It can be null
context
- the context of the action.argLine
where the tokens are replaced.public static ReplaceTokenProvider simpleReplaceTokenProvider(String token, String value)
public static ProjectActionMappingProvider findActionProvider(Project p, Lookup context)
ProjectConfiguration
s, so the returned provider willp
- the projectcontext
- the action invocation context@Deprecated public static Pair getActivePlatform(String activePlatformId)
null
if the active project platform is broken.
As this module is no longer dependent on the java platform module,
this method always returns null
as a platform since 2.3activePlatformId
- the name of platform used by Ant script or null
for default platform.@Deprecated public static Pair getActivePlatform(Project project)
null
as a platform since 2.3project
- the project to check.public static JavaRuntimeManager.JavaRuntime getActiveRuntime(Project project)
It is possible that the ID representing the project runtime, has no associated runtime in the IDE. In this case a broken JavaRuntime would be returned with the ID, that would be used.
project
- the project which root project specifies the runtime.null
public static void setActiveRuntime(Project project, JavaRuntimeManager.JavaRuntime runtime)
project
- the project , which root project shall be set the runtime onruntime
- The JavaRuntime to activate on the project or null
can be used to set the default runtime.