diff --git a/CHANGELOG.md b/CHANGELOG.md index c10bfb1..adc2bf9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # gradle-nuget-plugin changelog +## 2.19 +### Changed +* Add Input and Output Annotations for Gradle 7 + +### Removed +* Due to conflict in Gradle 6.1, `timeout` in `nugetPush` is removed + ## 2.18 ### Changed * built with gradle 4.7 (above won't work till we migrate out of plugindev) diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7a3265e..f3d88b1 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d99ba9a..a2bf131 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Wed Dec 31 11:18:19 CET 2014 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.2.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip diff --git a/gradlew b/gradlew index cccdd3d..2fe81a7 100755 --- a/gradlew +++ b/gradlew @@ -1,5 +1,21 @@ #!/usr/bin/env sh +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + ############################################################################## ## ## Gradle start up script for UN*X @@ -28,7 +44,7 @@ APP_NAME="Gradle" APP_BASE_NAME=`basename "$0"` # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD="maximum" @@ -109,8 +125,8 @@ if $darwin; then GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" fi -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` JAVACMD=`cygpath --unix "$JAVACMD"` @@ -138,19 +154,19 @@ if $cygwin ; then else eval `echo args$i`="\"$arg\"" fi - i=$((i+1)) + i=`expr $i + 1` done case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; esac fi @@ -159,14 +175,9 @@ save () { for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done echo " " } -APP_ARGS=$(save "$@") +APP_ARGS=`save "$@"` # Collect all arguments for the java command, following the shell quoting and substitution rules eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index f955316..62bd9b9 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,3 +1,19 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + @if "%DEBUG%" == "" @echo off @rem ########################################################################## @rem @@ -13,8 +29,11 @@ if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @rem Find java.exe if defined JAVA_HOME goto findJavaFromJavaHome diff --git a/src/main/groovy/com/ullink/BaseNuGet.groovy b/src/main/groovy/com/ullink/BaseNuGet.groovy index 662fb98..1def4bd 100644 --- a/src/main/groovy/com/ullink/BaseNuGet.groovy +++ b/src/main/groovy/com/ullink/BaseNuGet.groovy @@ -7,7 +7,7 @@ import java.nio.file.Paths import static org.apache.tools.ant.taskdefs.condition.Os.* -public class BaseNuGet extends Exec { +class BaseNuGet extends Exec { private static final String NUGET_EXE = 'NuGet.exe' @Console @@ -16,7 +16,7 @@ public class BaseNuGet extends Exec { @Input String nugetExePath - public BaseNuGet() { + BaseNuGet() { } private File getNugetHome() { diff --git a/src/main/groovy/com/ullink/NuGetInstall.groovy b/src/main/groovy/com/ullink/NuGetInstall.groovy index dbc6608..f07cbaa 100644 --- a/src/main/groovy/com/ullink/NuGetInstall.groovy +++ b/src/main/groovy/com/ullink/NuGetInstall.groovy @@ -4,14 +4,17 @@ import org.gradle.api.tasks.*; class NuGetInstall extends BaseNuGet { + @Optional @Input - def packageId + String packageId + @Optional @InputFile File packagesConfigFile @Input def sources = [] as Set @OutputDirectory File outputDirectory + @Optional @Input def version @Input @@ -22,17 +25,36 @@ class NuGetInstall extends BaseNuGet { def noCache = false @Input def requireConsent = false + @Optional @InputDirectory File solutionDirectory + @Optional @Input def conflictAction + @Optional @Input - def configFile + File configFile NuGetInstall() { super('install') } + void setPackagesConfigFile(String path) { + packagesConfigFile = project.file(path) + } + + void setOutputDirectory(String path) { + outputDirectory = project.file(path) + } + + void setSolutionDirectory(String path) { + solutionDirectory = project.file(path) + } + + void setConfigFile(String path) { + configFile = project.file(path) + } + @Override void exec() { if (packageId) args packageId diff --git a/src/main/groovy/com/ullink/NuGetPack.groovy b/src/main/groovy/com/ullink/NuGetPack.groovy index 2e231c2..39a575d 100644 --- a/src/main/groovy/com/ullink/NuGetPack.groovy +++ b/src/main/groovy/com/ullink/NuGetPack.groovy @@ -9,16 +9,16 @@ import org.gradle.api.tasks.* class NuGetPack extends BaseNuGet { @Optional - @Input - def nuspecFile + @InputFile + File nuspecFile @Optional - @Input - def csprojPath + @InputFile + File csprojPath @OutputDirectory def destinationDir = project.convention.plugins.base.distsDir - @Input - def basePath + @InputFile + File basePath @Input def packageVersion @Optional @@ -62,6 +62,18 @@ class NuGetPack extends BaseNuGet { } } + void setDestinationDir(String path) { + destinationDir = project.file(path) + } + + void setNuspecFile(String path) { + nuspecFile = project.file(path) + } + + void setCsprojPath(String path) { + csprojPath = project.file(path) + } + @Override void exec() { args getNuspecOrCsproj() @@ -109,16 +121,12 @@ class NuGetPack extends BaseNuGet { } NuGetSpec getDependentNuGetSpec() { - dependsOn.find { it instanceof NuGetSpec } + dependsOn.find { it instanceof NuGetSpec } as NuGetSpec } // Because Nuget pack handle csproj or nuspec file we should be able to use it in plugin - @InputFile File getNuspecOrCsproj() { - if (csprojPath) { - return project.file(csprojPath) - } - getNuspecFile() + csprojPath ? csprojPath : getNuspecFile() } GPathResult getNuspec() { @@ -136,7 +144,7 @@ class NuGetPack extends BaseNuGet { File getNuspecFile() { if (nuspecFile) { - return project.file(this.nuspecFile) + return nuspecFile } if (dependentNuGetSpec) { return dependentNuGetSpec.nuspecFile diff --git a/src/main/groovy/com/ullink/NuGetPush.groovy b/src/main/groovy/com/ullink/NuGetPush.groovy index 56c539e..71de187 100644 --- a/src/main/groovy/com/ullink/NuGetPush.groovy +++ b/src/main/groovy/com/ullink/NuGetPush.groovy @@ -1,23 +1,47 @@ package com.ullink +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.Optional + class NuGetPush extends BaseNuGet { - def nupkgFile + @Optional + @InputFile + File nupkgFile + @Optional + @Input def serverUrl + @Optional + @InputFile def apiKey + @Optional + @InputFile def configFile NuGetPush() { super('push') } + void setNupkgFile(String path) { + nupkgFile = project.file(path) + } + + void setApiKey(String path) { + apiKey = project.file(path) + } + + void setConfigFile(String path) { + configFile = project.file(path) + } + String getNugetPackOutputFile() { if (dependentNuGetPack) dependentNuGetPack.packageFile } NuGetPack getDependentNuGetPack() { - dependsOn.find { it instanceof NuGetPack } + dependsOn.find { it instanceof NuGetPack } as NuGetPack } @Override diff --git a/src/main/groovy/com/ullink/NuGetRestore.groovy b/src/main/groovy/com/ullink/NuGetRestore.groovy index 0653bcf..ac72a4c 100644 --- a/src/main/groovy/com/ullink/NuGetRestore.groovy +++ b/src/main/groovy/com/ullink/NuGetRestore.groovy @@ -1,29 +1,61 @@ package com.ullink import com.ullink.util.GradleHelper -import org.gradle.api.UnknownTaskException +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputDirectory +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.Optional +import org.gradle.api.tasks.OutputDirectory class NuGetRestore extends BaseNuGet { - def solutionFile - def packagesConfigFile + @Optional + @InputFile + File solutionFile + @Optional + @InputFile + File packagesConfigFile + @Input def sources = [] as Set + @Input def noCache = false - def configFile + @InputFile + File configFile + @Input def requireConsent = false - def packagesDirectory - def solutionDirectory + @InputDirectory + File solutionDirectory + @Input def disableParallelProcessing = false + @Input def msBuildVersion + def packagesDirectory NuGetRestore() { super('restore') } + void setSolutionFile(String path) { + solutionFile = project.file(path) + } + + void setPackagesConfigFile(String path) { + packagesConfigFile = project.file(path) + } + + void setConfigFile(String path) { + configFile = project.file(path) + } + + void setSolutionDirectory(String path) { + solutionDirectory = project.file(path) + } + /** - * Only provided for backward compatibility. Uses 'sources' instead + * @Deprecated Only provided for backward compatibility. Uses 'sources' instead */ + @Deprecated def setSource(String source) { sources.clear() sources.add(source) @@ -51,7 +83,8 @@ class NuGetRestore extends BaseNuGet { super.exec() } - def getPackagesFolder() { + @OutputDirectory + File getPackagesFolder() { // https://docs.nuget.org/consume/command-line-reference#restore-command // If -PackagesDirectory is specified, is used as the packages directory. if (packagesDirectory) { @@ -61,7 +94,7 @@ class NuGetRestore extends BaseNuGet { // If -SolutionDirectory is specified, \packages is used as the packages directory. // SolutionFile can also be provided. // Otherwise use '.\packages' - def solutionDir = solutionFile ? solutionFile.getParent() : solutionDirectory - return new File(solutionDir ?: '.', 'packages').absolutePath + def solutionDir = solutionFile ? project.file(solutionFile.getParent()) : solutionDirectory + return new File(solutionDir ? solutionDir.toString() : '.', 'packages') } } diff --git a/src/main/groovy/com/ullink/NuGetSources.groovy b/src/main/groovy/com/ullink/NuGetSources.groovy index 719eb55..684aaef 100644 --- a/src/main/groovy/com/ullink/NuGetSources.groovy +++ b/src/main/groovy/com/ullink/NuGetSources.groovy @@ -1,6 +1,9 @@ package com.ullink import org.gradle.api.GradleException +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.Optional class NuGetSources extends BaseNuGet { @@ -8,18 +11,34 @@ class NuGetSources extends BaseNuGet { add, remove, enable, disable, list, update } - Operation operation + @Input + Operation operation + @Optional + @Input def sourceName + @Optional + @Input def sourceUrl + @Optional + @Input def username + @Optional + @Input def password - def configFile + @Optional + @InputFile + File configFile + @Input def storePasswordInClearText = false NuGetSources() { super('sources') } + void setConfigFile(String path) { + configFile = project.file(path) + } + @Override void exec() { if(!operation){ diff --git a/src/main/groovy/com/ullink/NugetLocalsClear.groovy b/src/main/groovy/com/ullink/NugetLocalsClear.groovy index 79def79..374211c 100644 --- a/src/main/groovy/com/ullink/NugetLocalsClear.groovy +++ b/src/main/groovy/com/ullink/NugetLocalsClear.groovy @@ -1,7 +1,10 @@ package com.ullink +import org.gradle.api.tasks.Input + class NugetLocalsClear extends BaseNuGet{ + @Input def all = false NugetLocalsClear() { diff --git a/src/test/groovy/com/ullink/MSBuildTaskBuilder.groovy b/src/test/groovy/com/ullink/MSBuildTaskBuilder.groovy index 2301968..509bea1 100644 --- a/src/test/groovy/com/ullink/MSBuildTaskBuilder.groovy +++ b/src/test/groovy/com/ullink/MSBuildTaskBuilder.groovy @@ -1,53 +1,51 @@ package com.ullink -import org.gradle.api.Task +import org.gradle.api.Project class MSBuildTaskBuilder { - - private final Task msbuildTask private final Map mainProjectProperties = [:] + private final Project project private final mainProject = new Object() private final List artifacts = [] - public MSBuildTaskBuilder() { - msbuildTask = [ - getName: { 'msbuild' } - ] as Task - mainProject.metaClass.getProperties = { mainProjectProperties } - mainProject.metaClass.getDotnetArtifacts = { artifacts } - msbuildTask.metaClass.getMainProject = { mainProject } - msbuildTask.metaClass.parseProject = true + MSBuildTaskBuilder(Project project) { + this.project = project } - public Task build() { - msbuildTask + def build() { + mainProject.metaClass.dotnetArtifacts = artifacts + mainProject.metaClass.properties = mainProjectProperties + project.tasks.register('msbuild') { + it.metaClass.mainProject = mainProject + it.metaClass.parseProject = true + } } - public MSBuildTaskBuilder withAssemblyName(String assemblyName) { + MSBuildTaskBuilder withAssemblyName(String assemblyName) { mainProjectProperties['AssemblyName'] = assemblyName this } - public MSBuildTaskBuilder withFrameworkVersion(String version) { + MSBuildTaskBuilder withFrameworkVersion(String version) { mainProjectProperties['TargetFrameworkVersion'] = version this } - public MSBuildTaskBuilder withArtifact(String artifactPath) { + MSBuildTaskBuilder withArtifact(String artifactPath) { artifacts.add(new File(artifactPath)) this } - public MSBuildTaskBuilder withProjectFile(String path) { + MSBuildTaskBuilder withProjectFile(String path) { mainProject.metaClass.getProjectFile = { path } this } - public MSBuildTaskBuilder withProjectFile(File file) { + MSBuildTaskBuilder withProjectFile(File file) { withProjectFile(file.path) } - public MSBuildTaskBuilder withMainProjectProperty(String name, String value) { + MSBuildTaskBuilder withMainProjectProperty(String name, String value) { mainProjectProperties[name] = value this } diff --git a/src/test/groovy/com/ullink/NuGetPluginTest.groovy b/src/test/groovy/com/ullink/NuGetPluginTest.groovy index f26cbc4..06053ff 100644 --- a/src/test/groovy/com/ullink/NuGetPluginTest.groovy +++ b/src/test/groovy/com/ullink/NuGetPluginTest.groovy @@ -54,7 +54,7 @@ class NuGetPluginTest { } @Test - public void nugetPackSpecifyVersion() { + void nugetPackSpecifyVersion() { File nuspec = new File(project.tasks.nugetPack.temporaryDir, 'bar.nuspec') nuspec.text = ''' diff --git a/src/test/groovy/com/ullink/NuGetSpecTest.groovy b/src/test/groovy/com/ullink/NuGetSpecTest.groovy index 53f547d..9113b86 100644 --- a/src/test/groovy/com/ullink/NuGetSpecTest.groovy +++ b/src/test/groovy/com/ullink/NuGetSpecTest.groovy @@ -9,7 +9,7 @@ import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual class NuGetSpecTest { @Before - public void init() { + void init() { XMLUnit.setIgnoreWhitespace(true) } @@ -25,18 +25,17 @@ class NuGetSpecTest { Project newNugetWithMsbuildProject() { def project = newNugetProject() - def msbuildTask = new MSBuildTaskBuilder() + new MSBuildTaskBuilder(project) .withAssemblyName('bar') .withFrameworkVersion('v3.5') .withArtifact('folder/bin/bar.dll') .withProjectFile('folder/does not exist') .build() - project.tasks.add(msbuildTask) project } @Test - public void generateNuspec_Closure() { + void generateNuspec_Closure() { def project = newNugetProject() project.nugetSpec { @@ -281,7 +280,7 @@ class NuGetSpecTest { } @Test - public void generateNuspec_defaultDependenciesFromPackageConfig() { + void generateNuspec_defaultDependenciesFromPackageConfig() { def project = newNugetProject() project.nugetSpec { @@ -291,11 +290,10 @@ class NuGetSpecTest { File.createTempDir().with { projectFolder -> deleteOnExit() - def msbuildTask = new MSBuildTaskBuilder() + new MSBuildTaskBuilder(project) .withAssemblyName('bar') .withProjectFile(new File(projectFolder.path, 'bar.csproj')) .build() - project.tasks.add(msbuildTask) File packageConfig = new File(projectFolder, 'packages.config') packageConfig.createNewFile() @@ -338,11 +336,10 @@ class NuGetSpecTest { File.createTempDir().with { projectFolder -> deleteOnExit() - def msbuildTask = new MSBuildTaskBuilder() + new MSBuildTaskBuilder(project) .withAssemblyName('bar') .withProjectFile(new File(projectFolder.path, 'bar.csproj')) .build() - project.tasks.add(msbuildTask) File packageConfig = new File(projectFolder, 'packages.config') packageConfig.createNewFile() @@ -385,11 +382,10 @@ class NuGetSpecTest { File.createTempDir().with { projectFolder -> deleteOnExit() - def msbuildTask = new MSBuildTaskBuilder() + new MSBuildTaskBuilder(project) .withAssemblyName('bar') .withProjectFile(new File(projectFolder.path, 'bar.csproj')) .build() - project.tasks.add(msbuildTask) File projectJson = new File(projectFolder, 'project.json') projectJson.createNewFile() @@ -440,11 +436,10 @@ class NuGetSpecTest { File.createTempDir().with { projectFolder -> deleteOnExit() - def msbuildTask = new MSBuildTaskBuilder() + new MSBuildTaskBuilder(project) .withAssemblyName('bar') .withProjectFile(new File(projectFolder.path, 'bar.csproj')) .build() - project.tasks.add(msbuildTask) File projectJson = new File(projectFolder, 'project.json') projectJson.createNewFile() @@ -506,12 +501,10 @@ class NuGetSpecTest { File.createTempDir().with { projectFolder -> deleteOnExit() - - def msbuildTask = new MSBuildTaskBuilder() + new MSBuildTaskBuilder(project) .withAssemblyName('bar') .withProjectFile(new File(projectFolder.path, 'bar.csproj')) .build() - project.tasks.add(msbuildTask) File projectJson = new File(projectFolder, 'project.json') projectJson.createNewFile() @@ -570,14 +563,12 @@ class NuGetSpecTest { deleteOnExit() def csproj = new File(getClass().getResource('packageparser/packagereference.csproj').toURI()) - def msbuildTask = new MSBuildTaskBuilder() + new MSBuildTaskBuilder(project) .withAssemblyName('bar') .withProjectFile(csproj) .withMainProjectProperty('MSBuildProjectFile', 'packagereference.csproj') .build() - project.tasks.add(msbuildTask) - def expected = '''