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 storePaswordInClearText = 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', name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be username ?

if (password) args '-Passsword', password
Copy link
Contributor

@gluck gluck Jan 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo still (-Passs vs -Pass)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still the '-Passs' typo here, no ?

if (configFile) args '-ConfigFile', configFile
if (storePaswordInClearText) args '-StorePaswordInClearText'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo as well (pas vs pass)

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