Skip to content

Commit

Permalink
Made createPackage.contentSrc more flexible
Browse files Browse the repository at this point in the history
Added better logging for installation
  • Loading branch information
jdigger committed Aug 16, 2015
1 parent 9f94c16 commit a0acb99
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/CqPackagePlugin.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ reinstall::
Convenience task that simple depends on `clean`, `uninstall`, `remove`, `install`, then `verifyBundles`.

installPackage::
Installs the CQ Package
Installs the CQ Package that has been uploaded. **Note** Uses the name of the package. See below.

validateBundles::
Checks all the JARs that are included in the package to make sure they are installed and in an
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,16 @@ class CqPackageHelper {
Map getPackageInfo(SlingServerConfiguration serverConfig) {
def packagesInfo = listPackages(serverConfig)
if (packagesInfo != null) {
return packagesInfo.results.find { Map packageInfo ->
def packageMap = packagesInfo.results.find { Map packageInfo ->
packageInfo.name == packageName
} as Map
if (packageMap == null) {
logger.info "Could not find ${packageName} in ${packagesInfo.results.collect { Map pi -> pi.name }}"
}
return packageMap
}
else {
logger.warn "Did not get a list of packages on ${serverConfig.name}"
return null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import groovy.transform.TypeChecked
import org.gradle.api.Project
import org.gradle.api.artifacts.Configuration
import org.gradle.api.file.CopySpec
import org.gradle.api.internal.file.copy.DefaultCopySpec
import org.gradle.api.tasks.InputDirectory
import org.gradle.api.tasks.TaskAction
import org.gradle.api.tasks.bundling.Zip
Expand Down Expand Up @@ -80,6 +81,8 @@ class CreatePackageTask extends Zip {
'jcr_root/var/**',
'SLING-INF/**',
]

setContentSrc(project.file("src/main/content"))
}


Expand Down Expand Up @@ -140,6 +143,10 @@ class CreatePackageTask extends Zip {
*/
@SuppressWarnings("GroovyUnusedDeclaration")
void setContentSrc(File contentSrc) {
if (_contentSrc != null)
((DefaultCopySpec)getMainSpec()).getSourcePaths().remove(this._contentSrc)

((DefaultCopySpec)getMainSpec()).getSourcePaths().add(contentSrc)
this._contentSrc = contentSrc
}

Expand All @@ -149,15 +156,13 @@ class CreatePackageTask extends Zip {
*/
@InputDirectory
File getContentSrc() {
return _contentSrc ?: project.file("src/main/content")
return _contentSrc
}


@Override
@TaskAction
protected void copy() {
this.from(contentSrc)

// delaying until now to set up these sections because they need the "final" versions
// of some of the properties of this task
addVaultDefinition(contentSrc)
Expand All @@ -172,7 +177,6 @@ class CreatePackageTask extends Zip {
ALL, PROJECT_ONLY, NON_PROJECT_ONLY, NONE
}


/**
* The Configuration to use when determining what bundles to put in the package.
* @see #addAllBundles()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class SlingSupport {
HttpResponse doGet(URI url, SimpleHttpClient httpClient) {
if (!serverConf.active) return new HttpResponse(HTTP_CLIENT_TIMEOUT, "${serverConf.name} is not responding")
if (url == null) return new HttpResponse(HTTP_NOT_FOUND, 'Missing URL')
log.info "GET ${url}"
HttpGet get = new HttpGet(url)
def resp = httpClient.execute(get)
if (resp.code == HTTP_CLIENT_TIMEOUT) serverConf.active = false
Expand Down

0 comments on commit a0acb99

Please sign in to comment.