Skip to content

Commit

Permalink
Merge pull request #186 from fundacionjala/develop
Browse files Browse the repository at this point in the history
Build 1.0.7 version
  • Loading branch information
marcocdlv committed Jul 28, 2015
2 parents 633e8d2 + 899ab86 commit 0a349d1
Show file tree
Hide file tree
Showing 97 changed files with 4,762 additions and 2,248 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def patch = "$System.env.VERSION_NUMBER_PATCH"
def newVersion = "$major.$minor.$patch"
version = newVersion


uploadArchives {
repositories {
mavenDeployer {
Expand Down Expand Up @@ -124,4 +125,4 @@ bintray {
labels = ['sfdc', 'integration ', 'continuous', 'jenkins', 'gradle']
publicDownloadNumbers = true
}
}
}
16 changes: 16 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@

## 1.0.7 - 2015-07-28

### Features

* New option was added to disable subcomponents deletion once Update command is executed.

### Bugs fixed

* When the enforce version is changed and it is executed the task status shows all files as deleted and added.

### Known issues

* Once that files are deleted and update task is executed those files are not deleted from Salesforce organization.
* Deployment tasks are not deploying salesforce components when these are in sub folders into project directory.


## 1.0.6 - 2015-07-15

### Bugs fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.fundacionjala.gradle.plugins.enforce.tasks.credentialmanager.Credenti
import org.fundacionjala.gradle.plugins.enforce.tasks.filemonitor.FilesStatus
import org.fundacionjala.gradle.plugins.enforce.tasks.filemonitor.Reset
import org.fundacionjala.gradle.plugins.enforce.tasks.salesforce.deployment.Deploy
import org.fundacionjala.gradle.plugins.enforce.tasks.salesforce.deployment.Truncate
import org.fundacionjala.gradle.plugins.enforce.tasks.salesforce.deployment.Undeploy
import org.fundacionjala.gradle.plugins.enforce.tasks.salesforce.deployment.Update
import org.fundacionjala.gradle.plugins.enforce.tasks.salesforce.deployment.Upload
Expand Down Expand Up @@ -51,6 +52,7 @@ class EnforcePlugin implements Plugin<Project> {
project.task('update', type: Update)
project.task('upload', type: Upload)
project.task('delete', type: Delete)
project.task('truncate', type: Truncate)

project.task("addCredential", type: CredentialAdder)
project.task("updateCredential", type: CredentialUpdater)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ class EnforcePluginExtension {

Boolean deleteTemporaryFiles = true

/**
* A list with wildcards that customize that subComponents can be deleted
*/
ArrayList<String> deleteSubComponents = ['*']

ArrayList<String> standardObjects = []

String tool = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ComponentMonitor {
* @return a map of components with their status changed, added or deleted
*/
public Map<String, ResultTracker> getComponentChanged(ArrayList<File> arrayFiles) throws Exception {
recoveryFileHashCode = componentSerializer.read()
recoveryFileHashCode = Util.getFilesWithTheirRelativePaths(componentSerializer.read(), srcProject)
currentFileHashCode = getComponentsSignature(arrayFiles)

return getFilesChanged(recoveryFileHashCode, currentFileHashCode)
Expand Down Expand Up @@ -162,4 +162,4 @@ class ComponentMonitor {
}
componentSerializer.save(recoveryFileHashCode)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import org.fundacionjala.gradle.plugins.enforce.wsc.soap.MetadataAPI
*/
public class RetrieveMetadata {

private org.fundacionjala.gradle.plugins.enforce.utils.salesforce.Package metaPackage
private org.fundacionjala.gradle.plugins.enforce.utils.salesforce.PackageManager.Package metaPackage
private byte[] zipFileRetrieved
private ArrayList<String> warningMessages
private String RETRIEVE_RESULT_NULL = "Retrieve result instance is NULL"
Expand All @@ -26,7 +26,7 @@ public class RetrieveMetadata {
* Constructor of RetrieveMetadata
* @param filePath contains the file xml
*/
RetrieveMetadata(org.fundacionjala.gradle.plugins.enforce.utils.salesforce.Package metaPackage) {
RetrieveMetadata(org.fundacionjala.gradle.plugins.enforce.utils.salesforce.PackageManager.Package metaPackage) {
this.metaPackage = metaPackage
warningMessages = new ArrayList<String>()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
*/

package org.fundacionjala.gradle.plugins.enforce.tasks.filemonitor
import org.fundacionjala.gradle.plugins.enforce.utils.Constants

import org.fundacionjala.gradle.plugins.enforce.utils.Util
import org.fundacionjala.gradle.plugins.enforce.utils.salesforce.PackageGenerator

import java.nio.file.Paths

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.fundacionjala.gradle.plugins.enforce.tasks.credentialmanager.Credenti
import org.fundacionjala.gradle.plugins.enforce.utils.AnsiColor
import org.fundacionjala.gradle.plugins.enforce.utils.Constants
import org.fundacionjala.gradle.plugins.enforce.utils.Util
import org.fundacionjala.gradle.plugins.enforce.utils.salesforce.PackageBuilder
import org.fundacionjala.gradle.plugins.enforce.utils.salesforce.PackageManager.PackageBuilder
import org.fundacionjala.gradle.plugins.enforce.wsc.Credential
import org.gradle.api.GradleException
import org.gradle.api.tasks.bundling.Zip
Expand Down Expand Up @@ -253,11 +253,25 @@ abstract class SalesforceTask extends ForceTask {
logger.debug('Created directory at: ' + buildFolderPath)
projectPackagePath = Paths.get(projectPath, PACKAGE_NAME)
parameters = project.properties.clone()
setup()
loadParameters()
runTask()
}

/**
* Abstract method: When implement a method can select steps for deployment
*/
abstract void runTask()


/**
* Abstract method: When implement a method can setup files for deployment tasks
*/
abstract void setup()


/**
* Abstract method: When implement a method can load parameters for deployment tasks
*/
abstract void loadParameters()
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,100 +5,85 @@

package org.fundacionjala.gradle.plugins.enforce.tasks.salesforce.deployment

import org.fundacionjala.gradle.plugins.enforce.undeploy.SmartFilesValidator
import org.fundacionjala.gradle.plugins.enforce.utils.Constants
import org.fundacionjala.gradle.plugins.enforce.utils.Util
import org.fundacionjala.gradle.plugins.enforce.wsc.rest.QueryBuilder
import org.fundacionjala.gradle.plugins.enforce.wsc.rest.ToolingAPI

import java.nio.file.Paths
import org.fundacionjala.gradle.plugins.enforce.utils.salesforce.OrgValidator

/**
* Deletes files into an org using metadata API
*/
class Delete extends Deployment {
public String pathDelete
private static final String START_DELETE_TASK = 'Starting delete process...'
private static final String SUCCESSFULLY_DELETE_TASK = 'The files were successfully deleted!'
private static final String DESCRIPTION_DELETE_TASK = "This task deploys just the files that were changed"
private static final String DIR_DELETE_FOLDER = "delete"
private static final String PROCESS_DELETE_CANCELLED = "The delete process was canceled"
private static final String NOT_FILES_DELETED = "There are not files to delete"
private static final String QUESTION_CONTINUE_DELETE = "Do you want delete this files from your organization? (y/n) :"

public ArrayList<File> filesToDeleted
public String files = ""

/**
* 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>()
super(DESCRIPTION_DELETE_TASK, Constants.DEPLOYMENT)
taskFolderName = DIR_DELETE_FOLDER
filesToDeleted = []
}

/**
* 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()
createDeploymentDirectory(taskFolderPath)
loadClassifiedFiles(files, excludes)
loadFilesToDelete()
validateFilesInOrg()
showFilesToDelete()


if( System.console().readLine("\n"+Constants.QUESTION_CONTINUE_DELETE) == Constants.YES_OPTION ) {
if( System.console().readLine("\n"+QUESTION_CONTINUE_DELETE) == Constants.YES_OPTION ) {
createDestructive()
createPackageEmpty()
executeDeploy(pathDelete)
executeDeploy(taskFolderPath, START_DELETE_TASK, SUCCESSFULLY_DELETE_TASK)
}
else {
logger.quiet(Constants.PROCCES_DELETE_CANCELLED)
logger.quiet(PROCESS_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
* Initializes all task parameters
* @param properties the task properties
* @return A map of all task parameters
*/
def addFilesToDelete() {
filesToDeleted = addFilesTo(filesToDeleted)
void loadParameters() {
if (Util.isValidProperty(parameters, Constants.PARAMETER_FILES)) {
files = parameters[Constants.PARAMETER_FILES]
}
if (Util.isValidProperty(parameters, Constants.PARAMETER_EXCLUDES)) {
excludes = parameters[Constants.PARAMETER_EXCLUDES]
}
}

/**
* Excludes Files from filesExcludes map
* Adds all files into an org
*/
def excludeFilesToDelete() {
filesToDeleted = excludeFiles(filesToDeleted)
def loadFilesToDelete() {
File packageFile = new File(projectPackagePath)
filesToDeleted = classifiedFile.validFiles
filesToDeleted.remove(packageFile)
}

/**
* Filter the files into Org
*/
def validateFilesInOrg() {
ToolingAPI toolingAPI = new ToolingAPI(credential)
QueryBuilder queryBuilder = new QueryBuilder()
ArrayList<String> jsonQueries = []
if(!parameters.get(Constants.PARAMETER_VALIDATE_ORG).equals(Constants.FALSE_OPTION)) {
queryBuilder.createQueryFromPackage(projectPackagePath).each { query ->
jsonQueries.push(toolingAPI.httpAPIClient.executeQuery(query as String))
}
SmartFilesValidator smartFilesValidator = new SmartFilesValidator(jsonQueries)
filesToDeleted = smartFilesValidator.filterFilesAccordingOrganization(filesToDeleted, projectPath)
filesToDeleted = OrgValidator.getValidFiles(credential, filesToDeleted, projectPath)
}
}

Expand All @@ -110,21 +95,21 @@ class Delete extends Deployment {
ArrayList<File> showFiles = filesToDeleted.findAll { File file ->
!file.getName().endsWith("xml")
}
def numComponentes = showFiles.size()
def numberOfComponents = showFiles.size()

logger.quiet("*********************************************")
logger.quiet(" Components to delete ")
logger.quiet("*********************************************")
if(numComponentes == 0) {
logger.quiet(Constants.NOT_FILES_DELETED)
if(numberOfComponents == 0) {
logger.quiet(NOT_FILES_DELETED)
}
else if(numComponentes > limit) {
else if(numberOfComponents > limit) {
showFiles.groupBy { File file ->
file.getParentFile().getName()
}.each { group, files ->
logger.quiet("[ " + files.size() + " ] " + group)
}
logger.quiet(numComponentes+" components")
logger.quiet( "Total: ${numberOfComponents} components")
}
else {
showFiles.each { File file ->
Expand All @@ -138,15 +123,14 @@ class Delete extends Deployment {
* 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)
writePackage(taskDestructivePath, filesToDeleted)
combinePackageToUpdate(taskDestructivePath)
}

/**
* Create a package empty
*/
def createPackageEmpty() {
writePackage(Paths.get(pathDelete, PACKAGE_NAME).toString(), [])
writePackage(taskPackagePath, [])
}
}
Loading

0 comments on commit 0a349d1

Please sign in to comment.