Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NuGetSources task #58

Merged
merged 18 commits into from
Jan 5, 2018
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