Skip to content

Commit b2a3398

Browse files
committed
Pass system properties to build sub-modules in release mojo
1 parent 2b4f0f1 commit b2a3398

File tree

4 files changed

+31
-8
lines changed

4 files changed

+31
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Version 2.6.2 (2017-08-10)
2+
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.
5+
16
# Version 2.6.1 (2017-08-04)
27

38
* [chg] Search custom archetype catalog first (`http://seedstack.org/maven/` by default), then central, then local, then manual coordinates.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<groupId>org.seedstack</groupId>
2121
<artifactId>seedstack-maven-plugin</artifactId>
22-
<version>2.6.1-SNAPSHOT</version>
22+
<version>2.6.2-SNAPSHOT</version>
2323
<packaging>maven-plugin</packaging>
2424

2525
<properties>

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:39:15 CEST 2017
16+
#Thu Aug 10 14:33:05 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: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
130130
// Ask for archetype group id (defaults to distribution group id)
131131
archetypeGroupId = prompter.promptInput("Enter the archetype group id", archetypeGroupId);
132132
// Ask for archetype artifact id
133-
archetypeArtifactId = prompter.promptInput("Enter the archetype artifact id", null);
133+
archetypeArtifactId = prompter.promptInput("Enter the archetype artifact id", "web-archetype");
134134
// Ask for archetype version (defaults to latest)
135135
try {
136136
archetypeVersion = artifactResolver.getHighestVersion(mavenProject, archetypeGroupId, archetypeArtifactId, allowSnapshots);
@@ -206,8 +206,10 @@ public void execute() throws MojoExecutionException, MojoFailureException {
206206

207207
executionEnvironment(mavenProject, mavenSession, buildPluginManager));
208208

209-
File projectDir = new File("." + File.separator + artifactId);
209+
final File projectDir = new File("." + File.separator + artifactId);
210210
if (projectDir.exists() && projectDir.canWrite()) {
211+
final File questionFile = new File(projectDir, "questions.json");
212+
211213
// Create template engines
212214
stringTemplateEngine = new PebbleEngine.Builder()
213215
.loader(new StringLoader())
@@ -218,7 +220,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
218220
.build();
219221

220222
// Create vars
221-
HashMap<String, Object> vars = new HashMap<>();
223+
final HashMap<String, Object> vars = new HashMap<>();
222224

223225
// Put project values in vars
224226
HashMap<String, Object> projectVars = new HashMap<>();
@@ -240,11 +242,24 @@ public void execute() throws MojoExecutionException, MojoFailureException {
240242
archetypeVars.put("version", archetypeVersion);
241243
vars.put("archetype", archetypeVars);
242244

245+
Thread shutdownRender = new Thread(new Runnable() {
246+
@Override
247+
public void run() {
248+
renderTemplates(projectDir, vars);
249+
if (questionFile.exists() && questionFile.canRead() && !questionFile.delete()) {
250+
getLog().warn("Unable to delete question file, useless files may be still be present in project");
251+
}
252+
}
253+
}, "render-hook");
254+
255+
// If the user cancels during question, complete the process with minimal vars
256+
Runtime.getRuntime().addShutdownHook(shutdownRender);
257+
243258
// Inquire from user if a question file is present
259+
HashMap<String, Object> varsWithAnswers = new HashMap<>(vars);
244260
try {
245-
File questionFile = new File(projectDir, "questions.json");
246261
if (questionFile.exists() && questionFile.canRead()) {
247-
vars.putAll(inquire.inquire(questionFile.toURI().toURL()));
262+
varsWithAnswers.putAll(inquire.inquire(questionFile.toURI().toURL()));
248263
if (!questionFile.delete()) {
249264
getLog().warn("Unable to delete question file, useless files may be still be present in project");
250265
}
@@ -253,7 +268,10 @@ public void execute() throws MojoExecutionException, MojoFailureException {
253268
getLog().error("Unable to process question file, resulting project might be unusable", e);
254269
}
255270

256-
renderTemplates(projectDir, vars);
271+
// We can now do the rendering properly, cancel the shutdown hook
272+
Runtime.getRuntime().removeShutdownHook(shutdownRender);
273+
274+
renderTemplates(projectDir, varsWithAnswers);
257275
}
258276
}
259277

0 commit comments

Comments
 (0)