javagradlejarosgibnd

How to rename bundles generated with gradle workspace plugin


Alright i want to rename the bundles generated by my build to specify the version in its name, but everything i do seems to be ignored, and the bundle ends up with the projects folder name everytime.

build.gradle file

apply plugin: 'java'

repositories {
    mavenCentral()
}

dependencies {
    // https://mvnrepository.com/artifact/org.osgi/org.osgi.core
    compile group: 'org.osgi', name: 'org.osgi.core', version: '6.0.0'
}

task copyJar(type: Copy) {
    from('generated')
    include('*.jar')
    into("$rootDir/build/lib/bundles")
}

build.finalizedBy(copyJar)

gradle.properties

bundle_name=helloworld
bundle_version=5.1.2

from what i understand, the jar task uses the baseName and version properties, along with other properties to name the jar if nothing has been specified, so i tried in the build.gradle file but it doesnt work, i keep getting a jar file with the name of the projects folder

jar.baseName = "$bundle_name"
jar.version = "$bundle_version"

also im using the bnd workspace plugin, and i think its overriding the way the jar task works but im not sure

here's the parent project build.gradle

    //Applying the Gradle BND Plugin for Workspace Builds
    //https://github.com/bndtools/bnd/blob/master/biz.aQute.bnd.gradle/README.md
buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath "biz.aQute.bnd:biz.aQute.bnd.gradle:${bnd_version}"
    }
}
apply plugin: 'biz.aQute.bnd.workspace'
apply plugin: 'java'

    // Repositorios, aguante Maven Central.
/*
repositories {
    mavenCentral()
}
*/

clean {
    delete ("$rootDir/build/libs/bundles")
}

thank you for reading


Solution

  • If you are using the Bnd workspace plugin, then you must control Bnd via the project’s bnd.bnd file. See the -outputmask instruction to control the output name.