Custom exporters (or just custom Gradle builds)

45 views
Skip to first unread message

Dan Gravell

unread,
Nov 1, 2016, 8:40:17 AM11/1/16
to bndtools-users
I see mention of custom exporters - did this work get completed?

I need to package an application with the folders:

bin/
bundle/
more-bundles/
conf/
licence-stuff

There are a few reasons I need this, and can't use the JAR approach:

- I want scripts and exes to run my app
- Existing integrations exist which assume the above layout

I don't really like the idea of extracting the JAR and moving files about - the internals of the JAR feel like an implementation detail to me.

Are there any examples of "custom exporters" or just custom Gradle builds that do this? I'm really inexperienced with Gradle so part looking for a template project I can adapt and learn as I go. I'm moving from Ant.

Dan

Peter Kriens

unread,
Nov 1, 2016, 8:43:17 AM11/1/16
to bndtool...@googlegroups.com
The package function is part of the launcher. If you write/copy the launcher then you can build your own exporter. The launcher is picked up form the -runpath so you can put your custom launcher in a repo.

Kind regards,

Peter Kriens

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Dan Gravell

unread,
Nov 1, 2016, 11:23:01 AM11/1/16
to bndtools-users
So that means writing it in Java? I was kind of hoping to write the build in Groovy using Gradle.


TBH all I really need, I think, is to know the path to my third party dependencies. Looks like it is possible to get those as Container objects from the project in the workspace?

Dan

Peter Kriens

unread,
Nov 1, 2016, 11:29:00 AM11/1/16
to bndtool...@googlegroups.com

Don’t underestimate launchers though … 

Kind regards,

Peter Kriens

Raymond Auge

unread,
Nov 1, 2016, 12:04:31 PM11/1/16
to bndtool...@googlegroups.com
Dan, couldn't the bnd gradle plugin task called runbundles be enough?

basically, this dumps all the runbundles into a directory inside the build directory.

From there you could do whatever you want with them.

- Ray

To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "bndtools-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Raymond Augé (@rotty3000)
Senior Software Architect Liferay, Inc. (@Liferay)
Board Member & EEG Co-Chair, OSGi Alliance (@OSGiAlliance)

Dan Gravell

unread,
Nov 1, 2016, 1:10:13 PM11/1/16
to bndtools-users
That looks exactly what I need, thanks Ray! I'm embarrassed I didn't see this first time, I was following: https://github.com/bndtools/bnd/blob/master/biz.aQute.bnd.gradle/README.md#gradle-plugin-for-workspace-builds

I guess I might have just seen "run..." and thought it was for running a bndrun file.

Dan
To unsubscribe from this group and stop receiving emails from it, send an email to bndtools-user...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Dan Gravell

unread,
Nov 1, 2016, 1:42:53 PM11/1/16
to bndtools-users
Is there a constant or property I can use to return the prefix "generated/distributions/runbundles/" for the location of the generated runbundles?

Guess I could just hard code it...

BJ Hargrave

unread,
Nov 1, 2016, 2:15:16 PM11/1/16
to bndtool...@googlegroups.com
--
BJ

Dan Gravell

unread,
Nov 2, 2016, 7:32:37 AM11/2/16
to bndtools-users
Thanks!

Dan Gravell

unread,
Dec 16, 2016, 7:06:25 AM12/16/16
to bndtools-users
Just getting around to this!

If I try to access that directory directly:

task linuxRelease(dependsOn:':com.elsten.bliss.build.bnd:runbundles.product') {
doLast {
println(runbundles.product.outputs.dir)
}
}

(product is the bndrun name) I get:

> Could not find property 'product' on task ':com.elsten.bliss.build.bnd:runbundles'.

I guess this is because the runbundles task for the particular bndrun file is generated? If I do:

tasks['runbundles.product'].outputs.dir

Then I think a generic task object is returned and I can't call dir on it.

Maybe my approach of depending on runbundles is incorrect?

Dan

On Tuesday, November 1, 2016 at 6:15:16 PM UTC, BJ Hargrave wrote:

BJ Hargrave

unread,
Dec 16, 2016, 7:41:15 AM12/16/16
to bndtool...@googlegroups.com
':com.elsten.bliss.build.bnd:runbundles.product' does not exists as a task directly since it is generated on demand by a taskRule:
https://github.com/bndtools/bnd/blob/master/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndPlugin.groovy#L405-L406

To depend upon it, you need to trigger the rule using tasks.getByPath. See https://github.com/bndtools/bnd/blob/master/biz.aQute.bnd.gradle/src/aQute/bnd/gradle/BndPlugin.groovy#L440 for an example.

So you would need to do:
task linuxRelease(dependsOn:tasks.getByPath(':com.elsten.bliss.build.bnd:runbundles.product'))
BJ

Dan Gravell

unread,
Dec 16, 2016, 7:45:15 AM12/16/16
to bndtools-users
The runbundles.project task is being executed ok with my current code. It's the call to .outputs.dir that is failing...

I tried it your way, I still get the same thing:

> Could not find property 'product' on task ':com.elsten.bliss.build.bnd:runbundles'.

I also thought it was a bit weird I have to qualify the task by the project name - the project name is the same one the build script is in. I saw it done this way in build/build.gradle (bndtools source).

Dan

BJ Hargrave

unread,
Dec 16, 2016, 7:52:00 AM12/16/16
to bndtool...@googlegroups.com
Well your println is wrong.


task linuxRelease(dependsOn:':com.elsten.bliss.build.bnd:runbundles.product') {
doLast {
println(runbundles.product.outputs.dir)
}
}

It finds the task runbundles, which exists and then looks for a product property.

Try println(tasks.getByPath(':com.elsten.bliss.build.bnd:runbundles.product').outputs.dir)

Dan Gravell

unread,
Dec 16, 2016, 7:58:10 AM12/16/16
to bndtools-users
Same as when I accessed it via tasks:

> No such property: dir for class: org.gradle.api.internal.tasks.DefaultTaskOutputs

Does the tasks or getByPath lookup return a generic task, does it need some way of casting so we can get the specific properties of outputs?

BJ Hargrave

unread,
Dec 16, 2016, 3:31:20 PM12/16/16
to bndtool...@googlegroups.com

BJ Hargrave

unread,
Dec 18, 2016, 11:46:30 AM12/18/16
to bndtool...@googlegroups.com
I just released https://github.com/bndtools/bnd/pull/1824 which adds a destinationDir property to the export.* and runbundles.* tasks. This will allow you to set and get the destination directory for these tasks.
--
BJ
Reply all
Reply to author
Forward
0 new messages