diff --git a/README.md b/README.md index dccb05b..5d8c026 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/src/main/groovy/com/ullink/NuGetPlugin.groovy b/src/main/groovy/com/ullink/NuGetPlugin.groovy index cf21e79..a130ebe 100644 --- a/src/main/groovy/com/ullink/NuGetPlugin.groovy +++ b/src/main/groovy/com/ullink/NuGetPlugin.groovy @@ -27,6 +27,10 @@ class NuGetPlugin implements Plugin { 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).' + } } } diff --git a/src/main/groovy/com/ullink/NuGetSources.groovy b/src/main/groovy/com/ullink/NuGetSources.groovy new file mode 100644 index 0000000..bd3322b --- /dev/null +++ b/src/main/groovy/com/ullink/NuGetSources.groovy @@ -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() + } +} diff --git a/src/test/groovy/com/ullink/NuGetPluginTest.groovy b/src/test/groovy/com/ullink/NuGetPluginTest.groovy index eece907..ef852dd 100644 --- a/src/test/groovy/com/ullink/NuGetPluginTest.groovy +++ b/src/test/groovy/com/ullink/NuGetPluginTest.groovy @@ -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