-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #116 from fundacionjala/develop
New release v1.0.4
- Loading branch information
Showing
43 changed files
with
1,657 additions
and
304 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
130 changes: 130 additions & 0 deletions
130
...groovy/org/fundacionjala/gradle/plugins/enforce/tasks/salesforce/deployment/Delete.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/* | ||
* Copyright (c) Fundacion Jala. All rights reserved. | ||
* Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
*/ | ||
|
||
package org.fundacionjala.gradle.plugins.enforce.tasks.salesforce.deployment | ||
|
||
import org.fundacionjala.gradle.plugins.enforce.utils.Constants | ||
import org.fundacionjala.gradle.plugins.enforce.utils.Util | ||
|
||
import java.nio.file.Paths | ||
|
||
/** | ||
* Deletes files into an org using metadata API | ||
*/ | ||
class Delete extends Deployment { | ||
public String pathDelete | ||
public ArrayList<File> filesToDeleted | ||
|
||
/** | ||
* Sets description and group task | ||
* @param description is description tasks | ||
* @param group is the group typeName the task | ||
*/ | ||
Delete() { | ||
super(Constants.DESCRIPTION_DELETE_TASK, Constants.DEPLOYMENT) | ||
filesToDeleted = new ArrayList<File>() | ||
} | ||
|
||
/** | ||
* Executes the task | ||
*/ | ||
@Override | ||
void runTask() { | ||
pathDelete = Paths.get(buildFolderPath, Constants.DIR_DELETE_FOLDER).toString() | ||
componentDeploy.startMessage = Constants.START_DELETE_TASK | ||
componentDeploy.successMessage = Constants.SUCCESSFULLY_DELETE_TASK | ||
createDeploymentDirectory(pathDelete) | ||
addAllFiles() | ||
addFoldersToDeleteFiles() | ||
addFilesToDelete() | ||
excludeFilesToDelete() | ||
showFilesToDelete() | ||
|
||
if( System.console().readLine("\n"+Constants.QUESTION_CONTINUE_DELETE) == Constants.YES_OPTION ) { | ||
createDestructive() | ||
createPackageEmpty() | ||
executeDeploy(pathDelete) | ||
} | ||
else { | ||
logger.quiet(Constants.PROCCES_DELETE_CANCELLED) | ||
} | ||
} | ||
|
||
/** | ||
* Adds all files into an org | ||
*/ | ||
def addAllFiles() { | ||
filesToDeleted = addAllFilesInAFolder(filesToDeleted) | ||
} | ||
|
||
/** | ||
* Adds all files that are inside the folders | ||
*/ | ||
def addFoldersToDeleteFiles() { | ||
filesToDeleted = addFilesFromFolders(filesToDeleted) | ||
} | ||
|
||
/** | ||
* Adds files to file's list | ||
*/ | ||
def addFilesToDelete() { | ||
filesToDeleted = addFilesTo(filesToDeleted) | ||
} | ||
|
||
/** | ||
* Shows files to delete | ||
*/ | ||
def showFilesToDelete() { | ||
def limit = 15 | ||
ArrayList<File> showFiles = filesToDeleted.findAll { File file -> | ||
!file.getName().endsWith("xml") | ||
} | ||
def numComponentes = showFiles.size() | ||
|
||
logger.quiet("*********************************************") | ||
logger.quiet(" Components to delete ") | ||
logger.quiet("*********************************************") | ||
if(numComponentes == 0) { | ||
logger.quiet(Constants.NOT_FILES_DELETED) | ||
} | ||
else if(numComponentes > limit) { | ||
showFiles.groupBy { File file -> | ||
file.getParentFile().getName() | ||
}.each { group, files -> | ||
logger.quiet("[ " + files.size() + " ] " + group) | ||
} | ||
} | ||
else { | ||
showFiles.each { File file -> | ||
logger.quiet( Util.getRelativePath(file, projectPath)) | ||
} | ||
logger.quiet(numComponentes+" components") | ||
} | ||
logger.quiet("*********************************************") | ||
} | ||
|
||
/** | ||
* Excludes Files from filesExcludes map | ||
*/ | ||
def excludeFilesToDelete() { | ||
filesToDeleted = excludeFiles(filesToDeleted) | ||
} | ||
|
||
/** | ||
* Creates packages to all files which has been deleted | ||
*/ | ||
def createDestructive() { | ||
String destructivePath = Paths.get(pathDelete, PACKAGE_NAME_DESTRUCTIVE).toString() | ||
writePackage(destructivePath, filesToDeleted) | ||
combinePackageToUpdate(destructivePath) | ||
} | ||
|
||
/** | ||
* Create a package empty | ||
*/ | ||
def createPackageEmpty() { | ||
writePackage(Paths.get(pathDelete, PACKAGE_NAME).toString(), []) | ||
} | ||
} |
Oops, something went wrong.