Skip to content

Commit 63dea59

Browse files
committed
Fallback to hard-coded archetype list
1 parent b2a3398 commit 63dea59

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Version 2.6.2 (2017-08-10)
22

3-
* [chg] Use `web-archetype` as default archetype id when manually entering coordinates during generation.
4-
* [chg] If the user cancels (ctrl+c) generation during questions, still render the template with fallback variables.
3+
* [chg] Add a fallback to hard-coded archetype list for project generation.
4+
* [chg] In the case of project generation with a custom archetype, ensures that archetype id is not blank.
5+
* [chg] If the user cancels (ctrl+c) project generation during questions, still render the template with fallback values.
56

67
# Version 2.6.1 (2017-08-04)
78

src/license/THIRD-PARTY.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# Please fill the missing licenses for dependencies :
1414
#
1515
#
16-
#Thu Aug 10 14:33:05 CEST 2017
16+
#Thu Aug 10 14:59:44 CEST 2017
1717
classworlds--classworlds--1.1-alpha-2=
1818
commons-collections--commons-collections--3.1=
1919
dom4j--dom4j--1.6.1=

src/main/java/org/seedstack/maven/GenerateMojo.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,24 +113,21 @@ public void execute() throws MojoExecutionException, MojoFailureException {
113113
archetypeVersion = artifactResolver.getHighestVersion(mavenProject, distributionGroupId, distributionArtifactId, allowSnapshots);
114114
getLog().info("Resolved version " + archetypeVersion);
115115
}
116-
Set<String> possibleTypes = findProjectTypes(archetypeGroupId, archetypeVersion, remoteCatalog);
117116
try {
118117
// We have a list of possible types, let the user choose
119-
if (!possibleTypes.isEmpty()) {
120-
ArrayList<String> list = new ArrayList<>(possibleTypes);
121-
Collections.sort(list);
122-
list.add("custom archetype");
123-
type = prompter.promptList("Choose the project type", Value.convertList(list));
124-
} else {
125-
getLog().info("No " + archetypeVersion + " archetype found, enter coordinates manually");
126-
}
118+
ArrayList<String> list = new ArrayList<>(findProjectTypes(archetypeGroupId, archetypeVersion, remoteCatalog));
119+
Collections.sort(list);
120+
list.add("custom archetype");
121+
type = prompter.promptList("Choose the project type", Value.convertList(list));
127122

128-
// No possible types or the user wants to input a custom archetype
129-
if (possibleTypes.isEmpty() || "custom archetype".equals(type)) {
123+
// If the user wants to input a custom archetype
124+
if ("custom archetype".equals(type)) {
130125
// Ask for archetype group id (defaults to distribution group id)
131126
archetypeGroupId = prompter.promptInput("Enter the archetype group id", archetypeGroupId);
132127
// Ask for archetype artifact id
133-
archetypeArtifactId = prompter.promptInput("Enter the archetype artifact id", "web-archetype");
128+
while (archetypeArtifactId == null || archetypeArtifactId.isEmpty()) {
129+
archetypeArtifactId = prompter.promptInput("Enter the archetype artifact id", null);
130+
}
134131
// Ask for archetype version (defaults to latest)
135132
try {
136133
archetypeVersion = artifactResolver.getHighestVersion(mavenProject, archetypeGroupId, archetypeArtifactId, allowSnapshots);
@@ -346,6 +343,14 @@ private Set<String> findProjectTypes(String archetypeGroupId, String archetypeVe
346343
getLog().info("No remote or central " + archetypeVersion + " archetype found, trying the local catalog");
347344
possibleTypes.addAll(findArchetypes(archetypeGroupId, archetypeVersion, archetypeManager.getDefaultLocalCatalog()));
348345
}
346+
if (possibleTypes.isEmpty()) {
347+
getLog().warn("No " + archetypeVersion + " archetype found anywhere (check your Maven proxy settings), falling back to hard-coded list");
348+
possibleTypes.add("addon");
349+
possibleTypes.add("batch");
350+
possibleTypes.add("cli");
351+
possibleTypes.add("domain");
352+
possibleTypes.add("web");
353+
}
349354

350355
return possibleTypes;
351356
}

0 commit comments

Comments
 (0)