18
18
package io .quarkus .maven ;
19
19
20
20
import static org .fusesource .jansi .Ansi .ansi ;
21
+ import static org .twdata .maven .mojoexecutor .MojoExecutor .artifactId ;
22
+ import static org .twdata .maven .mojoexecutor .MojoExecutor .configuration ;
23
+ import static org .twdata .maven .mojoexecutor .MojoExecutor .element ;
24
+ import static org .twdata .maven .mojoexecutor .MojoExecutor .executeMojo ;
25
+ import static org .twdata .maven .mojoexecutor .MojoExecutor .executionEnvironment ;
26
+ import static org .twdata .maven .mojoexecutor .MojoExecutor .goal ;
27
+ import static org .twdata .maven .mojoexecutor .MojoExecutor .groupId ;
28
+ import static org .twdata .maven .mojoexecutor .MojoExecutor .name ;
29
+ import static org .twdata .maven .mojoexecutor .MojoExecutor .plugin ;
30
+ import static org .twdata .maven .mojoexecutor .MojoExecutor .version ;
21
31
22
32
import java .io .File ;
23
33
import java .io .IOException ;
29
39
import org .apache .commons .lang3 .StringUtils ;
30
40
import org .apache .maven .execution .MavenSession ;
31
41
import org .apache .maven .plugin .AbstractMojo ;
42
+ import org .apache .maven .plugin .BuildPluginManager ;
32
43
import org .apache .maven .plugin .MojoExecutionException ;
33
44
import org .apache .maven .plugins .annotations .Component ;
34
45
import org .apache .maven .plugins .annotations .Mojo ;
@@ -83,6 +94,9 @@ public class CreateProjectMojo extends AbstractMojo {
83
94
@ Component
84
95
private MavenVersionEnforcer mavenVersionEnforcer ;
85
96
97
+ @ Component
98
+ private BuildPluginManager pluginManager ;
99
+
86
100
@ Override
87
101
public void execute () throws MojoExecutionException {
88
102
// We detect the Maven version during the project generation to indicate the user immediately that the installed
@@ -136,6 +150,8 @@ public void execute() throws MojoExecutionException {
136
150
new AddExtensions (new File (projectRoot , "pom.xml" ))
137
151
.addExtensions (extensions );
138
152
}
153
+
154
+ createMavenWrapper ();
139
155
} catch (IOException e ) {
140
156
throw new MojoExecutionException (e .getMessage (), e );
141
157
}
@@ -144,6 +160,26 @@ public void execute() throws MojoExecutionException {
144
160
}
145
161
}
146
162
163
+ private void createMavenWrapper () {
164
+ try {
165
+ executeMojo (
166
+ plugin (
167
+ groupId ("io.takari" ),
168
+ artifactId ("maven" ),
169
+ version (MojoUtils .getMavenWrapperVersion ())),
170
+ goal ("wrapper" ),
171
+ configuration (
172
+ element (name ("maven" ), MojoUtils .getProposedMavenVersion ())),
173
+ executionEnvironment (
174
+ project ,
175
+ session ,
176
+ pluginManager ));
177
+ } catch (Exception e ) {
178
+ // no reason to fail if the wrapper could not be created
179
+ getLog ().debug ("Unable to create Maven Wrapper" );
180
+ }
181
+ }
182
+
147
183
private SourceType determineSourceType (Set <String > extensions ) {
148
184
return extensions .stream ().anyMatch (e -> e .toLowerCase ().contains ("kotlin" ))
149
185
? SourceType .KOTLIN
0 commit comments