Skip to content

Commit 3722629

Browse files
committed
Bootstrap archetype generation from released version
1 parent 04422d6 commit 3722629

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

maven/codenameone-maven-plugin/src/main/java/com/codename1/maven/GenerateAppProjectMojo.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ public class GenerateAppProjectMojo extends AbstractMojo {
5353
@Parameter(property="archetypeCatalog", defaultValue = "local")
5454
private String archetypeCatalog;
5555

56+
@Parameter(property = "bootstrapArchetypeVersion", defaultValue = "7.0.204")
57+
private String bootstrapArchetypeVersion;
58+
5659

5760
private Properties loadSourceProjectProperties() throws IOException {
5861
Properties props = new Properties();
@@ -76,6 +79,14 @@ private void generateProject() throws MojoExecutionException{
7679
MavenXpp3Reader reader = new MavenXpp3Reader();
7780
Model model = reader.read(getClass().getResourceAsStream("/META-INF/maven/com.codenameone/codenameone-maven-plugin/pom.xml"));
7881
archetypeVersion = model.getVersion();
82+
if (archetypeVersion != null && archetypeVersion.endsWith("-SNAPSHOT")) {
83+
String bootstrapVersion = bootstrapArchetypeVersion != null ? bootstrapArchetypeVersion.trim() : "";
84+
if (bootstrapVersion.isEmpty()) {
85+
bootstrapVersion = "LATEST";
86+
}
87+
getLog().info("Detected snapshot plugin version " + archetypeVersion + ". Bootstrapping cn1app-archetype using " + bootstrapVersion + ".");
88+
archetypeVersion = bootstrapVersion;
89+
}
7990
} catch (Exception ex) {
8091
getLog().warn("Attempted to read archetype version from embedded pom.xml file but failed", ex);
8192
}
@@ -84,6 +95,9 @@ private void generateProject() throws MojoExecutionException{
8495

8596
request.setGoals( Collections.singletonList( "archetype:generate" ) );
8697

98+
request.setBatchMode(true);
99+
request.setInteractive(false);
100+
87101
String[] propsArr = {
88102
"interactiveMode=false",
89103
"archetypeArtifactId=cn1app-archetype",
@@ -120,6 +134,19 @@ private void generateProject() throws MojoExecutionException{
120134
request.setProperties(props);
121135

122136
Invoker invoker = new DefaultInvoker();
137+
invoker.setInputStream(new ByteArrayInputStream(new byte[0]));
138+
invoker.setOutputHandler(line -> {
139+
if (line == null || line.contains("Progress (")) {
140+
return;
141+
}
142+
getLog().info(line);
143+
});
144+
invoker.setErrorHandler(line -> {
145+
if (line == null || line.contains("Progress (")) {
146+
return;
147+
}
148+
getLog().error(line);
149+
});
123150
try {
124151
InvocationResult result = invoker.execute( request );
125152
if (result.getExitCode() != 0) {

0 commit comments

Comments
 (0)