Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions src/main/groovy/com/moowork/gradle/node/NodeExtension.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package com.moowork.gradle.node

import com.moowork.gradle.node.variant.Variant
import org.gradle.api.Project
import org.gradle.api.Action
import org.gradle.api.credentials.Credentials
import org.gradle.api.artifacts.repositories.PasswordCredentials

class NodeExtension
{
Expand All @@ -17,6 +20,10 @@ class NodeExtension

def String distBaseUrl = 'https://nodejs.org/dist'

def Action<? super PasswordCredentials> distCredentialsAction = null

def Class distCredentialsType = PasswordCredentials

def String npmCommand = 'npm'

def boolean download = false
Expand All @@ -34,4 +41,41 @@ class NodeExtension
{
return project.extensions.getByType( NodeExtension )
}

void distCredentials( Class credentialsType, Action<? super Credentials> action )
{
this.distCredentialsType = credentialsType
this.distCredentialsAction = action
}

void distCredentials( Action<? super PasswordCredentials> action )
{
this.distCredentials( this.distCredentialsType, action )
}

class DistCredentials implements PasswordCredentials
{
def private String username = null
def private String password = null

public String getUsername()
{
return this.username
}

public String getPassword()
{
return this.password
}

public void setUsername(String userName)
{
this.username = userName
}

public void setPassword(String password)
{
this.password = password
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,13 @@ class SetupTask
url distUrl
layout 'pattern', {
artifact 'v[revision]/[artifact](-v[revision]-[classifier]).[ext]'
ivy 'v[revision]/ivy.xml'
}
}

if ( this.config.distCredentialsAction != null )
{
this.repo.credentials( this.config.distCredentialsType, this.config.distCredentialsAction )
}
}

private void restoreRepositories()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.moowork.gradle.node

import org.gradle.api.artifacts.repositories.PasswordCredentials

class NodeExtensionTest
extends AbstractProjectTest
{
Expand All @@ -13,6 +15,8 @@ class NodeExtensionTest
ext != null
ext.npmCommand == 'npm'
ext.distBaseUrl == 'https://nodejs.org/dist'
ext.distCredentialsType == PasswordCredentials
ext.distCredentialsAction == null
ext.workDir != null
ext.nodeModulesDir != null
ext.version == '4.4.0'
Expand Down