Skip to content

Commit

Permalink
Merge pull request #146 from fundacionjala/develop
Browse files Browse the repository at this point in the history
New release v1.0.5
  • Loading branch information
Rodrigo Ruiz committed Jun 23, 2015
2 parents e18a4dc + 0d6e672 commit 2da6fb7
Show file tree
Hide file tree
Showing 61 changed files with 1,967 additions and 910 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'org.fundacionjala.gradle.plugins.enforce:enforce-gradle-plugin:1.0.1'
classpath 'org.fundacionjala.gradle.plugins.enforce:enforce-gradle-plugin:1.0.4'
}
}
Expand Down
2 changes: 1 addition & 1 deletion example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'org.fundacionjala.gradle.plugins.enforce:enforce-gradle-plugin:1.0.1'
classpath 'org.fundacionjala.gradle.plugins.enforce:enforce-gradle-plugin:1.0.4'
}
}

Expand Down
51 changes: 51 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,55 @@

## 1.0.5 - 2015-06-22

### Bugs fixed

* Update command tries to delete packaged sub-components.
* @isTest annotation should be case insensitive.
* Special characters not deployed properly.
* The status task is showing empty space by every changed object .
* Update task doesn't support excludes parameter.
* Once that a document is added and the update task is executed, it didn't upload that document to your organization.
* Once that a document is deleted and the update task is executed, it deletes all documents from your organization.
* When I execute retrieve task using the -Pfiles with documents is not working.



### Known issues

* Once a folder of documents is deleted, it isn’t deleted from your organization.
* Update Command: 400 Bad Request error is displayed when trying to delete validation rules.


## 1.0.4 - 2015-06-10

### Features

* Delete task was created to delete components from your organization based in your package xml file or using folder parameter. It doesn't truncate.

### Bugs fixed

* The deploy task ends with percentage less than 100%.
* Support deleteTemporaryFiles parameter for Retrieve task.
* Update task fails for files that have spaces in their name.
* Update/Deploy/Upload command does not take in account the package.xml info for packaged objects.
* Excludes parameter into deploy task doesn't take in account documents component without extension into package xml file.
* The validation of files parameter value does not work when it sends documents, reports or dashboard.

### Enhancements

* Use unzip method of Gradle instead of unzip method of AntBuilder for the Retrieve task.

### Known issues

* When the enforce version is changed and status task is executed all files are shown as deleted for the moment to avoid it you should execute reset task.
* When you execute the delete task using files parameter and you use a folder name as a value, It is listing all files from the project.
* When we use the status task to show objects it shows an empty line between objects names.
* If a document or report or dashboard are deleted all documents or reports or dashboards are deleted for the update task.
* Update task does not support the excludes parameter.
* Once retrieve task is executed using files parameter with document file as value the validation doesn’t work.



## 1.0.3 - 2015-05-25

### Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
*/

package org.fundacionjala.gradle.plugins.enforce

import java.nio.charset.StandardCharsets

/**
* This class creates a plugin extension to assign properties of the plugin.
*/
Expand Down Expand Up @@ -35,6 +38,8 @@ class EnforcePluginExtension {

String integration = "no"

String encoding = StandardCharsets.UTF_8.displayName()

String foldersToDownload = "objects,staticresources,classes,pages,triggers,components"

Map<String, Map<String, Closure>> interceptors
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.fundacionjala.gradle.plugins.enforce.filemonitor

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

/**
* This class represents the state of the object component and its sub components
*/
Expand Down Expand Up @@ -38,18 +40,19 @@ class ObjectHash extends ComponentHash {
private Map<String, String> getChangedFields(ObjectHash objectHash) {
Map<String, String> result = [:]
objectHash.subComponents.each { String fieldAPIName, String fieldHash ->
if (!this.subComponents.containsKey(fieldAPIName)) {
Boolean isPackaged = Util.isPackaged(fieldAPIName)
if (!isPackaged && !this.subComponents.containsKey(fieldAPIName)) {
result.put(fieldAPIName, ComponentStates.ADDED)
}

if (this.subComponents.containsKey(fieldAPIName) &&
if (!isPackaged && this.subComponents.containsKey(fieldAPIName) &&
!this.subComponents.get(fieldAPIName).toString().equals(fieldHash)) {
result.put(fieldAPIName, ComponentStates.CHANGED)
}
}

this.subComponents.each { String fieldAPIName, String fieldHash ->
if(!objectHash.subComponents.containsKey(fieldAPIName)) {
if(!Util.isPackaged(fieldAPIName) && !objectHash.subComponents.containsKey(fieldAPIName)) {
result.put(fieldAPIName, ComponentStates.DELETED)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ class ObjectResultTracker extends ResultTracker {

@Override
public String toString() {
String result = '';
StringBuilder result = new StringBuilder()
subComponentsResult.each { field, fieldState ->
result += field + ' -> '+ fieldState.value() + '\n\t'
result.append('\n\t')
result.append(field)
result.append(' -> ')
result.append(fieldState.value())
}
return state.value() + '\n\t' + result
return state.value() + result.toString()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ package org.fundacionjala.gradle.plugins.enforce.interceptor
import org.fundacionjala.gradle.plugins.enforce.utils.salesforce.MetadataComponents
import groovy.util.logging.Slf4j

import java.nio.charset.StandardCharsets

/**
* This class manages all components created from source path
*/
Expand All @@ -19,7 +21,7 @@ class InterceptorManager {
Map<String, MetadataInterceptor> interceptors
List truncatedDirectories = ['classes', 'objects', 'triggers', 'pages', 'components', 'workflows', 'tabs']
List<String> interceptorsToExecute

String encoding

/**
* Creates a new interceptor management from source path
Expand All @@ -28,6 +30,7 @@ class InterceptorManager {
InterceptorManager() {
this.interceptors = [:]
interceptorsToExecute = []
encoding = StandardCharsets.UTF_8.displayName()
}

/**
Expand All @@ -39,6 +42,7 @@ class InterceptorManager {
FactoryInterceptor factoryComponent = new FactoryInterceptor()
MetadataInterceptor interceptor = factoryComponent.getInterceptor(componentType)
if (interceptor) {
interceptor.encoding = encoding
interceptor.loadInterceptors()
this.interceptors.put(componentType.directory, interceptor)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

package org.fundacionjala.gradle.plugins.enforce.interceptor
import groovy.util.logging.Slf4j

import java.nio.charset.StandardCharsets

/**
* This class provides a skeletal implementation of the interceptor for all metadata types supported
*/
Expand All @@ -14,13 +17,16 @@ abstract class MetadataInterceptor {
List<File> files
protected Map<String, Closure> interceptors
protected final int INDEX_ZERO = 0
String encoding

/**
* Initializes the class properties by default
*/
MetadataInterceptor() {
files = []
interceptors = new LinkedHashMap<String, Closure>()
interceptorsToExecute = []
encoding = StandardCharsets.UTF_8.displayName()
}

Map<String, Closure> getInterceptors() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,37 @@

package org.fundacionjala.gradle.plugins.enforce.interceptor.commands

import groovy.util.logging.Slf4j
import org.fundacionjala.gradle.plugins.enforce.utils.Util

import java.nio.charset.StandardCharsets

/**
* Implements the truncated algorithm to truncate the class content
*/
@Slf4j
class Class {
private final String CLASS_DECLARATION = 'public class %s {}'
private final String EXCEPTION_FILE_NAME = 'Exception.cls'
private final String CLASS_DECLARATION_EXCEPTION = 'public class %s extends %s {}'
String encoding

Class() {
this.encoding = StandardCharsets.UTF_8.displayName()
}

/**
* A closure to truncate the class content
*/
Closure execute = { file ->
if (!file) return
String charset = Util.getCharset(file)
String className = Util.getFileName(file.getName())
file.text = String.format(CLASS_DECLARATION, className)
String content = String.format(CLASS_DECLARATION, className)
if (file.getName().contains(EXCEPTION_FILE_NAME)) {
String exceptionName = Util.getFileName(EXCEPTION_FILE_NAME)
file.text = String.format(CLASS_DECLARATION_EXCEPTION, className, exceptionName)
content = String.format(CLASS_DECLARATION_EXCEPTION, className, exceptionName)
}

Util.writeFile(file, content, charset, encoding)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,35 @@

package org.fundacionjala.gradle.plugins.enforce.interceptor.commands

import groovy.util.logging.Slf4j
import org.fundacionjala.gradle.plugins.enforce.utils.Util

import java.nio.charset.StandardCharsets

/**
* Implements the truncated algorithm remove any annotation in a class file
*/
@Slf4j
class ClassAnnotation {
private final int INDEX_AT_SIGN = 0
private final int INDEX_FIRST_LETTER = 1
private final int INDEX_NEXT = 1
String annotation
String encoding

ClassAnnotation() {
this.encoding = StandardCharsets.UTF_8.displayName()
}

/**
* A closure to remove any annotation in a class file
*/
Closure execute = { file ->
if (!file) return
String charset = Util.getCharset(file)
String regex = "${annotation[INDEX_AT_SIGN]}[${annotation[INDEX_FIRST_LETTER].toUpperCase()}"
regex = "${regex}${annotation[INDEX_FIRST_LETTER].toLowerCase()}]${annotation.substring(INDEX_FIRST_LETTER + INDEX_NEXT)}"
file.text = file.text.replaceAll(regex, '')
String content = file.text.replaceAll(regex, '')
Util.writeFile(file, content, charset, encoding)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,27 @@

package org.fundacionjala.gradle.plugins.enforce.interceptor.commands

import groovy.util.logging.Slf4j
import org.fundacionjala.gradle.plugins.enforce.utils.Util

import java.nio.charset.StandardCharsets
import java.util.regex.Matcher

/**
* Implements the truncated algorithm to truncate the component content
*/
@Slf4j
class Component {
private final String ATTRIBUTE_REGEX = /<apex:attribute(.|\s)*?\/>/
private final String ATTRIBUTE_BY_DEFAULT = "<apex:attribute name=%s type=\"Object\" required=\"false\" description=\"Description\"/>"
private final String NAME_ATTRIBUTE = "name"
private final String COMPONENT_BY_DEFAULT = "<apex:component>%s\n</apex:component>"
private final int INDEX_ATTRIBUTE = 0
String encoding

Component() {
this.encoding = StandardCharsets.UTF_8.displayName()
}

/**
* A closure to truncate the component content
Expand All @@ -24,6 +34,7 @@ class Component {
if (!file) {
return
}
String charset = Util.getCharset(file)
String component = file.text
String newAttributes = ""
String attribute = ""
Expand All @@ -40,7 +51,7 @@ class Component {
attributeName = attribute.substring(indexIniName, indexEndName + 1)
newAttributes += "\n${String.format(ATTRIBUTE_BY_DEFAULT, attributeName)}"
}

file.text = String.format(COMPONENT_BY_DEFAULT, newAttributes)
String content = String.format(COMPONENT_BY_DEFAULT, newAttributes)
Util.writeFile(file, content, charset, encoding)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@

package org.fundacionjala.gradle.plugins.enforce.interceptor.commands

import groovy.util.logging.Slf4j
import org.fundacionjala.gradle.plugins.enforce.utils.Util

import java.nio.charset.StandardCharsets

/**
* Implements the truncated algorithm to replace an "action override" by default for all "action overrides"
* that matches with the regex in an object file
*/
@Slf4j
class ObjectActionOverride {
private final String ATTRIB_ACTION_NAME = 'actionName'
private final String ATTRIB_TYPE = 'type'
Expand All @@ -19,13 +25,20 @@ class ObjectActionOverride {
private final String REPLACEMENT_TYPE = "<${ATTRIB_TYPE}>Default</${ATTRIB_TYPE}>"
private
final String REPLACEMENT_TEXT = "<${ATTRIB_ACTION_OVERRIDE}><${ATTRIB_ACTION_NAME}>\$1</${ATTRIB_ACTION_NAME}>${REPLACEMENT_TYPE}"
String encoding

ObjectActionOverride() {
this.encoding = StandardCharsets.UTF_8.displayName()
}

/**
* A closure to replace an "action override" by default for all "action override"
* that matches with the regex in an object file
*/
Closure execute = { file ->
if (!file) return
file.text = file.text.replaceAll(REGEX_ACTION, REPLACEMENT_TEXT)
String charset = Util.getCharset(file)
String content = file.text.replaceAll(REGEX_ACTION, REPLACEMENT_TEXT)
Util.writeFile(file, content, charset, encoding)
}
}
Loading

0 comments on commit 2da6fb7

Please sign in to comment.