Skip to content

Commit

Permalink
Merge pull request #58 from darsen/master
Browse files Browse the repository at this point in the history
NuGetSources task
  • Loading branch information
gluck committed Jan 5, 2018
2 parents e0261b6 + 3f1e8a8 commit 1fa864a
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ You can see this plugin being used for real on [il-repack](https://github.com/gl
- solutionDirectory - could either contain the .sln file or the repositories.config file
- packagesDirectory - used only if a folder with repositories.config is used

## nugetSources

Nuget sources is used to add, remove, enable, disable nuget feeds

- Sample usage:

nugetSources {
operation = 'add'
sourceName = 'localNuGetFeed'
sourceUrl = 'http://foo.com'
}

Where
- operation - could be add, remove, enable, disable and list
- sourceName - name of the nuget feed
- sourceUrl - url of the nuget feed

# See also

[Gradle Msbuild plugin](https://github.com/Ullink/gradle-msbuild-plugin) - Allows to build VS projects & solutions.
Expand Down
4 changes: 4 additions & 0 deletions src/main/groovy/com/ullink/NuGetPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class NuGetPlugin implements Plugin<Project> {
group = BasePlugin.UPLOAD_GROUP
description = 'Pushes the NuGet package to the configured server url.'
}

project.task('nugetSources', type: NuGetSources) {
description = 'Adds, removes, enables, disables and lists nuget sources (feeds).'
}
}
}

42 changes: 42 additions & 0 deletions src/main/groovy/com/ullink/NuGetSources.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.ullink

import org.gradle.api.GradleException

class NuGetSources extends BaseNuGet {

enum Operation{
add, remove, enable, disable, list
}

Operation operation
def sourceName
def sourceUrl
def username
def password
def configFile
def storePasswordInClearText = false

NuGetSources() {
super('sources')
project.afterEvaluate{
if(!operation){
throw new GradleException('Operation not specified for NuGetSources task.')
}
if(operation != Operation.list && !sourceName){
throw new GradleException('SourceName not specified for NuGetSources task.')
}
}
}

@Override
void exec() {
args operation
if (sourceName) args '-Name', sourceName
if (sourceUrl) args '-Source', sourceUrl
if (username) args '-UserName', username
if (password) args '-Password', password
if (configFile) args '-ConfigFile', configFile
if (storePasswordInClearText) args '-StorePasswordInClearText'
super.exec()
}
}
1 change: 1 addition & 0 deletions src/test/groovy/com/ullink/NuGetPluginTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class NuGetPluginTest {
assertTrue(project.tasks.nugetPack instanceof NuGetPack)
assertTrue(project.tasks.nugetPush instanceof NuGetPush)
assertTrue(project.tasks.nugetSpec instanceof NuGetSpec)
assertTrue(project.tasks.nugetSources instanceof NuGetSources)
}

@Test
Expand Down

0 comments on commit 1fa864a

Please sign in to comment.