From 9712b238cc5e513282c70e8b7171830f42fa885a Mon Sep 17 00:00:00 2001 From: Jim Moore Date: Fri, 11 Mar 2016 13:26:44 -0700 Subject: [PATCH] Added support for -Ppackage= --- .../gradle/cqpackage/UploadPackage.groovy | 15 ++++++++++-- .../cqpackage/CqPackagePluginIntSpec.groovy | 24 +++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/main/groovy/com/twcable/gradle/cqpackage/UploadPackage.groovy b/src/main/groovy/com/twcable/gradle/cqpackage/UploadPackage.groovy index 890f0a1..526a63b 100644 --- a/src/main/groovy/com/twcable/gradle/cqpackage/UploadPackage.groovy +++ b/src/main/groovy/com/twcable/gradle/cqpackage/UploadPackage.groovy @@ -163,14 +163,25 @@ in other words, there's no indication it's missing its dependency at this point /** * Returns the CQ Package file to use. * - * If a System Property of "package" is set, that is used. Otherwise the output of + * If a System Property or Project property of "package" is set, that is used. Otherwise the output of * the 'createPackage' task is used. */ @Nonnull static File getThePackageFile(Project project) { + def hasPackageProperty = project.hasProperty('package') + if (hasPackageProperty) { + final filename = project.property('package') as String + final file = new File(filename).absoluteFile + if (!file.exists()) throw new FileNotFoundException(file.toString()) + return file + } + def packageProperty = System.getProperty('package') if (packageProperty != null) { - return new File(packageProperty) + final filename = packageProperty + final file = new File(filename).absoluteFile + if (!file.exists()) throw new FileNotFoundException(file.toString()) + return file } def file = CreatePackageTask.from(project).archivePath diff --git a/src/test/groovy/com/twcable/gradle/cqpackage/CqPackagePluginIntSpec.groovy b/src/test/groovy/com/twcable/gradle/cqpackage/CqPackagePluginIntSpec.groovy index 0bafca9..8a18a08 100644 --- a/src/test/groovy/com/twcable/gradle/cqpackage/CqPackagePluginIntSpec.groovy +++ b/src/test/groovy/com/twcable/gradle/cqpackage/CqPackagePluginIntSpec.groovy @@ -317,6 +317,30 @@ class CqPackagePluginIntSpec extends IntegrationSpec { } + def "upload package with package Project property"() { + def testPackageFilename = this.class.classLoader.getResource("testpackage-1.0.1.zip").file + + getHandler.addPathResponse("/crx/packmgr/list.jsp", + new JsonBuilder( + PackageServerFixture.packageList( + PackageFixture.of("twc/test:testpackage:1.0.1") + ) + ).toString() + ) + + postHandler.addFileResponse("/crx/packmgr/service/.json", successfulPackageUpload().body) + + writeSimpleBuildFile() + + when: + result = runTasks("uploadPackage", "-Ppackage=${testPackageFilename}", "-x", "removePackage") + + then: + result.success + !result.wasExecuted(':createPackage') + } + + def "install package"() { defaultPackageListHandler()