Skip to content

Commit

Permalink
Upload task uploads empty folders of reports to an org
Browse files Browse the repository at this point in the history
  • Loading branch information
marcocdlv committed Oct 7, 2015
1 parent 4346c46 commit fcdc0d6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ abstract class SalesforceTask extends ForceTask {
public ArrayList<String> arrayPaths
public String projectPackagePath
public Map parameters
ArrayList<String> FOLDERS_WITH_SUB_FOLDERS = ['documents', 'reports', 'dashboards']

/**
* Sets description and group task
Expand Down Expand Up @@ -106,8 +107,10 @@ abstract class SalesforceTask extends ForceTask {
*/
void writePackage(String packagePath, ArrayList<File> files, boolean withProjectPath = true) {
FileWriter fileWriter = new FileWriter(packagePath)
files = files.grep({ file ->
!file.name.endsWith(Constants.META_XML)
files = files.grep({ File file ->
String folderName = file.getParentFile().getName()
!file.name.endsWith(Constants.META_XML) || (FOLDERS_WITH_SUB_FOLDERS.contains(folderName)
&& file.name.endsWith(Constants.META_XML))
})
if (withProjectPath) {
packageBuilder.createPackage(files, projectPath)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ class Util {
* @param fileName the file typeName
*/
public static String getFileName(String fileName) {
fileName.replaceFirst(PATTERN_FILE_EXT, '')
String result = fileName.replaceFirst(PATTERN_FILE_EXT, Constants.EMPTY)
if (fileName.contains(Constants.META_XML)) {
result = fileName.replaceFirst(Constants.META_XML, Constants.EMPTY)
}
return result
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,20 @@ class UtilTest extends Specification {
thrown(Exception)
}

def "Test should return a file name Class1.cls without its extension"() {
when:
String result = Util.getFileName('Class1.cls')
then:
result == 'Class1'
}

def "Test should return a file name 'MyReports-meta.xml' without '-meta.xml'"() {
when:
String result = Util.getFileName('MyReports-meta.xml')
then:
result == 'MyReports'
}

def cleanupSpec() {
new File(Paths.get(RESOURCES_PATH, 'triggers').toString()).deleteDir()
new File(Paths.get(RESOURCES_PATH, 'relativeTest').toString()).deleteDir()
Expand Down

0 comments on commit fcdc0d6

Please sign in to comment.