Class StartParameter
- java.lang.Object
-
- org.gradle.StartParameter
-
- All Implemented Interfaces:
Serializable,LoggingConfiguration,ParallelismConfiguration
public class StartParameter extends Object implements LoggingConfiguration, ParallelismConfiguration, Serializable
StartParameterdefines the configuration used by a Gradle instance to execute a build. The properties ofStartParametergenerally correspond to the command-line options of Gradle.You can obtain an instance of a
StartParameterby either creating a new one, or duplicating an existing one usingnewInstance()ornewBuild().- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static FileDEFAULT_GRADLE_USER_HOMEThe default user home directory.static StringGRADLE_USER_HOME_PROPERTY_KEYprotected FilegradleHomeDir
-
Constructor Summary
Constructors Constructor Description StartParameter()Creates aStartParameterwith default values.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddInitScript(File initScriptFile)Adds the given file to the list of init scripts that are run before the build starts.booleanequals(Object obj)List<File>getAllInitScripts()Returns all init scripts, including explicit init scripts and implicit init scripts.FilegetBuildFile()Returns the build file to use to select the default project.ConsoleOutputgetConsoleOutput()Returns the style of logging output that should be written to the console.FilegetCurrentDir()Returns the directory to use to select the default project, and to search for the settings file.Set<String>getExcludedTaskNames()Returns the names of the tasks to be excluded from this build.FilegetGradleUserHomeDir()Returns the directory to use as the user home directory.List<File>getIncludedBuilds()List<File>getInitScripts()Returns all explicitly added init scripts that will be run before the build starts.List<String>getLockedDependenciesToUpdate()Returns the list of modules that are to be allowed to update their version compared to the lockfile.LogLevelgetLogLevel()Returns the minimum logging level to use.intgetMaxWorkerCount()Returns the maximum number of concurrent workers used for underlying build operations.FilegetProjectCacheDir()Returns the project's cache dir.FilegetProjectDir()Returns the project dir to use to select the default project.Map<String,String>getProjectProperties()FilegetSettingsFile()Returns the explicit settings file to use for the build, or null.ShowStacktracegetShowStacktrace()Returns the detail that should be included in stacktraces.Map<String,String>getSystemPropertiesArgs()List<String>getTaskNames()Returns the names of the tasks to execute in this build.List<TaskExecutionRequest>getTaskRequests()Returns the tasks to execute in this build.WarningModegetWarningMode()Specifies which type of warnings should be written to the console.inthashCode()voidincludeBuild(File includedBuild)booleanisBuildCacheDebugLogging()Whether build cache debug logging is enabled.booleanisBuildCacheEnabled()Returns true if the build cache is enabled.booleanisBuildProjectDependencies()Returns true if project dependencies are to be built, false if they should not be.booleanisBuildScan()Returns true if build scan should be created.booleanisConfigureOnDemand()If the configure-on-demand mode is activebooleanisContinueOnFailure()Specifies whether the build should continue on task failure.booleanisContinuous()booleanisDryRun()booleanisInteractive()Deprecated.This flag is no longer used and simply defaults to 'false'.booleanisNoBuildScan()Returns true when build scan creation is explicitly disabled.booleanisOffline()Specifies whether the build should be performed offline (ie without network access).booleanisParallelProjectExecutionEnabled()Returns true if parallel project execution is enabled.booleanisProfile()Returns true if a profile report will be generated.booleanisRecompileScripts()Deprecated.This flag is no longer used.booleanisRefreshDependencies()Specifies whether the dependencies should be refreshed..booleanisRerunTasks()Specifies whether the cached task results should be ignored and each task should be forced to be executed.booleanisSearchUpwards()booleanisUseEmptySettings()Returns whether an empty settings script will be used regardless of whether one exists in the default location.booleanisWriteDependencyLocks()Returns true when dependency resolution is to be persisted for lockingStartParameternewBuild()Creates the parameters for a new build, using these parameters as a template.StartParameternewInstance()Duplicates thisStartParameterinstance.protected StartParameterprepareNewBuild(StartParameter p)protected StartParameterprepareNewInstance(StartParameter p)voidsetBuildCacheDebugLogging(boolean buildCacheDebugLogging)Whether build cache debug logging is enabled.voidsetBuildCacheEnabled(boolean buildCacheEnabled)Enables/disables the build cache.voidsetBuildFile(File buildFile)Sets the build file to use to select the default project.StartParametersetBuildProjectDependencies(boolean build)Specifies whether project dependencies should be built.voidsetBuildScan(boolean buildScan)Specifies whether a build scan should be created.voidsetConfigureOnDemand(boolean configureOnDemand)voidsetConsoleOutput(ConsoleOutput consoleOutput)Specifies the style of logging output that should be written to the console.voidsetContinueOnFailure(boolean continueOnFailure)Specifies whether the build should continue on task failure.voidsetContinuous(boolean enabled)voidsetCurrentDir(File currentDir)Sets the directory to use to select the default project, and to search for the settings file.voidsetDryRun(boolean dryRun)voidsetExcludedTaskNames(Iterable<String> excludedTaskNames)Sets the tasks to exclude from this build.voidsetGradleUserHomeDir(File gradleUserHomeDir)Sets the directory to use as the user home directory.voidsetIncludedBuilds(List<File> includedBuilds)voidsetInitScripts(List<File> initScripts)Sets the list of init scripts to be run before the build starts.voidsetInteractive(boolean interactive)Deprecated.This flag is no longer used.voidsetLockedDependenciesToUpdate(List<String> lockedDependenciesToUpdate)Indicates that specified dependencies are to be allowed to update their version.voidsetLogLevel(LogLevel logLevel)Specifies the minimum logging level to use.voidsetMaxWorkerCount(int maxWorkerCount)Specifies the maximum number of concurrent workers used for underlying build operations.voidsetNoBuildScan(boolean noBuildScan)Specifies whether build scan creation is explicitly disabled.voidsetOffline(boolean offline)Specifies whether the build should be performed offline (ie without network access).voidsetParallelProjectExecutionEnabled(boolean parallelProjectExecution)Enables/disables parallel project execution.voidsetProfile(boolean profile)Specifies if a profile report should be generated.voidsetProjectCacheDir(File projectCacheDir)Sets the project's cache location.voidsetProjectDir(File projectDir)Sets the project directory to use to select the default project.voidsetProjectProperties(Map<String,String> projectProperties)voidsetRecompileScripts(boolean recompileScripts)Deprecated.This flag is no longer used and simply defaults to 'false'.voidsetRefreshDependencies(boolean refreshDependencies)Specifies whether the dependencies should be refreshed..voidsetRerunTasks(boolean rerunTasks)Specifies whether the cached task results should be ignored and each task should be forced to be executed.voidsetSearchUpwards(boolean searchUpwards)voidsetSettingsFile(File settingsFile)Sets the settings file to use for the build.voidsetShowStacktrace(ShowStacktrace showStacktrace)Sets the detail that should be included in stacktraces.voidsetSystemPropertiesArgs(Map<String,String> systemPropertiesArgs)voidsetTaskNames(Iterable<String> taskNames)Sets the tasks to execute in this build.voidsetTaskRequests(Iterable<? extends TaskExecutionRequest> taskParameters)Sets the task parameters to execute in this build.voidsetWarningMode(WarningMode warningMode)Specifies which type of warnings should be written to the console.voidsetWriteDependencyLocks(boolean writeDependencyLocks)Specifies whether dependency resolution needs to be persisted for lockingStringtoString()StartParameteruseEmptySettings()Specifies that an empty settings script should be used.
-
-
-
Field Detail
-
GRADLE_USER_HOME_PROPERTY_KEY
public static final String GRADLE_USER_HOME_PROPERTY_KEY
- See Also:
- Constant Field Values
-
DEFAULT_GRADLE_USER_HOME
public static final File DEFAULT_GRADLE_USER_HOME
The default user home directory.
-
gradleHomeDir
protected File gradleHomeDir
-
-
Method Detail
-
getLogLevel
public LogLevel getLogLevel()
Returns the minimum logging level to use. All log messages with a lower log level are ignored. Defaults toLogLevel.LIFECYCLE.- Specified by:
getLogLevelin interfaceLoggingConfiguration
-
setLogLevel
public void setLogLevel(LogLevel logLevel)
Specifies the minimum logging level to use. All log messages with a lower log level are ignored.- Specified by:
setLogLevelin interfaceLoggingConfiguration
-
getShowStacktrace
public ShowStacktrace getShowStacktrace()
Returns the detail that should be included in stacktraces. Defaults toShowStacktrace.INTERNAL_EXCEPTIONS.- Specified by:
getShowStacktracein interfaceLoggingConfiguration
-
setShowStacktrace
public void setShowStacktrace(ShowStacktrace showStacktrace)
Sets the detail that should be included in stacktraces.- Specified by:
setShowStacktracein interfaceLoggingConfiguration
-
getConsoleOutput
public ConsoleOutput getConsoleOutput()
Returns the style of logging output that should be written to the console. Defaults toConsoleOutput.Auto- Specified by:
getConsoleOutputin interfaceLoggingConfiguration
-
setConsoleOutput
public void setConsoleOutput(ConsoleOutput consoleOutput)
Specifies the style of logging output that should be written to the console.- Specified by:
setConsoleOutputin interfaceLoggingConfiguration
-
getWarningMode
public WarningMode getWarningMode()
Specifies which type of warnings should be written to the console.- Specified by:
getWarningModein interfaceLoggingConfiguration
-
setWarningMode
public void setWarningMode(WarningMode warningMode)
Specifies which type of warnings should be written to the console.- Specified by:
setWarningModein interfaceLoggingConfiguration
-
setProjectCacheDir
public void setProjectCacheDir(@Nullable File projectCacheDir)
Sets the project's cache location. Set to null to use the default location.
-
getProjectCacheDir
@Nullable public File getProjectCacheDir()
Returns the project's cache dir.- Returns:
- project's cache dir, or null if the default location is to be used.
-
newInstance
public StartParameter newInstance()
Duplicates thisStartParameterinstance.- Returns:
- the new parameters.
-
prepareNewInstance
protected StartParameter prepareNewInstance(StartParameter p)
-
newBuild
public StartParameter newBuild()
Creates the parameters for a new build, using these parameters as a template. Copies the environmental properties from this parameter (eg Gradle user home dir, etc), but does not copy the build specific properties (eg task names).
- Returns:
- The new parameters.
-
prepareNewBuild
protected StartParameter prepareNewBuild(StartParameter p)
-
getBuildFile
@Nullable public File getBuildFile()
Returns the build file to use to select the default project. Returns null when the build file is not used to select the default project.- Returns:
- The build file. May be null.
-
setBuildFile
public void setBuildFile(@Nullable File buildFile)
Sets the build file to use to select the default project. Use null to disable selecting the default project using the build file.- Parameters:
buildFile- The build file. May be null.
-
useEmptySettings
public StartParameter useEmptySettings()
Specifies that an empty settings script should be used. This means that even if a settings file exists in the conventional location, or has been previously specified bysetSettingsFile(File), it will not be used. IfsetSettingsFile(File)is called after this, it will supersede calling this method.- Returns:
- this
-
isUseEmptySettings
public boolean isUseEmptySettings()
Returns whether an empty settings script will be used regardless of whether one exists in the default location.- Returns:
- Whether to use empty settings or not.
-
getTaskNames
public List<String> getTaskNames()
Returns the names of the tasks to execute in this build. When empty, the default tasks for the project will be executed. IfTaskExecutionRequests are set for this build then names from these task parameters are returned.- Returns:
- the names of the tasks to execute in this build. Never returns null.
-
setTaskNames
public void setTaskNames(@Nullable Iterable<String> taskNames)
Sets the tasks to execute in this build. Set to an empty list, or null, to execute the default tasks for the project. The tasks are executed in the order provided, subject to dependency between the tasks.
- Parameters:
taskNames- the names of the tasks to execute in this build.
-
getTaskRequests
public List<TaskExecutionRequest> getTaskRequests()
Returns the tasks to execute in this build. When empty, the default tasks for the project will be executed.- Returns:
- the tasks to execute in this build. Never returns null.
-
setTaskRequests
public void setTaskRequests(Iterable<? extends TaskExecutionRequest> taskParameters)
Sets the task parameters to execute in this build. Set to an empty list, to execute the default tasks for the project. The tasks are executed in the order provided, subject to dependency between the tasks.
- Parameters:
taskParameters- the tasks to execute in this build.
-
getExcludedTaskNames
public Set<String> getExcludedTaskNames()
Returns the names of the tasks to be excluded from this build. When empty, no tasks are excluded from the build.- Returns:
- The names of the excluded tasks. Returns an empty set if there are no such tasks.
-
setExcludedTaskNames
public void setExcludedTaskNames(Iterable<String> excludedTaskNames)
Sets the tasks to exclude from this build.- Parameters:
excludedTaskNames- The task names.
-
getCurrentDir
public File getCurrentDir()
Returns the directory to use to select the default project, and to search for the settings file.- Returns:
- The current directory. Never returns null.
-
setCurrentDir
public void setCurrentDir(@Nullable File currentDir)
Sets the directory to use to select the default project, and to search for the settings file. Set to null to use the default current directory.- Parameters:
currentDir- The directory. Set to null to use the default.
-
isSearchUpwards
public boolean isSearchUpwards()
-
setSearchUpwards
public void setSearchUpwards(boolean searchUpwards)
-
setSystemPropertiesArgs
public void setSystemPropertiesArgs(Map<String,String> systemPropertiesArgs)
-
getGradleUserHomeDir
public File getGradleUserHomeDir()
Returns the directory to use as the user home directory.- Returns:
- The home directory.
-
setGradleUserHomeDir
public void setGradleUserHomeDir(@Nullable File gradleUserHomeDir)
Sets the directory to use as the user home directory. Set to null to use the default directory.- Parameters:
gradleUserHomeDir- The home directory. May be null.
-
isBuildProjectDependencies
public boolean isBuildProjectDependencies()
Returns true if project dependencies are to be built, false if they should not be. The default is true.
-
setBuildProjectDependencies
public StartParameter setBuildProjectDependencies(boolean build)
Specifies whether project dependencies should be built. Defaults to true.- Returns:
- this
-
isDryRun
public boolean isDryRun()
-
setDryRun
public void setDryRun(boolean dryRun)
-
setSettingsFile
public void setSettingsFile(@Nullable File settingsFile)
Sets the settings file to use for the build. Use null to use the default settings file.- Parameters:
settingsFile- The settings file to use. May be null.
-
getSettingsFile
@Nullable public File getSettingsFile()
Returns the explicit settings file to use for the build, or null. Will return null if the default settings file is to be used. However, ifisUseEmptySettings()returns true, then no settings file at all will be used.- Returns:
- The settings file. May be null.
- See Also:
isUseEmptySettings()
-
addInitScript
public void addInitScript(File initScriptFile)
Adds the given file to the list of init scripts that are run before the build starts. This list is in addition to the default init scripts.- Parameters:
initScriptFile- The init scripts.
-
setInitScripts
public void setInitScripts(List<File> initScripts)
Sets the list of init scripts to be run before the build starts. This list is in addition to the default init scripts.- Parameters:
initScripts- The init scripts.
-
getInitScripts
public List<File> getInitScripts()
Returns all explicitly added init scripts that will be run before the build starts. This list does not contain the user init script located in ${user.home}/.gradle/init.gradle, even though that init script will also be run.- Returns:
- list of all explicitly added init scripts.
-
getAllInitScripts
public List<File> getAllInitScripts()
Returns all init scripts, including explicit init scripts and implicit init scripts.- Returns:
- All init scripts, including explicit init scripts and implicit init scripts.
-
setProjectDir
public void setProjectDir(@Nullable File projectDir)
Sets the project directory to use to select the default project. Use null to use the default criteria for selecting the default project.- Parameters:
projectDir- The project directory. May be null.
-
getProjectDir
@Nullable public File getProjectDir()
Returns the project dir to use to select the default project. Returns null when the build file is not used to select the default project- Returns:
- The project dir. May be null.
-
setProfile
public void setProfile(boolean profile)
Specifies if a profile report should be generated.- Parameters:
profile- true if a profile report should be generated
-
isProfile
public boolean isProfile()
Returns true if a profile report will be generated.
-
isContinueOnFailure
public boolean isContinueOnFailure()
Specifies whether the build should continue on task failure. The default is false.
-
setContinueOnFailure
public void setContinueOnFailure(boolean continueOnFailure)
Specifies whether the build should continue on task failure. The default is false.
-
isOffline
public boolean isOffline()
Specifies whether the build should be performed offline (ie without network access).
-
setOffline
public void setOffline(boolean offline)
Specifies whether the build should be performed offline (ie without network access).
-
isRefreshDependencies
public boolean isRefreshDependencies()
Specifies whether the dependencies should be refreshed..
-
setRefreshDependencies
public void setRefreshDependencies(boolean refreshDependencies)
Specifies whether the dependencies should be refreshed..
-
isRerunTasks
public boolean isRerunTasks()
Specifies whether the cached task results should be ignored and each task should be forced to be executed.
-
setRerunTasks
public void setRerunTasks(boolean rerunTasks)
Specifies whether the cached task results should be ignored and each task should be forced to be executed.
-
isRecompileScripts
@Deprecated public boolean isRecompileScripts()
Deprecated.This flag is no longer used.Specifies whether to force the build scripts to be recompiled.
-
setRecompileScripts
@Deprecated public void setRecompileScripts(boolean recompileScripts)
Deprecated.This flag is no longer used and simply defaults to 'false'.Specifies whether to force the build scripts to be recompiled.
-
isParallelProjectExecutionEnabled
public boolean isParallelProjectExecutionEnabled()
Returns true if parallel project execution is enabled.- Specified by:
isParallelProjectExecutionEnabledin interfaceParallelismConfiguration- See Also:
ParallelismConfiguration.getMaxWorkerCount()
-
setParallelProjectExecutionEnabled
public void setParallelProjectExecutionEnabled(boolean parallelProjectExecution)
Enables/disables parallel project execution.- Specified by:
setParallelProjectExecutionEnabledin interfaceParallelismConfiguration- See Also:
ParallelismConfiguration.isParallelProjectExecutionEnabled()
-
isBuildCacheEnabled
public boolean isBuildCacheEnabled()
Returns true if the build cache is enabled.- Since:
- 3.5
-
setBuildCacheEnabled
public void setBuildCacheEnabled(boolean buildCacheEnabled)
Enables/disables the build cache.- Since:
- 3.5
-
isBuildCacheDebugLogging
@Incubating public boolean isBuildCacheDebugLogging()
Whether build cache debug logging is enabled.- Since:
- 4.6
-
setBuildCacheDebugLogging
@Incubating public void setBuildCacheDebugLogging(boolean buildCacheDebugLogging)
Whether build cache debug logging is enabled.- Since:
- 4.6
-
getMaxWorkerCount
public int getMaxWorkerCount()
Returns the maximum number of concurrent workers used for underlying build operations. Workers can be threads, processes or whatever Gradle considers a "worker". Some examples:- A thread running a task
- A test process
- A language compiler in a forked process
- Specified by:
getMaxWorkerCountin interfaceParallelismConfiguration- Returns:
- maximum number of concurrent workers, always >= 1.
- See Also:
Runtime.availableProcessors()
-
setMaxWorkerCount
public void setMaxWorkerCount(int maxWorkerCount)
Specifies the maximum number of concurrent workers used for underlying build operations.- Specified by:
setMaxWorkerCountin interfaceParallelismConfiguration- See Also:
ParallelismConfiguration.getMaxWorkerCount()
-
isConfigureOnDemand
@Incubating public boolean isConfigureOnDemand()
If the configure-on-demand mode is active
-
setConfigureOnDemand
@Incubating public void setConfigureOnDemand(boolean configureOnDemand)
-
isContinuous
public boolean isContinuous()
-
setContinuous
public void setContinuous(boolean enabled)
-
includeBuild
public void includeBuild(File includedBuild)
-
isBuildScan
public boolean isBuildScan()
Returns true if build scan should be created.- Since:
- 3.4
-
setBuildScan
public void setBuildScan(boolean buildScan)
Specifies whether a build scan should be created.- Since:
- 3.4
-
isNoBuildScan
public boolean isNoBuildScan()
Returns true when build scan creation is explicitly disabled.- Since:
- 3.4
-
setNoBuildScan
public void setNoBuildScan(boolean noBuildScan)
Specifies whether build scan creation is explicitly disabled.- Since:
- 3.4
-
isInteractive
@Deprecated public boolean isInteractive()
Deprecated.This flag is no longer used and simply defaults to 'false'.Returns true when console is interactive.- Since:
- 4.3
-
setInteractive
@Deprecated public void setInteractive(boolean interactive)
Deprecated.This flag is no longer used.Specifies whether console is interactive.- Since:
- 4.3
-
setWriteDependencyLocks
@Incubating public void setWriteDependencyLocks(boolean writeDependencyLocks)
Specifies whether dependency resolution needs to be persisted for locking- Since:
- 4.8
-
isWriteDependencyLocks
@Incubating public boolean isWriteDependencyLocks()
Returns true when dependency resolution is to be persisted for locking- Since:
- 4.8
-
setLockedDependenciesToUpdate
@Incubating public void setLockedDependenciesToUpdate(List<String> lockedDependenciesToUpdate)
Indicates that specified dependencies are to be allowed to update their version. Implicitly activates dependency locking persistence.- Parameters:
lockedDependenciesToUpdate- the modules to update- Since:
- 4.8
- See Also:
isWriteDependencyLocks()
-
getLockedDependenciesToUpdate
@Incubating public List<String> getLockedDependenciesToUpdate()
Returns the list of modules that are to be allowed to update their version compared to the lockfile.- Returns:
- a list of modules allowed to have a version update
- Since:
- 4.8
-
-