[Plugin-Dev] ${user;KEY} macro

20 views
Skip to first unread message

Frank Rosenberger

unread,
Nov 9, 2017, 9:48:42 AM11/9/17
to bndtool...@googlegroups.com
I am currently developing a bnd plugin which will need authentication data (user, password) to function as intended. Of course this confidential information should not end up in a shared .bnd file.
I found the ${user;KEY} macro in the bnd Macro Reference. Its description states:
 
A current user setting from the ~/.bnd/settings.json file

I created such a settings file.

{
   
"authUserName": "user",
   
"authPassword": "pass",
   
"useAuth": true
}

I then registered my plugin as such:

-plugin.custom: \
    com
.example.bnd.CustomPlugin;\
        path
:=${cnf}/plugins/com.example.bnd-1.0.0.jar;\
        auth
='${user;useAuth}';\
        user
='${user;authUserName}';\
       
pass='${user;authPassword}'

After building the workspace I get the following warnings:

No translation found for macro: user;authPassword    build.bnd    /cnf    line 1    Bndtools Workspace Problem Marker
No translation found for macro: user;authUserName    build.bnd    /cnf    line 1    Bndtools Workspace Problem Marker
No translation found for macro: user;useAuth    build.bnd    /cnf    line 1    Bndtools Workspace Problem Marker

As expected with those warnings the properties did not get fetched from the settings.json, but were instead passed on to my plugin unresolved.
Did I use the macro wrong? If so, what would be the correct syntax?

Peter Kriens

unread,
Nov 9, 2017, 10:15:15 AM11/9/17
to bndtool...@googlegroups.com
The bnd settings file is more complex. The format is 

{
“id” : <unique UUID>,
“map” : { <key>=<value>, <key>=<value> … }
}

You can control this file with the bnd commandline (in brew nowadays)

NAME
  settings                    - Set bnd/jpm global variables. The key can be
                                wildcard.

SYNOPSIS
   settings [options] <<key>[=<value>]...>

OPTIONS

   [ -b, --base64 ]           - Show key in base64
   [ -c, --clear ]            - Clear all the settings, including the public and
                                private key
   [ -g, --generate ]         - Generate a new private/public key pair
   [ -l, --location <string> ] - Override the default "~/.bnd/settings.json"
                                location
   [ -m, --mac ]              - Sign the strings on the commandline
   [ -p, --password <[c> ]    - Password for local file
   [ -P, --publicKey ]        - Show the public key
   [ -s, --secretKey ]        - Show the private secret key

For example

bnd settings useAuth=true

Note that we also support the maven settings. In your plugin you can get an HttpClient that is automatically setup with information in either ~/.bnd/settings.xml or ~/.m2/settings.xml

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.

Frank Rosenberger

unread,
Nov 9, 2017, 10:45:51 AM11/9/17
to bndtools-users
Thank you Peter, I can now construct a valid settings.json file.

Sadly the initial problem remains unsolved. I still get the warning that the user macro can not be translated.

Peter Kriens

unread,
Nov 9, 2017, 11:38:38 AM11/9/17
to bndtool...@googlegroups.com
Weird, it does work for me, I just tested it again.

If you do on the command ‘bnd settings’ you see the settings?

If you enter in a bnd file:

Bla = ${warning;${user;useAuth}}

You should get a warning and see the actual value. It is possible that Eclipse does not pick it up so try a restart.

Kind regards,

Peter Kriens

Frank Rosenberger

unread,
Nov 10, 2017, 3:05:02 AM11/10/17
to bndtools-users
I let it rest over night. I did an Eclipse restart. I checked the settings on the bnd command line. I did the ${warning}.

And lo and behold, it works now! ;)

Thank you for your assistance Peter.

Regards
Frank
Reply all
Reply to author
Forward
0 new messages