I'm working on an OSGi bundle using bndtools in Eclipse. I just added a new bundle (apache commons logging) to the cnf/localrepo
repository, and our CI server is now failing the build:
[Gradle] - Launching build.
[workspace] $ gradle build
:mybundle : Cannot find /error/com.springsource.org.apache.commons.logging;version=0 Not found in [bnd-cache, Release, Local, Bndtools Hub, /var/lib/jenkins/jobs/myapp/workspace/cnf/nonosgi-repo r/w=true]
Error : com.springsource.org.apache.commons.logging;version=0 Not found in [bnd-cache, Release, Local, Bndtools Hub, /var/lib/jenkins/jobs/myapp/workspace/cnf/nonosgi-repo r/w=true]
Project names lightly obfuscated just for simplicity.
It appears to me that the gradle plugin doesn't refresh the repository index - if one of my teammates updates from our vcs without refreshing in Eclipse, then they get the same error.
I know bndtools has the org.osgi.impl.bundle.repoindex.cli plugin, but I don't know enough about bndtools or gradle to apply it to my project. I also feel as though either (a) the gradle plugin should refresh the repositories on its own or (b) I'm using the repositories incorrectly.
Is it possible to add a task to our build.gradle that refreshes the indexes before a build?
Should we instead move all our dependencies to an online repository so bnd doesn't need to manage the indexes?
Should we instead move all our dependencies to an online repository so bnd doesn't need to manage the indexes?
Probably, but for various reasons it's easier in the short-term to continue to use our LocalIndexedRepository
.
Is it possible to add a task to our build.gradle that refreshes the indexes before a build?
bndtools' Bundle-Hub repository uses the org.osgi.impl.bundle.repoindex.cli plugin to reindex the repository in its build.gradle. Since I'm not fluent in groovy or gradle, I simply copied its code into cnf/localrepo/build.gradle:
repositories {
mavenCentral()
}
configurations {
repoindex
}
dependencies {
repoindex group: 'biz.aQute.bnd', name: 'org.osgi.impl.bundle.repoindex.cli', version: '3.0.0'
}
defaultTasks = [':index']
task('index') {
/* Bundles to index. */
def bundles = fileTree(projectDir) {
include '**/*.jar'
exclude '**/*-latest.jar'
exclude '.*/'
}
doLast {
javaexec {
main = '-jar' // first arg must be the jar
args configurations.repoindex.singleFile
args '-n', 'Local' // REPO NAME HERE
args bundles*.absolutePath
}.assertNormalExitValue()
}
}
Thanks to BJ Hargrave for pointing me in the direction of Bundle-Hub's scripts.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments