56
56
import com .diffplug .gradle .p2 .P2Declarative ;
57
57
import com .diffplug .gradle .p2 .P2Model ;
58
58
import com .diffplug .gradle .p2 .P2Model .DirectorApp ;
59
+ import com .diffplug .gradle .pde .EclipseRelease ;
60
+ import com .diffplug .gradle .pde .PdeInstallation ;
59
61
60
62
/** DSL for {@link OomphIdePlugin}. */
61
63
public class OomphIdeExtension implements P2Declarative {
@@ -76,6 +78,8 @@ public class OomphIdeExtension implements P2Declarative {
76
78
Object ideDir = "build/oomph-ide" + FileMisc .macApp ();
77
79
@ Nonnull
78
80
Action <DirectorApp > directorModifier = Actions .doNothing ();
81
+ @ Nonnull
82
+ Action <DirectorApp > runP2Using ;
79
83
80
84
Action <EclipseIni > eclipseIni ;
81
85
@@ -86,6 +90,7 @@ public OomphIdeExtension(Project project) throws IOException {
86
90
this .workspaceRegistry = WorkspaceRegistry .instance ();
87
91
this .name = project .getRootProject ().getName ();
88
92
this .perspective = Perspectives .RESOURCES ;
93
+ this .runP2Using = app -> Errors .rethrow ().run (() -> app .runUsingBootstrapper (project ));
89
94
}
90
95
91
96
/** Returns the underlying project. */
@@ -252,7 +257,7 @@ void ideSetupP2() throws Exception {
252
257
directorModifier .execute (app );
253
258
254
259
// create it
255
- app . runUsingBootstrapper ( project );
260
+ runP2Using . execute ( app );
256
261
// write out the branding product
257
262
writeBrandingPlugin (ideDir );
258
263
// setup the eclipse.ini file
@@ -261,6 +266,23 @@ void ideSetupP2() throws Exception {
261
266
FileMisc .writeToken (ideDir , STALE_TOKEN , p2state ());
262
267
}
263
268
269
+ /** Defaults to {@link DirectorApp#runUsingBootstrapper()} - this allows you to override that behavior. */
270
+ public void runP2Using (Action <DirectorApp > runUsing ) {
271
+ this .runP2Using = runUsing ;
272
+ }
273
+
274
+ /** Provisions using the given version of the full Eclipse PDE. */
275
+ public void runP2UsingPDE (String version ) {
276
+ runP2Using (directorApp -> Errors .rethrow ().run (() -> {
277
+ directorApp .runUsing (PdeInstallation .from (EclipseRelease .official (version )));
278
+ }));
279
+ }
280
+
281
+ /** Provisions using the latest available version of the full Eclipse PDE. */
282
+ public void runP2UsingPDE () {
283
+ runP2UsingPDE (EclipseRelease .LATEST );
284
+ }
285
+
264
286
private BufferedImage loadImg (Object obj ) throws IOException {
265
287
File file = project .file (obj );
266
288
Preconditions .checkArgument (file .isFile (), "Image file %s does not exist!" , file );
0 commit comments