Skip to content

Commit 98c7a29

Browse files
committed
Added methods for controlling how the p2 action is carried out. Workaround for #19.
1 parent 144104d commit 98c7a29

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/main/java/com/diffplug/gradle/oomph/OomphIdeExtension.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@
5656
import com.diffplug.gradle.p2.P2Declarative;
5757
import com.diffplug.gradle.p2.P2Model;
5858
import com.diffplug.gradle.p2.P2Model.DirectorApp;
59+
import com.diffplug.gradle.pde.EclipseRelease;
60+
import com.diffplug.gradle.pde.PdeInstallation;
5961

6062
/** DSL for {@link OomphIdePlugin}. */
6163
public class OomphIdeExtension implements P2Declarative {
@@ -76,6 +78,8 @@ public class OomphIdeExtension implements P2Declarative {
7678
Object ideDir = "build/oomph-ide" + FileMisc.macApp();
7779
@Nonnull
7880
Action<DirectorApp> directorModifier = Actions.doNothing();
81+
@Nonnull
82+
Action<DirectorApp> runP2Using;
7983

8084
Action<EclipseIni> eclipseIni;
8185

@@ -86,6 +90,7 @@ public OomphIdeExtension(Project project) throws IOException {
8690
this.workspaceRegistry = WorkspaceRegistry.instance();
8791
this.name = project.getRootProject().getName();
8892
this.perspective = Perspectives.RESOURCES;
93+
this.runP2Using = app -> Errors.rethrow().run(() -> app.runUsingBootstrapper(project));
8994
}
9095

9196
/** Returns the underlying project. */
@@ -252,7 +257,7 @@ void ideSetupP2() throws Exception {
252257
directorModifier.execute(app);
253258

254259
// create it
255-
app.runUsingBootstrapper(project);
260+
runP2Using.execute(app);
256261
// write out the branding product
257262
writeBrandingPlugin(ideDir);
258263
// setup the eclipse.ini file
@@ -261,6 +266,23 @@ void ideSetupP2() throws Exception {
261266
FileMisc.writeToken(ideDir, STALE_TOKEN, p2state());
262267
}
263268

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+
264286
private BufferedImage loadImg(Object obj) throws IOException {
265287
File file = project.file(obj);
266288
Preconditions.checkArgument(file.isFile(), "Image file %s does not exist!", file);

0 commit comments

Comments
 (0)