Skip to content

Commit

Permalink
Added support for -Ppackage=
Browse files Browse the repository at this point in the history
  • Loading branch information
jdigger committed Mar 11, 2016
1 parent 5403071 commit 9712b23
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/main/groovy/com/twcable/gradle/cqpackage/UploadPackage.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 9712b23

Please sign in to comment.