@groovy.transform.CompileStatic @groovy.util.logging.Slf4j class NpmExtension extends org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension
Set up global config or task-based config for NPM.
| Fields inherited from class | Fields |
|---|---|
class org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension |
__$stMC, __$stMC |
| Type | Name and description |
|---|---|
static java.lang.String |
NAME |
java.io.File |
globalConfig |
java.io.File |
homeDirectory |
java.io.File |
localConfig |
| Constructor and description |
|---|
NpmExtension
(org.gradle.api.Project project)Adds the extension to the project. |
NpmExtension
(org.gradle.api.Project project, NodeJSExtension nodejs)Adds the extension to the project. |
NpmExtension
(org.gradle.api.Task task)Adds the extension to a NpmTask task. |
NpmExtension
(org.gradle.api.Task task, NodeJSExtension nodejs, NpmExtension altNpmExt)Adds the extension to a NpmTask task. |
protected NpmExtension
(org.gradle.api.Task task, java.lang.String projectExtName)Constructs a new extension which is attached to the provided task. |
protected NpmExtension
(org.gradle.api.Task task, java.lang.Class<? super NpmExtension> extClass)Constructs a new extension which is attached to the provided task. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
NpmExecSpec |
createExecSpec()Create execution specification. |
|
java.util.Map<java.lang.String, java.lang.Object> |
defaultNodejs()Sets NPM to be resolved from the default node.js distribution associated with this project. |
|
void |
executable(java.util.Map<java.lang.String, java.lang.Object> opts) |
|
void |
executableIsBundled()Use the NPM that is bundled with Node. |
|
protected org.ysb33r.grolifant.api.v4.runnable.ExecutableDownloader |
getDownloader()Gets the downloader implementation. |
|
java.io.File |
getGlobalConfig()Location & name of global NPM config file. |
|
java.io.File |
getHomeDirectory()The NPM home directory - the parent directory of node_modules, |
|
org.gradle.api.provider.Provider<java.io.File> |
getHomeDirectoryProvider()The NPM home directory - the parent directory of node_modules, |
|
java.io.File |
getLocalConfig()Location & name of local NPM config file. |
|
protected java.lang.String |
getNodeJsExtensionName()Returns the name of the extension to look for when trying to find the Node.js extension. |
|
protected java.lang.String |
getNpmProjectExtensionName()Returns the name of the extension to look for when trying to find the Npm extension. |
|
org.gradle.api.provider.Provider<java.io.File> |
getNpxCliJsProvider()The location of NPX. |
|
org.gradle.api.provider.Provider<java.io.File> |
getProjectConfig()Location of .npmrc for a project. |
|
org.ysb33r.grolifant.api.v4.exec.ResolvableExecutable |
getResolvedNpmCliJs()Resolves a path to a npm-cli.js executable. |
|
org.ysb33r.grolifant.api.v4.exec.ResolvableExecutable |
getResolvedNpxCliJs()Resolves a path to a npx-cli.js executable. |
|
void |
globalConfig(java.lang.Object path)Set global config file. |
|
void |
homeDirectory(java.lang.Object homeDir)Sets the home directory. |
|
void |
localConfig(java.lang.Object path)Set local config file. |
|
protected java.lang.String |
runExecutableAndReturnVersion()Runs the executable and returns the version. |
|
java.util.Map<java.lang.String, java.lang.Object> |
searchPath()Use this to configure a system path search for npm |
|
void |
setGlobalConfig(java.lang.Object path)Set global config file. |
|
void |
setHomeDirectory(java.lang.Object homeDir)Sets the home directory. |
|
void |
setLocalConfig(java.lang.Object path)Set local config file. |
|
org.gradle.api.provider.Provider<java.io.File> |
useGlobalGradleLocation()Sets it to use the equivalent of getGradleHomeDir()/.npmrc. |
|
org.gradle.api.provider.Provider<java.io.File> |
useGlobalSystemLocation()Tries to determine the location where global config will typically be places. |
|
org.gradle.api.provider.Provider<java.io.File> |
useLocalProjectLocation()Use to indicate that userconfig should be retrieved from the NPM home directory as configured by getHomeDirectory(). |
|
org.gradle.api.provider.Provider<java.io.File> |
useLocalUserProfileLocation()Use to indicate that userconfig should be retrieved from the user's home directory. |
| Methods inherited from class | Name |
|---|---|
class org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension |
org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#pfaccess$0(org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#access$0(org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#this$dist$invoke$2(java.lang.String, java.lang.Object), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#this$dist$set$2(java.lang.String, java.lang.Object), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#this$dist$get$2(java.lang.String), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#access$1(org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#executableByVersion(java.lang.Object), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#executableBySearchPath(java.lang.Object), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#setWindowsExtensionSearchOrder([Ljava.lang.String;), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#setWindowsExtensionSearchOrder(java.lang.Iterable), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#getWindowsExtensionSearchOrder(), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#resolvedExecutableVersion(), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#executableByPath(java.lang.Object), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#getExecutable(), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#getProjectOperations(), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#invokeMethod(java.lang.String, java.lang.Object), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#getMetaClass(), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#setMetaClass(groovy.lang.MetaClass), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#setProperty(java.lang.String, java.lang.Object), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#getProperty(java.lang.String), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#wait(long, int), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#wait(long), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#wait(), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#equals(java.lang.Object), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#toString(), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#hashCode(), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#getClass(), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#notify(), org.ysb33r.grolifant.api.v4.runnable.AbstractToolExtension#notifyAll() |
Adds the extension to the project.
project - Project to link to.Adds the extension to the project.
project - Project to link to.nodejs - Alternative NodeJS extension to use.Adds the extension to a NpmTask task.
Links the executable resolving to the global instance, but allows it to be overridden on a per-task basis.
task - Task to be extended.Adds the extension to a NpmTask task.
Links the executable resolving to the global instance, but allows it to be overridden on a per-task basis.
task - Task to be extended.nodejs - Alternative NodeJS extension to use as project extension.altNpmExt - Alternative Npm extension to use as project extension.Constructs a new extension which is attached to the provided task. This is meant for other plugins that want to provide their own NpmExtension implementation
project - Project this extension is associated with.projectExtName - Name of the extension that is attached to the project.Constructs a new extension which is attached to the provided task. This is meant for other plugins that want to provide their own NpmExtension implementation
Task - Task this extension is associated with.extClass - Type of the extension that is attached to the project.Create execution specification.
Sets NPM to be resolved from the default node.js distribution associated with this project. @executable
Use the NPM that is bundled with Node. This is the default and should raely be required.
Gets the downloader implementation. Can throw an exception if downloading is not supported.
Location & name of global NPM config file.
When this extension is attached to a project, the default location is set to
"${project.gradle.gradleUserHomeDir/npmrc"}
The NPM home directory - the parent directory of node_modules,
node_modules. Never null if the extension is tied to a project,
in which case it defaults to project.projectDir. The NPM home directory - the parent directory of node_modules,
node_modules. Never null if the extension is tied to a project,
in which case it defaults to project.projectDir. Location & name of local NPM config file.
When this extension is attached to a project, the default location is set to
"${project.rootProject.projectDir/npmrc"}
Returns the name of the extension to look for when trying to find the Node.js extension.
Returns the name of the extension to look for when trying to find the Npm extension.
The location of NPX.
Location of .npmrc for a project.
Resolves a path to a npm-cli.js executable.
If the extension is linked to a task and not the location not configured,
a lookup will be performed on the project extension of the same name. This is an alias
method for getResolvableExecutable( )
npm-cli.js executable.ExecConfigurationException if location was not configured. Resolves a path to a npx-cli.js executable.
If the extension is linked to a task and not the location not configured,
a lookup will be performed on the project extension of the same name. This is an alias
method for getResolvableExecutable( )
npx-cli.js executable.ExecConfigurationException if location was not configured.Set global config file.
path - Anything that can be converted using project.file.Sets the home directory.
homeDir - A directory in which node_modules will be created as a child folder.
Anything that can be resolved with project.file is acceptableSet local config file.
path - Anything that can be converted using project.file.Runs the executable and returns the version. See org.ysb33r.grolifant.api.v4.runnable.ExecUtils#parseVersionFromOutput as a helper to implement this method.
Use this to configure a system path search for npm
Set global config file.
path - Anything that can be converted using project.file.Sets the home directory.
homeDir - A directory in which node_modules will be created as a child folder.
Anything that can be resolved with project.file is acceptableSet local config file.
path - Anything that can be converted using project.file. Sets it to use the equivalent of getGradleHomeDir()/.npmrc.
This allows Gradle projects to be custom configured on local system without being affected by any system-wide
node installations.
Tries to determine the location where global config will typically be places.
Use to indicate that userconfig should be retrieved from the NPM home directory as configured by getHomeDirectory().
.npmrc Use to indicate that userconfig should be retrieved from the user's home directory.
Typically this is ~/.npmrc or %APPDATA\npm\.npmrc
.npmrcGroovy Documentation