Skip to content

Commit 4540461

Browse files
committed
Add feature allowing profiles to specify a target folder for parent profiles skeletons to be copied into
1 parent 19b4737 commit 4540461

File tree

3 files changed

+189
-65
lines changed

3 files changed

+189
-65
lines changed

grails-shell/src/main/groovy/org/grails/cli/profile/AbstractProfile.groovy

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package org.grails.cli.profile
1818
import grails.io.IOUtils
1919
import grails.util.BuildSettings
2020
import grails.util.CosineSimilarity
21-
import groovy.transform.CompileDynamic
2221
import groovy.transform.CompileStatic
2322
import groovy.transform.ToString
2423
import jline.console.completer.ArgumentCompleter
@@ -36,9 +35,6 @@ import org.grails.config.NavigableMap
3635
import org.grails.io.support.Resource
3736
import org.yaml.snakeyaml.Yaml
3837

39-
import java.util.regex.Matcher
40-
41-
4238
/**
4339
* Abstract implementation of the profile class
4440
*
@@ -60,11 +56,13 @@ abstract class AbstractProfile implements Profile {
6056
protected List<String> buildRepositories = []
6157
protected List<String> buildPlugins = []
6258
protected List<String> buildExcludes = []
59+
protected List<String> skeletonExcludes = []
6360
protected final List<Command> internalCommands = []
6461
protected List<String> buildMerge = null
6562
protected List<Feature> features = []
6663
protected Set<String> defaultFeaturesNames = []
6764
protected Set<String> requiredFeatureNames = []
65+
protected String parentTargetFolder
6866
final ClassLoader classLoader
6967
protected ExclusionDependencySelector exclusionDependencySelector = new ExclusionDependencySelector()
7068
protected String description = "";
@@ -201,7 +199,8 @@ abstract class AbstractProfile implements Profile {
201199
this.buildPlugins = (List<String>)navigableConfig.get("build.plugins", [])
202200
this.buildExcludes = (List<String>)navigableConfig.get("build.excludes", [])
203201
this.buildMerge = (List<String>)navigableConfig.get("build.merge", null)
204-
202+
this.parentTargetFolder = (String)navigableConfig.get("skeleton.parent.target", null)
203+
this.skeletonExcludes = (List<String>)navigableConfig.get("skeleton.excludes", [])
205204
}
206205

207206
String getDescription() {
@@ -472,4 +471,22 @@ abstract class AbstractProfile implements Profile {
472471

473472
}
474473
}
474+
475+
@Override
476+
String getParentSkeletonDir() {
477+
this.parentTargetFolder
478+
}
479+
480+
@Override
481+
File getParentSkeletonDir(File parent) {
482+
if (parentSkeletonDir) {
483+
new File(parent, parentSkeletonDir)
484+
} else {
485+
parent
486+
}
487+
}
488+
489+
List<String> getSkeletonExcludes() {
490+
this.skeletonExcludes
491+
}
475492
}

grails-shell/src/main/groovy/org/grails/cli/profile/Profile.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ public interface Profile {
108108
*/
109109
Command getCommand(ProjectContext context, String name);
110110

111-
112-
113111
/**
114112
* The profile completers
115113
* @param context The {@link org.grails.cli.profile.ProjectContext} instance
@@ -154,4 +152,18 @@ public interface Profile {
154152
*/
155153
List<String> getBuildPlugins();
156154

155+
/**
156+
* @return The subfolder the parent profile(s) skeleton should be copied into
157+
*/
158+
String getParentSkeletonDir();
159+
160+
/**
161+
* @return The directory the parent profile(s) skeleton should be copied into
162+
*/
163+
File getParentSkeletonDir(File parent);
164+
165+
/**
166+
* @return A list of paths to exclude from the skeleton. Used in ant fileset exclude:
167+
*/
168+
List<String> getSkeletonExcludes();
157169
}

0 commit comments

Comments
 (0)