apply plugin:’FeaturePde’
buildscript {
repositories {
add(new org.apache.ivy.plugins.resolver.URLResolver()) {
name = ‘pdePluginRepo’
addArtifactPattern(‘https://github.com/breskeby/gradleplugins/raw/gradle-eplugin-build/pdePlugin/dists/[artifact]-[revision](-[classifier])(.[ext])’)
}
}
dependencies {
classpath ‘:pdePlugin:5.0′
}
}
subprojects {
repositories {
add(new org.apache.ivy.plugins.resolver.FileSystemResolver()) {
name = ‘repo’
addIvyPattern “$eclipseLocation/plugins/[organisation].[module]-ivy-[revision].xml”
addArtifactPattern “$eclipseLocation/plugins/[organisation].[module]_[revision](-[classifier]).[ext]“
descriptor = ‘optional’
checkmodified = true
}
}
group = ‘org.gradle’
apply plugin:’java’
plugins.withType(JavaPlugin).whenPluginAdded {
sourceCompatibility = 1.5
targetCompatibility = 1.5
}
version = this.version
}
if(!hasProperty(‘eclipseLocation’)){
throw (new InvalidUserDataException(“The property ‘eclipseLocation’ not set. Use -PeclipseLocation=/Path/to/eclipse”))
}
configure(FeaturePde){
def projectDir = getRootDir()
featureName = “org.gradle.eclipse.feature”
envConfigs = “*, *, *”
buildDirectory = file(“build/tmp/”)
publishDirectory = “${projectDir}/build/tmp/publish”
pluginsSrcDirList = ["${projectDir}/build/tmp/plugins"]
featuresSrcDir = “${projectDir}/build/tmp/features”
builderDir = “${projectDir}/build/tmp”
buildId = “graclipse”
baseLocation = eclipseLocation
eclipseLocation = “${baseLocation}”
eclipseLauncher = “${baseLocation}”
equinoxLauncher=”${baseLocation}/plugins/org.eclipse.equinox.launcher”
equinoxLauncherPluginVersion = “1.1.0.v20100507″
pdeBuildPluginVersion = “3.6.0.v20100603″
}
//util methods
String createBundleClasspath(FileTree zipContent){
def BUNDLE_LIB_SEPERATOR = “,\n “
StringBuffer buffer = new StringBuffer();
zipContent.visit {node ->
if(node.toString().endsWith(“jar”)){
def filepath = node.relativePath.pathString
def bundleClasspathEntry = filepath.substring(filepath.indexOf(‘/’) + 1)
buffer.append(bundleClasspathEntry).append(BUNDLE_LIB_SEPERATOR)
}
}
def bundleClasspath = buffer.toString()
//remove the last colone and linebreak
bundleClasspath.substring(0, bundleClasspath.length() – BUNDLE_LIB_SEPERATOR.length())
}
//
repositories {
// get the latest available gradle snapshot. Are files resolved via URLResolver are cacheable?
add(new org.apache.ivy.plugins.resolver.URLResolver()) {
name = ‘gradle-dists’
addArtifactPattern ‘http://dist.codehaus.org/([organization]/)[artifact](-[revision])(-[classifier]).[ext]‘
}
add(new org.apache.ivy.plugins.resolver.URLResolver()) {
name = ‘gradle-snapshots’
addArtifactPattern ‘http://snapshots.dist.codehaus.org/([organization]/)[artifact](-[revision])(-[classifier]).[ext]‘
}
}
configurations {
workspaceSetup // the configuration to build a complete pde environment workspace including a valid gradle dist
}
dependencies{
workspaceSetup “gradle:gradle:0.9-rc-1:bin@zip”
}
//tasks
task clean(type: Delete) {
delete(‘build’)
}
task copyFragments(dependsOn:’clean’) << {
copy {
from ‘plugins’
into ‘build/tmp/plugins/’
}
copy {
from ‘features’
into ‘build/tmp/features/’
}
}
task assemble(dependsOn:’pdeUpload’, type: Zip) {
baseName = “gradle-eclipse”
setDestinationDir(file(‘build/dists’))
from(‘build/tmp/publish’)
}
task mergeGradleDist(dependsOn:’copyFragments’) << {
String BUNDLE_CLASSPATH_PLACEHOLDER = “_BUNDLE_CLASSPATH_”
FileTree zipContent = null
configurations.workspaceSetup.files.each { depFile ->
zipContent = zipTree(depFile)
copy {
from(zipTree(depFile)) {
eachFile { details ->
details.path = details.path.substring(details.relativePath.segments[0].length())
}
}
into ‘build/tmp/plugins/org.codehaus.gradle/’
}
}
String bundleClasspath = createBundleClasspath(zipContent);
File manifestFile = file(‘build/tmp/plugins/org.codehaus.gradle/META-INF/MANIFEST.MF’)
def manifestContent = manifestFile.text
manifestContent = manifestContent.replaceAll(BUNDLE_CLASSPATH_PLACEHOLDER, bundleClasspath)
manifestFile.write(manifestContent)
}
pdeUpload.dependsOn mergeGradleDist