diff --git a/grails-shell/src/main/groovy/org/grails/cli/profile/AbstractProfile.groovy b/grails-shell/src/main/groovy/org/grails/cli/profile/AbstractProfile.groovy index a4bb0abd40b..7152e01dfe5 100644 --- a/grails-shell/src/main/groovy/org/grails/cli/profile/AbstractProfile.groovy +++ b/grails-shell/src/main/groovy/org/grails/cli/profile/AbstractProfile.groovy @@ -57,6 +57,8 @@ abstract class AbstractProfile implements Profile { protected List buildPlugins = [] protected List buildExcludes = [] protected List skeletonExcludes = [] + protected List binaryExtensions = [] + protected List executablePatterns = [] protected final List internalCommands = [] protected List buildMerge = null protected List features = [] @@ -203,14 +205,36 @@ abstract class AbstractProfile implements Profile { this.buildMerge = (List)navigableConfig.get("build.merge", null) this.parentTargetFolder = (String)navigableConfig.get("skeleton.parent.target", null) this.skeletonExcludes = (List)navigableConfig.get("skeleton.excludes", []) + this.binaryExtensions = (List)navigableConfig.get("skeleton.binaryExtensions", []) + this.executablePatterns = (List)navigableConfig.get("skeleton.executable", []) } String getDescription() { - return description + description } String getInstructions() { - return instructions + instructions + } + + Set getBinaryExtensions() { + Set calculatedBinaryExtensions = [] + def parents = getExtends() + for(profile in parents) { + calculatedBinaryExtensions.addAll(profile.binaryExtensions) + } + calculatedBinaryExtensions.addAll(binaryExtensions) + return calculatedBinaryExtensions + } + + Set getExecutablePatterns() { + Set calculatedExecutablePatterns = [] + def parents = getExtends() + for(profile in parents) { + calculatedExecutablePatterns.addAll(profile.executablePatterns) + } + calculatedExecutablePatterns.addAll(executablePatterns) + return calculatedExecutablePatterns } @Override diff --git a/grails-shell/src/main/groovy/org/grails/cli/profile/Profile.java b/grails-shell/src/main/groovy/org/grails/cli/profile/Profile.java index 3c3e8eea880..b373b3eb802 100644 --- a/grails-shell/src/main/groovy/org/grails/cli/profile/Profile.java +++ b/grails-shell/src/main/groovy/org/grails/cli/profile/Profile.java @@ -21,9 +21,8 @@ import org.grails.io.support.Resource; import java.io.File; -import java.util.Collection; import java.util.List; -import java.util.Map; +import java.util.Set; /** * A Profile defines an active code generation and command execution policy. For example the "web" profile allows @@ -51,6 +50,15 @@ public interface Profile { */ String getDescription(); + /** + * @return The list of file extensions which should be treated as binary + */ + Set getBinaryExtensions(); + + /** + * @return The list of file patterns which should be executable in the resulting application + */ + Set getExecutablePatterns(); /** * @return Text to display after an application has been created with the profile diff --git a/grails-shell/src/main/groovy/org/grails/cli/profile/commands/CreateAppCommand.groovy b/grails-shell/src/main/groovy/org/grails/cli/profile/commands/CreateAppCommand.groovy index 5cf01fb148d..02c8aa1567d 100644 --- a/grails-shell/src/main/groovy/org/grails/cli/profile/commands/CreateAppCommand.groovy +++ b/grails-shell/src/main/groovy/org/grails/cli/profile/commands/CreateAppCommand.groovy @@ -67,7 +67,6 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos String groupname String defaultpackagename File targetDirectory - List binaryFileExtensions = ['png','gif','jpg','jpeg','ico','icns','pdf','zip','jar','class'] CommandDescription description = new CommandDescription(name, "Creates an application", "create-app [NAME] --profile=web") @@ -276,7 +275,7 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos appendFeatureFiles(skeletonDir) if(skeletonDir.exists()) { - copySrcToTarget(ant, skeletonDir, ['**/' + APPLICATION_YML]) + copySrcToTarget(ant, skeletonDir, ['**/' + APPLICATION_YML], profileInstance.binaryExtensions) } } @@ -583,8 +582,7 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos def tmpDir = unzipProfile(ant, skeletonResource) skeletonDir = new File(tmpDir, "META-INF/grails-profile/skeleton") } - copySrcToTarget(ant, skeletonDir, excludes) - + copySrcToTarget(ant, skeletonDir, excludes, profile.binaryExtensions) Set sourceBuildGradles = findAllFilesByName(skeletonDir, BUILD_GRADLE) @@ -610,12 +608,11 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos } } - ant.chmod(dir: targetDirectory, includes: "**/gradlew*", perm: 'u+x') - ant.chmod(dir: targetDirectory, includes: "**/grailsw*", perm: 'u+x') + ant.chmod(dir: targetDirectory, includes: profile.executablePatterns.join(' '), perm: 'u+x') } @CompileDynamic - protected void copySrcToTarget(GrailsConsoleAntBuilder ant, File srcDir, List excludes) { + protected void copySrcToTarget(GrailsConsoleAntBuilder ant, File srcDir, List excludes, Set binaryFileExtensions) { ant.copy(todir: targetDirectory, overwrite: true, encoding: 'UTF-8') { fileSet(dir: srcDir, casesensitive: false) { exclude(name: '**/.gitkeep')