Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ buildSrc/.gradle
.DS_Store
/.gradle/
/build/
**/.settings/org.eclipse.buildship.core.prefs
.classpath

# Common
.project
Expand Down
6 changes: 6 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> excludeManifestDependencies = new ArrayList<>();
private boolean addDependencies = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
137 changes: 135 additions & 2 deletions eclipse/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
}
}
Expand All @@ -18,6 +24,7 @@ sarosEclipse {
isCreateBundleJar = true
isAddDependencies = true
pluginVersionQualifier = versionQualifier
eclipseVersion = eclipseVersionNr
}

sourceSets {
Expand Down Expand Up @@ -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:
* <code>
* org.eclipse.equinox.p2.publisher.FeaturesAndBundlesPublisher \
* -source <project dir>/build/update-site \
* -compress \
* -inplace \
* -append \
* -publishArtifacts
* </code>
*/
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:
* <code>
* org.eclipse.equinox.p2.publisher.CategoryPublisher \
* -metadataRepository file:<project dir>/build/update-site \
* -categoryDefinition file:<project dir>/build/update-site/site.xml
* </code>
*/
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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this exclude the jar files?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It excludes the content.jar and artifacts.jar as described here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have expected that the cleanup was already done in l.167 - l.176.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cleanup you mention removes all metadata that are not part of the update-site, but these metadata are part of the update-site, but not part of the dropin.

}
}
}
3 changes: 3 additions & 0 deletions stf.test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions stf/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -11,6 +12,7 @@ sarosEclipse {
isCreateBundleJar = true
isAddDependencies = true
pluginVersionQualifier = versionQualifier
eclipseVersion = eclipseVersionNr
}

configurations {
Expand Down