Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ abstract class AbstractProfile implements Profile {
protected List<String> buildPlugins = []
protected List<String> buildExcludes = []
protected List<String> skeletonExcludes = []
protected List<String> binaryExtensions = []
protected List<String> executablePatterns = []
protected final List<Command> internalCommands = []
protected List<String> buildMerge = null
protected List<Feature> features = []
Expand Down Expand Up @@ -203,14 +205,36 @@ abstract class AbstractProfile implements Profile {
this.buildMerge = (List<String>)navigableConfig.get("build.merge", null)
this.parentTargetFolder = (String)navigableConfig.get("skeleton.parent.target", null)
this.skeletonExcludes = (List<String>)navigableConfig.get("skeleton.excludes", [])
this.binaryExtensions = (List<String>)navigableConfig.get("skeleton.binaryExtensions", [])
this.executablePatterns = (List<String>)navigableConfig.get("skeleton.executable", [])
}

String getDescription() {
return description
description
}

String getInstructions() {
return instructions
instructions
}

Set<String> getBinaryExtensions() {
Set<String> calculatedBinaryExtensions = []
def parents = getExtends()
for(profile in parents) {
calculatedBinaryExtensions.addAll(profile.binaryExtensions)
}
calculatedBinaryExtensions.addAll(binaryExtensions)
return calculatedBinaryExtensions
}

Set<String> getExecutablePatterns() {
Set<String> calculatedExecutablePatterns = []
def parents = getExtends()
for(profile in parents) {
calculatedExecutablePatterns.addAll(profile.executablePatterns)
}
calculatedExecutablePatterns.addAll(executablePatterns)
return calculatedExecutablePatterns
}

@Override
Expand Down
12 changes: 10 additions & 2 deletions grails-shell/src/main/groovy/org/grails/cli/profile/Profile.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -51,6 +50,15 @@ public interface Profile {
*/
String getDescription();

/**
* @return The list of file extensions which should be treated as binary
*/
Set<String> getBinaryExtensions();

/**
* @return The list of file patterns which should be executable in the resulting application
*/
Set<String> getExecutablePatterns();

/**
* @return Text to display after an application has been created with the profile
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos
String groupname
String defaultpackagename
File targetDirectory
List<String> binaryFileExtensions = ['png','gif','jpg','jpeg','ico','icns','pdf','zip','jar','class']

CommandDescription description = new CommandDescription(name, "Creates an application", "create-app [NAME] --profile=web")

Expand Down Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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<File> sourceBuildGradles = findAllFilesByName(skeletonDir, BUILD_GRADLE)

Expand All @@ -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<String> binaryFileExtensions) {
ant.copy(todir: targetDirectory, overwrite: true, encoding: 'UTF-8') {
fileSet(dir: srcDir, casesensitive: false) {
exclude(name: '**/.gitkeep')
Expand Down