From a7917a581c9ef6b1d0c0b2c8907e473711092a5b Mon Sep 17 00:00:00 2001 From: hacki11 Date: Sun, 4 Feb 2018 14:50:02 +0100 Subject: [PATCH 1/4] Allow providing a pde bootstrap installation like p2bootstrap feature does with a pdebootstrapurl override This can be an advantage if you are behind restrictive proxies bc by default pde is downloaded from p2 repos --- .../diffplug/gradle/GoomphCacheLocations.java | 21 +++++++ .../diffplug/gradle/pde/PdeInstallation.java | 56 +++++++++++++++---- .../pde/PdeBootstrapInstallationCreate.java | 43 ++++++++++++++ 3 files changed, 110 insertions(+), 10 deletions(-) create mode 100644 src/test/java/com/diffplug/gradle/pde/PdeBootstrapInstallationCreate.java diff --git a/src/main/java/com/diffplug/gradle/GoomphCacheLocations.java b/src/main/java/com/diffplug/gradle/GoomphCacheLocations.java index 550bf7167..adf7d2d0c 100644 --- a/src/main/java/com/diffplug/gradle/GoomphCacheLocations.java +++ b/src/main/java/com/diffplug/gradle/GoomphCacheLocations.java @@ -36,6 +36,7 @@ * * - {@link #p2bootstrap()} * - {@link #pdeBootstrap()} + * - {@link #pdeBootstrapUrl()} * - {@link #bundlePool()} * - {@link #workspaces()} * @@ -121,6 +122,26 @@ public static File p2bootstrap() { public static File override_p2bootstrap = null; + /** + * Location where the pde-bootstrap application should be downloaded from. + * + * Goomph's pde tasks rely on the eclipse [p2 director application](http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fp2_director.html&cp=2_0_20_2). + * It is distributed within the Eclipse SDK. The Package is + * downloaded and installed during configuration from official eclipse + * repository. + * + * Defaults to official update site of the selected Eclipse Release. If you override, it still + * needs to follow the correct versioning scheme. e.g. if you want to relocate to `http://intranet/goomph-pde-boostrap`, then + * the artifact will need to be available at `http://intranet/goomph-pde-boostrap/4.5.2/goomph-pde-bootstrap.zip` + * + * As new versions of pdeBootstrap come out, you will have to update your internal URL cache, but these releases are infrequent. + */ + public static Optional pdeBootstrapUrl() { + return Optional.ofNullable(override_pdeBootstrapUrl); + } + + public static String override_pdeBootstrapUrl = null; + /** * Location where eclipse instances with PDE build * are cached: `~/.goomph/pde-bootstrap`. diff --git a/src/main/java/com/diffplug/gradle/pde/PdeInstallation.java b/src/main/java/com/diffplug/gradle/pde/PdeInstallation.java index 8f84d5472..2401d416a 100644 --- a/src/main/java/com/diffplug/gradle/pde/PdeInstallation.java +++ b/src/main/java/com/diffplug/gradle/pde/PdeInstallation.java @@ -16,13 +16,16 @@ package com.diffplug.gradle.pde; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; +import java.net.URL; import java.nio.file.Files; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.Optional; +import com.diffplug.gradle.ZipMisc; import org.apache.commons.io.FileUtils; import org.gradle.api.Project; import org.osgi.framework.Version; @@ -41,9 +44,13 @@ /** Wraps a PDE installation for the given eclipse release.*/ public class PdeInstallation implements EclipseRunner { + + static final String DOWNLOAD_FILE = "/goomph-pde-bootstrap.zip"; + static final String VERSIONED_DOWNLOAD_FILE = "/goomph-pde-bootstrap-%s.zip"; + /** * Returns a PdeInstallation based on `GOOMPH_PDE_VER`, and other factors. - * + * * You must specify which version of Eclipse should be used by Goomph. * - Option #1: To use an officially supported release, use this: * + `GOOMPH_PDE_VER`=4.5.2 (or any official release) @@ -51,7 +58,7 @@ public class PdeInstallation implements EclipseRunner { * + `GOOMPH_PDE_VER`= * + `GOOMPH_PDE_UDPATE_SITE`= * + `GOOMPH_PDE_ID`= Date: Sun, 4 Feb 2018 15:18:14 +0100 Subject: [PATCH 2/4] change whitespaces to tabs for spotless --- .../diffplug/gradle/pde/PdeInstallation.java | 44 +++++++++---------- .../pde/PdeBootstrapInstallationCreate.java | 9 ++-- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/main/java/com/diffplug/gradle/pde/PdeInstallation.java b/src/main/java/com/diffplug/gradle/pde/PdeInstallation.java index 2401d416a..33f7ff354 100644 --- a/src/main/java/com/diffplug/gradle/pde/PdeInstallation.java +++ b/src/main/java/com/diffplug/gradle/pde/PdeInstallation.java @@ -25,7 +25,6 @@ import java.util.Objects; import java.util.Optional; -import com.diffplug.gradle.ZipMisc; import org.apache.commons.io.FileUtils; import org.gradle.api.Project; import org.osgi.framework.Version; @@ -37,6 +36,7 @@ import com.diffplug.common.swt.os.SwtPlatform; import com.diffplug.gradle.FileMisc; import com.diffplug.gradle.GoomphCacheLocations; +import com.diffplug.gradle.ZipMisc; import com.diffplug.gradle.eclipserunner.EclipseApp; import com.diffplug.gradle.eclipserunner.EclipseRunner; import com.diffplug.gradle.eclipserunner.NativeRunner; @@ -165,24 +165,24 @@ private boolean isInstalled() throws IOException { /** Installs the bootstrap installation. */ private void install() throws Exception { - if(GoomphCacheLocations.pdeBootstrapUrl().isPresent()) { + if (GoomphCacheLocations.pdeBootstrapUrl().isPresent()) { String url = GoomphCacheLocations.pdeBootstrapUrl().get(); System.out.print("Installing pde " + release + " from " + url + "... "); - File target = new File(getRootFolder(), DOWNLOAD_FILE); + File target = new File(getRootFolder(), DOWNLOAD_FILE); try { obtainBootstrap(url + release.version() + DOWNLOAD_FILE, target); } catch (FileNotFoundException ex) { //try versioned artifact - Common when bootstrap is on a maven type(sonatype nexus, etc.) repository. obtainBootstrap(url + release.version() + String.format(VERSIONED_DOWNLOAD_FILE, release.version()), target); } - // unzip it - ZipMisc.unzip(target, target.getParentFile()); - // delete the zip - FileMisc.forceDelete(target); - } else { + // unzip it + ZipMisc.unzip(target, target.getParentFile()); + // delete the zip + FileMisc.forceDelete(target); + } else { System.out.print("Installing pde " + release + "... "); - obtainBootstrap(release); - } + obtainBootstrap(release); + } // parse out the pde.build version File bundleInfo = new File(getContentsEclipse(), "configuration/org.eclipse.equinox.simpleconfigurator/bundles.info"); @@ -196,20 +196,20 @@ private void install() throws Exception { } /** Obtain PDE Installation from custom file or url */ - private void obtainBootstrap(String bootstrapUrl, File target) throws IOException { - URL url = new URL(bootstrapUrl); - FileUtils.copyURLToFile(url, target); - } + private void obtainBootstrap(String bootstrapUrl, File target) throws IOException { + URL url = new URL(bootstrapUrl); + FileUtils.copyURLToFile(url, target); + } - /** Obtain PDE Installation from remote p2 repository */ + /** Obtain PDE Installation from remote p2 repository */ private void obtainBootstrap(EclipseRelease release) throws Exception { - P2Model.DirectorApp directorApp = p2model().directorApp(getRootFolder(), "goomph-pde-bootstrap-" + release); - // share the install for quickness - directorApp.bundlepool(GoomphCacheLocations.bundlePool()); - // create a native launcher - directorApp.platform(SwtPlatform.getRunning()); - directorApp.runUsingBootstrapper(); - } + P2Model.DirectorApp directorApp = p2model().directorApp(getRootFolder(), "goomph-pde-bootstrap-" + release); + // share the install for quickness + directorApp.bundlepool(GoomphCacheLocations.bundlePool()); + // create a native launcher + directorApp.platform(SwtPlatform.getRunning()); + directorApp.runUsingBootstrapper(); + } /** Returns the Contents/Eclipse folder on mac, or just the root folder on other OSes. */ private File getContentsEclipse() { diff --git a/src/test/java/com/diffplug/gradle/pde/PdeBootstrapInstallationCreate.java b/src/test/java/com/diffplug/gradle/pde/PdeBootstrapInstallationCreate.java index 03f49c3da..9d59c3699 100644 --- a/src/test/java/com/diffplug/gradle/pde/PdeBootstrapInstallationCreate.java +++ b/src/test/java/com/diffplug/gradle/pde/PdeBootstrapInstallationCreate.java @@ -15,13 +15,12 @@ */ package com.diffplug.gradle.pde; -import com.diffplug.gradle.FileMisc; -import com.diffplug.gradle.p2.P2Model; -import com.diffplug.gradle.pde.EclipseRelease; -import com.diffplug.gradle.pde.PdeInstallation; +import java.io.File; + import org.gradle.internal.impldep.com.google.common.base.StandardSystemProperty; -import java.io.File; +import com.diffplug.gradle.FileMisc; +import com.diffplug.gradle.p2.P2Model; /** Creates a new folder for goomph-pde-bootstrap. */ public class PdeBootstrapInstallationCreate { From c0e94435e3c2067691e20071b5c35170aafc4bb5 Mon Sep 17 00:00:00 2001 From: hacki11 Date: Sun, 4 Feb 2018 16:54:42 +0100 Subject: [PATCH 3/4] add #49 to changes.md --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index c9ccb398b..f8b572a30 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,8 @@ ### Version 3.10.0 - TBD ([javadoc](http://diffplug.github.io/goomph/javadoc/snapshot/), [snapshot](https://oss.sonatype.org/content/repositories/snapshots/com/diffplug/gradle/goomph/)) +- Added a feature to provide a custom goomph-pde-bootstrap installation. [(#49)](https://github.com/diffplug/goomph/pull/52) + ### Version 3.9.1 - February 2nd 2018 ([javadoc](http://diffplug.github.io/goomph/javadoc/3.9.1/), [jcenter](https://bintray.com/diffplug/opensource/goomph/3.9.1/view)) - Added `--launcher.suppressErrors` to all `EclipseApp` invocations so that build errors won't open a blocking dialog on build servers. [(#49)](https://github.com/diffplug/goomph/pull/49) From d4ea45e1a572370541f840083afd6558fa76307c Mon Sep 17 00:00:00 2001 From: hacki11 Date: Sun, 4 Feb 2018 17:05:02 +0100 Subject: [PATCH 4/4] mixed up pull requests --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index f8b572a30..64d0fcddb 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,7 +2,7 @@ ### Version 3.10.0 - TBD ([javadoc](http://diffplug.github.io/goomph/javadoc/snapshot/), [snapshot](https://oss.sonatype.org/content/repositories/snapshots/com/diffplug/gradle/goomph/)) -- Added a feature to provide a custom goomph-pde-bootstrap installation. [(#49)](https://github.com/diffplug/goomph/pull/52) +- Added a feature to provide a custom goomph-pde-bootstrap installation. [(#52)](https://github.com/diffplug/goomph/pull/52) ### Version 3.9.1 - February 2nd 2018 ([javadoc](http://diffplug.github.io/goomph/javadoc/3.9.1/), [jcenter](https://bintray.com/diffplug/opensource/goomph/3.9.1/view))