diff --git a/.gitignore b/.gitignore index 8b2156df53..f4715be5e6 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,8 @@ buildSrc/.gradle .DS_Store /.gradle/ /build/ +**/.settings/org.eclipse.buildship.core.prefs +.classpath # Common .project diff --git a/build.gradle.kts b/build.gradle.kts index 439f333b13..32fbf342cf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -123,6 +123,12 @@ subprojects { } } + /* + * Define default eclipse version that is used for resolving + * dependencies and building the update site. + */ + projectToConf.extra["eclipseVersion"] = "4.8.0" + /* * Make common dependency definitions accessible by all sub-projects */ diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 44a00a2a06..bb8a3ff87d 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -9,7 +9,7 @@ repositories { } dependencies { - compile("com.diffplug.gradle:goomph:3.22.0") + compile("com.diffplug.gradle:goomph:3.24.0") compile("gradle.plugin.org.jetbrains.intellij.plugins:gradle-intellij-plugin:0.4.21") } diff --git a/buildSrc/src/main/java/saros/gradle/eclipse/SarosEclipseExtension.java b/buildSrc/src/main/java/saros/gradle/eclipse/SarosEclipseExtension.java index 6fe4ae1373..e6f75195c3 100644 --- a/buildSrc/src/main/java/saros/gradle/eclipse/SarosEclipseExtension.java +++ b/buildSrc/src/main/java/saros/gradle/eclipse/SarosEclipseExtension.java @@ -24,7 +24,7 @@ */ public class SarosEclipseExtension { private File manifest = null; - private String eclipseVersion = "4.8.0"; + private String eclipseVersion = null; private String pluginVersionQualifier = null; private List excludeManifestDependencies = new ArrayList<>(); private boolean addDependencies = false; diff --git a/buildSrc/src/main/java/saros/gradle/eclipse/SarosEclipsePlugin.java b/buildSrc/src/main/java/saros/gradle/eclipse/SarosEclipsePlugin.java index 4ccda192a1..7f7674b5eb 100644 --- a/buildSrc/src/main/java/saros/gradle/eclipse/SarosEclipsePlugin.java +++ b/buildSrc/src/main/java/saros/gradle/eclipse/SarosEclipsePlugin.java @@ -75,9 +75,13 @@ private void configureEclipseAfterEvaluate(Project p, SarosEclipseExtension e) { if (e.isAddDependencies()) { methodRequiresManifest("add dependencies", e); + String eclipseVersion = e.getEclipseVersion(); + if (eclipseVersion == null) + throw new GradleException( + "Unable to add osgi dependencies without an eclipse version specification."); + new OsgiDependencyConfigurator(p) - .addDependencies( - e.getManifest(), e.getExcludeManifestDependencies(), e.getEclipseVersion()); + .addDependencies(e.getManifest(), e.getExcludeManifestDependencies(), eclipseVersion); } } diff --git a/eclipse/build.gradle.kts b/eclipse/build.gradle.kts index d2ded4f90d..74008fa731 100644 --- a/eclipse/build.gradle.kts +++ b/eclipse/build.gradle.kts @@ -1,12 +1,18 @@ plugins { - id("saros.gradle.eclipse.plugin") + id("saros.gradle.eclipse.plugin") + id("com.diffplug.p2.asmaven") // Provides the class FeaturesAndBundlesPublisher } +import com.diffplug.gradle.p2.FeaturesAndBundlesPublisher +import com.diffplug.gradle.p2.CategoryPublisher +import com.diffplug.gradle.pde.EclipseRelease + val versionQualifier = ext.get("versionQualifier") as String +val eclipseVersionNr = ext.get("eclipseVersion") as String configurations { val testConfig by getting {} - val testImplementation by getting { + getByName("testImplementation") { extendsFrom(testConfig) } } @@ -18,6 +24,7 @@ sarosEclipse { isCreateBundleJar = true isAddDependencies = true pluginVersionQualifier = versionQualifier + eclipseVersion = eclipseVersionNr } sourceSets { @@ -74,4 +81,130 @@ tasks { from(rootProject.file("log4j2.xml")) from(rootProject.file("saros_log4j2.xml")) } + + /* Eclipse release tasks + * + * The following tasks provide the functionality of creating + * an eclipse update-site (via "updateSite") or dropin (via "dropin"). + * The creation of the update-site uses as recommended the eclipse's + * P2Directory. You can find a how-to here: + * http://maksim.sorokin.dk/it/2010/11/26/creating-a-p2-repository-from-features-and-plugins/ + * + * Instead of calling the P2Director via CLI we use the goomph + * plugin's classes that provide an abstraction layer of the P2Director. + */ + + val updateSiteDirPath = "build/update-site" + + /* Step 0 of update-site creation + * + * Creates the structure: + * update-site/ + * |- features/ + * |- feature.xml + * |- plugins/ + * |- saros.core.jar + * |- saros.eclipse.jar + * |- site.xml + */ + val updateSitePreparation by registering(Copy::class) { + dependsOn(":saros.core:jar", ":saros.eclipse:jar") + + into(updateSiteDirPath) + into("features") { + from("feature/feature.xml") + } + into("plugins") { + from(project.tasks.findByName("jar")) + from(project(":saros.core").tasks.findByName("jar")) + } + from("update/site.xml") + } + + /* Step 1 of update-site creation + * + * Creates the basic p2-Repository, but it is + * not usable as update-site, because the plugins + * are not visible to users. + * + * equivalent to P2Director call with: + * + * org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher \ + * -source /build/update-site \ + * -compress \ + * -inplace \ + * -append \ + * -publishArtifacts + * + */ + val updateSiteFeaturesAndBundlesPublishing by registering { + dependsOn(updateSitePreparation) + doLast { + with(FeaturesAndBundlesPublisher()) { + source(project.file(updateSiteDirPath)) + compress() + inplace() + append() + publishArtifacts() + runUsingBootstrapper() + } + } + } + + /* Step 2 of update-site creation + * + * Adds the meta-data to the repository to make + * the plugin accessible for users. + * + * equivalent to P2Director call with: + * + * org.eclipse.equinox.p2.publisher.CategoryPublisher \ + * -metadataRepository file:/build/update-site \ + * -categoryDefinition file:/build/update-site/site.xml + * + */ + val updateSiteCategoryPublishing by registering { + dependsOn(updateSiteFeaturesAndBundlesPublishing) + doLast { + with(CategoryPublisher(EclipseRelease.official(eclipseVersionNr))) { + metadataRepository(project.file(updateSiteDirPath)) + categoryDefinition(project.file("$updateSiteDirPath/site.xml")) + runUsingPdeInstallation() + } + } + } + + /* Step 3 of update-site creation + * + * The creation-process is already completed after + * step 2, but this task removes the meta-data which + * were necessary for update-site creation but are + * not part of the update-site. + */ + val updateSite by registering(Delete::class) { + dependsOn(updateSiteCategoryPublishing) + + delete("$updateSiteDirPath/features/feature.xml") + delete(fileTree("$updateSiteDirPath/plugins") { + // Remove all bundles without version (which is appended during update-site build) + exclude("*_*.jar") + }) + delete("$updateSiteDirPath/site.xml") + } + + /* Creates a dropin at build/dropin + * + * Creates an update-site, removes the superfluous meta-data + * and creates a zip. + */ + register("dropin", Zip::class) { + dependsOn(updateSite) + + archiveFileName.set("saros-eclipse-dropin.zip") + destinationDirectory.set(project.file("build/dropin")) + + from(updateSiteDirPath) { + exclude("*.jar") + } + } } diff --git a/stf.test/build.gradle.kts b/stf.test/build.gradle.kts index 1d79da9ce9..17e6e35a08 100644 --- a/stf.test/build.gradle.kts +++ b/stf.test/build.gradle.kts @@ -3,10 +3,13 @@ plugins { id("saros.gradle.eclipse.plugin") } +val eclipseVersionNr = ext.get("eclipseVersion") as String + sarosEclipse { manifest = file("META-INF/MANIFEST.MF") excludeManifestDependencies = listOf("org.junit", "saros.eclipse", "saros.core") isAddDependencies = true + eclipseVersion = eclipseVersionNr } configurations { diff --git a/stf/build.gradle.kts b/stf/build.gradle.kts index 38db9c1d1c..c5e04b44f5 100644 --- a/stf/build.gradle.kts +++ b/stf/build.gradle.kts @@ -3,6 +3,7 @@ plugins { } val versionQualifier = (ext.get("versionQualifier") ?: "") as String +val eclipseVersionNr = ext.get("eclipseVersion") as String val junitVersion = ext.get("junitVersion") sarosEclipse { @@ -11,6 +12,7 @@ sarosEclipse { isCreateBundleJar = true isAddDependencies = true pluginVersionQualifier = versionQualifier + eclipseVersion = eclipseVersionNr } configurations {