Skip to content

Commit 2b4f0f1

Browse files
committed
Search custom archetype catalog (first)
1 parent cd38b0a commit 2b4f0f1

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Version 2.6.1 (2017-08-04)
22

3-
* [new] Fallback to seedstack.org archetype catalog if nothing is found on the default remote or locally.
3+
* [chg] Search custom archetype catalog first (`http://seedstack.org/maven/` by default), then central, then local, then manual coordinates.
44

55
# Version 2.6.0 (2017-08-03)
66

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-
#Fri Aug 04 17:22:50 CEST 2017
16+
#Fri Aug 04 17:39:15 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: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {
9696
version = mavenSession.getUserProperties().getProperty("version"),
9797
archetypeGroupId = mavenSession.getUserProperties().getProperty("archetypeGroupId"),
9898
archetypeArtifactId = mavenSession.getUserProperties().getProperty("archetypeArtifactId"),
99-
archetypeVersion = mavenSession.getUserProperties().getProperty("archetypeVersion");
99+
archetypeVersion = mavenSession.getUserProperties().getProperty("archetypeVersion"),
100+
remoteCatalog = mavenSession.getUserProperties().getProperty("remoteCatalog", SEEDSTACK_ORG);
100101
boolean allowSnapshots = !mavenSession.getUserProperties().getProperty("allowSnapshots", "false").equals("false");
101102

102103

@@ -112,15 +113,18 @@ public void execute() throws MojoExecutionException, MojoFailureException {
112113
archetypeVersion = artifactResolver.getHighestVersion(mavenProject, distributionGroupId, distributionArtifactId, allowSnapshots);
113114
getLog().info("Resolved version " + archetypeVersion);
114115
}
115-
Set<String> possibleTypes = findProjectTypes(archetypeGroupId, archetypeVersion);
116+
Set<String> possibleTypes = findProjectTypes(archetypeGroupId, archetypeVersion, remoteCatalog);
116117
try {
117118
// We have a list of possible types, let the user choose
118119
if (!possibleTypes.isEmpty()) {
119120
ArrayList<String> list = new ArrayList<>(possibleTypes);
120121
Collections.sort(list);
121122
list.add("custom archetype");
122123
type = prompter.promptList("Choose the project type", Value.convertList(list));
124+
} else {
125+
getLog().info("No " + archetypeVersion + " archetype found, enter coordinates manually");
123126
}
127+
124128
// No possible types or the user wants to input a custom archetype
125129
if (possibleTypes.isEmpty() || "custom archetype".equals(type)) {
126130
// Ask for archetype group id (defaults to distribution group id)
@@ -311,21 +315,18 @@ private String processPath(String absolutePath, Map<String, Object> vars) {
311315
}
312316
}
313317

314-
private Set<String> findProjectTypes(String archetypeGroupId, String archetypeVersion) {
318+
private Set<String> findProjectTypes(String archetypeGroupId, String archetypeVersion, String remoteCatalog) {
315319
Set<String> possibleTypes = new HashSet<>();
316-
getLog().info("Searching for archetypes in remote catalog");
317-
possibleTypes.addAll(findArchetypes(archetypeGroupId, archetypeVersion, archetypeManager.getRemoteCatalog()));
320+
getLog().info("Searching for " + archetypeVersion + " archetypes in remote catalog " + remoteCatalog);
321+
possibleTypes.addAll(findArchetypes(archetypeGroupId, archetypeVersion, archetypeManager.getRemoteCatalog(remoteCatalog)));
318322

319323
if (possibleTypes.isEmpty()) {
320-
getLog().info("No remote archetype found with version " + archetypeVersion + ", trying the local catalog");
321-
possibleTypes.addAll(findArchetypes(archetypeGroupId, archetypeVersion, archetypeManager.getDefaultLocalCatalog()));
322-
}
323-
if (possibleTypes.isEmpty()) {
324-
getLog().info("No local archetype found with version " + archetypeVersion + ", falling back to seedstack.org");
325-
possibleTypes.addAll(findArchetypes(archetypeGroupId, archetypeVersion, archetypeManager.getRemoteCatalog(SEEDSTACK_ORG)));
324+
getLog().info("No remote " + archetypeVersion + " archetype found, trying the central catalog");
325+
possibleTypes.addAll(findArchetypes(archetypeGroupId, archetypeVersion, archetypeManager.getRemoteCatalog()));
326326
}
327327
if (possibleTypes.isEmpty()) {
328-
getLog().info("No suitable archetype found");
328+
getLog().info("No remote or central " + archetypeVersion + " archetype found, trying the local catalog");
329+
possibleTypes.addAll(findArchetypes(archetypeGroupId, archetypeVersion, archetypeManager.getDefaultLocalCatalog()));
329330
}
330331

331332
return possibleTypes;

0 commit comments

Comments
 (0)