diff --git a/build/bnd.bnd b/build/bnd.bnd index 1aafb2175..1562b74dd 100644 --- a/build/bnd.bnd +++ b/build/bnd.bnd @@ -1,9 +1,6 @@ # Set javac settings from JDT prefs -include: ${workspace}/cnf/eclipse/jdt.bnd - --sub: *.bnd - --releaserepo: +-nobundles: true gittag: ${first;${system-allow-fail;git describe --abbrev=0},${base.version}.DEV} @@ -24,6 +21,13 @@ p2 = bndtools.api, \ org.bndtools.templating,\ org.bndtools.templating.gitrepo +plugins: \ + ${map;repo;${replace;${p2};$;\\\\\\;latest}},\ + ${repo;biz.aQute.bndlib;latest},\ + ${repo;biz.aQute.repository;latest},\ + ${repo;biz.aQute.resolve;latest},\ + ${repo;org.slf4j.api;latest} + # Template projects which are not part of the p2 feature templates = \ org.bndtools.templates.osgi, \ diff --git a/build/build.gradle b/build/build.gradle index 774b9ba3a..532563bd6 100644 --- a/build/build.gradle +++ b/build/build.gradle @@ -3,6 +3,8 @@ */ import aQute.bnd.gradle.Index +import aQute.bnd.osgi.Jar +import org.apache.tools.ant.filters.ReplaceTokens def buildProject = project @@ -21,165 +23,112 @@ configure(parent) { defaultTasks = [build.path] } -import org.apache.tools.ant.filters.ReplaceTokens -import aQute.bnd.osgi.Jar - -/* - * Setup tasks (p2 plugins) - */ -task p2Plugins(type: Copy) { - dependsOn releaseNeeded - from zipTree("${buildDir}/${project.name}.main.jar") +task p2Plugins(type: Sync) { + dependsOn build + from bnd('plugins').tokenize(',') into "${buildDir}/plugins" - include '*.jar' - - doLast { - String[] projs = bnd('p2', '').split(/\s*,\s*/) - def targetDir = file("${buildDir}/plugins") - if ((!targetDir.exists() && !targetDir.mkdirs()) || !targetDir.isDirectory()) { - throw new GradleException("Could not create directory ${targetDir}") - } - projs.each { - def proj = parent.findProject(it) - if (proj == null) { - throw new GradleException("Could not find project ${it}") - } - - proj.bnd.project.getBuilder(null).withCloseable { pb -> - pb.getSubBuilders()*.getBsn().each { bsn -> - copy { - from project.relativePath(proj.bnd.project.getOutputFile(bsn)) - into targetDir - } - } - } - } - } } -/* - * Setup tasks (p2 features) - */ -task p2FeatureTree(type: Copy) { - dependsOn p2Plugins - from 'feature' - into "${buildDir}/features" - doFirst { - def masterVersion = String.format('%s-%tY% - featureTokens["${jar.getBsn()}-version"] = jar.getVersion() - } +task p2FeatureProperties(type: WriteProperties) { + inputs.files p2Plugins + outputFile = file("${buildDir}/feature.properties") + doFirst { + property('master-version', String.format('%s-%tY% + property("${jar.getBsn()}-version", jar.getVersion()) } - filter(ReplaceTokens, tokens: featureTokens ) } - include 'category.xml' - include '**/feature.xml' - inputs.files file("${buildDir}/plugins") + } } task p2FeatureMain(type: Zip) { - dependsOn p2FeatureTree + inputs.files p2FeatureProperties destinationDir = file("${buildDir}/features") archiveName = 'bndtools.feature.jar' - from "${buildDir}/features/bndtools" + from 'feature/bndtools' include 'feature.xml' + doFirst { + Properties properties = new Properties() + p2FeatureProperties.outputFile.withInputStream { + properties.load(it) + } + filter(ReplaceTokens, tokens: properties ) + } } task p2FeatureM2e(type: Zip) { - dependsOn p2FeatureTree + inputs.files p2FeatureProperties destinationDir = file("${buildDir}/features") archiveName = 'bndtools.m2e.feature.jar' - from "${buildDir}/features/bndtools-m2e" + from 'feature/bndtools-m2e' include 'feature.xml' + doFirst { + Properties properties = new Properties() + p2FeatureProperties.outputFile.withInputStream { + properties.load(it) + } + filter(ReplaceTokens, tokens: properties ) + } } task p2FeaturePde(type: Zip) { - dependsOn p2FeatureTree + inputs.files p2FeatureProperties destinationDir = file("${buildDir}/features") archiveName = 'bndtools.pde.feature.jar' - from "${buildDir}/features/bndtools-pde" + from 'feature/bndtools-pde' include 'feature.xml' + doFirst { + Properties properties = new Properties() + p2FeatureProperties.outputFile.withInputStream { + properties.load(it) + } + filter(ReplaceTokens, tokens: properties ) + } } -/* - * Setup tasks (p2 repositories) - */ task p2 { - description 'Generate the p2 repositories.' + description 'Publish the p2 repositories.' group 'release' - dependsOn p2Plugins, p2FeatureMain, p2FeatureM2e, p2FeaturePde - - inputs.files file('p2.xml'), - fileTree(buildDir) - .include('p2/**') - .include('features/category.xml') - outputs.dir "${buildDir}/p2" - + inputs.files p2Plugins, p2FeatureMain, p2FeatureM2e, p2FeaturePde, 'p2.xml', 'feature/category.xml' + ext.destinationDir = file("${buildDir}/p2") + outputs.dir destinationDir doLast { - def bnd_verbose = logger.isEnabled(LogLevel.INFO) - def bnd_eclipseDirectory = file('eclipse-3.5.2') - def bnd_eclipseJar = new File(bnd_eclipseDirectory, 'plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar') - def javaArgs = [] - if (bnd_verbose) { - javaArgs += '-consoleLog' - } - javaArgs += '-application' - javaArgs += 'org.eclipse.ant.core.antRunner' - javaArgs += '-data' - javaArgs += buildDir - javaArgs += '-buildfile' - javaArgs += 'p2.xml' - javaArgs += 'p2Bndtools' - - def result = javaexec { - classpath = files(bnd_eclipseJar) - main = 'org.eclipse.equinox.launcher.Main' - args = javaArgs - } - if (result.exitValue != 0) { - throw new GradleException("Could not publish features and bundles -Bndtools") - } - - javaArgs = [] - if (bnd_verbose) { - javaArgs += '-consoleLog' - } - javaArgs += '-application' - javaArgs += 'org.eclipse.equinox.p2.publisher.CategoryPublisher' - javaArgs += '-data' - javaArgs += buildDir - javaArgs += '-metadataRepository' - javaArgs += "file://${buildDir}/p2" - javaArgs += '-categoryDefinition' - javaArgs += "file://${buildDir}/features/category.xml" - javaArgs += '-compress' - - result = javaexec { - classpath = files(bnd_eclipseJar) - main = 'org.eclipse.equinox.launcher.Main' - args = javaArgs - } - if (result.exitValue != 0) { - throw new GradleException("Could not categorise repository - Bndtools") - } - - /* Clean up the files Eclipse leaves behind */ - fileTree(bnd_eclipseDirectory).include('configuration/*.log').each { - it.delete() - } - - delete(file("${bnd_eclipseDirectory}/configuration/org.eclipse.core.runtime")) - delete(file("${bnd_eclipseDirectory}/configuration/org.eclipse.equinox.app" )) - delete(file("${bnd_eclipseDirectory}/configuration/org.eclipse.osgi" )) - delete(file("${bnd_eclipseDirectory}/p2" )) - delete("${buildDir}/features") - delete("${buildDir}/plugins") + javaexec { + classpath 'eclipse-3.5.2/plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar' + main = 'org.eclipse.equinox.launcher.Main' + if (logger.isDebugEnabled()) { + args '-consoleLog' + } + args '-application' + args 'org.eclipse.ant.core.antRunner' + args '-data' + args buildDir + args '-buildfile' + args 'p2.xml' + args 'p2Bndtools' + }.assertNormalExitValue() + + javaexec { + classpath 'eclipse-3.5.2/plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar' + main = 'org.eclipse.equinox.launcher.Main' + if (logger.isDebugEnabled()) { + args '-consoleLog' + } + args '-application' + args 'org.eclipse.equinox.p2.publisher.CategoryPublisher' + args '-data' + args buildDir + args '-metadataRepository' + args uri(destinationDir) + args '-categoryDefinition' + args uri('feature/category.xml') + args '-compress' + }.assertNormalExitValue() } } @@ -195,14 +144,11 @@ task('index', type: Index) { } } -/* - * Setup tasks (distribution) - */ task dist(type: Zip) { description 'Create distribution archives containing p2 repository (including R5 index).' group 'release' - dependsOn index - destinationDir = file(buildDir) + inputs.files p2, index + destinationDir = buildDir archiveName = 'bndtools-latest.zip' from "${buildDir}/p2" include '**' diff --git a/build/main.bnd b/build/main.bnd deleted file mode 100644 index ecb3eea7b..000000000 --- a/build/main.bnd +++ /dev/null @@ -1,7 +0,0 @@ -# Only extra bundles that are needed for the feature are mentioned here --resourceonly: true --includeresource: \ - ${repo;biz.aQute.bndlib;latest},\ - ${repo;biz.aQute.repository;latest},\ - ${repo;biz.aQute.resolve;latest},\ - ${repo;org.slf4j.api;latest}