Skip to content

Commit 2c79ddf

Browse files
authored
Merge pull request #5 from Cognifide/vlt-subproject-fix
Fixing aemSync for subprojects
2 parents cf5db73 + 9aab1f0 commit 2c79ddf

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/main/kotlin/com/cognifide/gradle/aem/vlt/VltApp.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,22 @@ class VltApp(val instance: AemInstance, val project: Project) : VaultFsApp() {
1414
companion object {
1515

1616
fun checkout(project: Project, config: AemConfig) {
17+
val contentDir = File(config.determineContentPath(project))
18+
if (!contentDir.exists()) {
19+
project.logger.info("JCR content directory to be checked out does not exist: ${contentDir.absolutePath}")
20+
}
21+
1722
val instance = AemInstance.filter(project, config, AemInstance.FILTER_AUTHOR).first()
1823
val vltApp = VltApp(instance, project)
19-
val cmdArgs = config.vaultCheckoutArgs + listOf(instance.url, "/", config.determineContentPath(project))
24+
val cmdArgs = config.vaultCheckoutArgs + listOf(instance.url, "/", contentDir.absolutePath)
2025

2126
val filter = File(config.vaultFilterPath)
2227
if (filter.exists()) {
2328
vltApp.executeCommand(listOf(CheckoutTask.COMMAND, "-f", filter.absolutePath) + cmdArgs)
2429
} else {
25-
vltApp.executeCommand(listOf(CheckoutTask.COMMAND + cmdArgs))
30+
vltApp.executeCommand(listOf(CheckoutTask.COMMAND) + cmdArgs)
2631
}
2732
}
28-
2933
}
3034

3135
init {

src/main/kotlin/com/cognifide/gradle/aem/vlt/VltCleaner.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,35 @@ import java.io.File
1212
import java.io.IOException
1313
import java.util.*
1414

15-
class VltCleaner(val root: String, val logger: Logger) {
15+
class VltCleaner(val root: File, val logger: Logger) {
1616

1717
companion object {
1818
val VLT_FILE = ".vlt"
1919

2020
val JCR_CONTENT_FILE = ".content.xml"
2121

2222
fun clean(project : Project, config : AemConfig) {
23-
val cleaner = VltCleaner(config.contentPath, project.logger)
23+
val contentDir = File(config.determineContentPath(project))
24+
if (!contentDir.exists()) {
25+
project.logger.warn("JCR content directory to be cleaned does not exist: ${contentDir.absolutePath}")
26+
return
27+
}
2428

29+
val cleaner = VltCleaner(contentDir, project.logger)
2530
cleaner.removeVltFiles()
2631
cleaner.cleanupDotContent(config.vaultSkipProperties, config.vaultLineSeparator)
2732
}
2833
}
2934

3035
fun removeVltFiles() {
31-
for (file in FileUtils.listFiles(File(root), NameFileFilter(VLT_FILE), TrueFileFilter.INSTANCE)) {
36+
for (file in FileUtils.listFiles(root, NameFileFilter(VLT_FILE), TrueFileFilter.INSTANCE)) {
3237
logger.info("Deleting {}", file.path)
3338
FileUtils.deleteQuietly(file)
3439
}
3540
}
3641

3742
fun cleanupDotContent(contentProperties: List<String>, lineEnding : String) {
38-
for (file in FileUtils.listFiles(File(root), NameFileFilter(JCR_CONTENT_FILE), TrueFileFilter.INSTANCE)) {
43+
for (file in FileUtils.listFiles(root, NameFileFilter(JCR_CONTENT_FILE), TrueFileFilter.INSTANCE)) {
3944
try {
4045
logger.info("Cleaning up {}", file.path)
4146

0 commit comments

Comments
 (0)