I am not sure how do you actually manage p2 repositories on bintray? everything that you upload normally must be associated to a version and package, but we need a way to have some files repository scoped like metadata of a compose repository or whatever. I know that question has been answerred already in some form, but I need more info, especially what are the rules of uploading repository scoped things, what paths can they have like must the uploaded files reside at a repository root or not, and such things. I don't quite understand why this is not documented on bintray officially.
1 Answers
Bintray organizes artifacts under repositories > packages > versions.
The relations are: [repository] 1---* [package] 1---* [version] 1---* [artifact]
.
There is one exception for that - metadata files. The main reason is that metadata files usually include several versions, so they can't be associated to a specific version. Another difference is that versioned artifacts cannot be overwritten 180 days after they were published, whereas metadata files are expected to change every time a version is released. This is why metadata files are basically called "repository scoped". Just note that Bintray identifies metadata files by their names - i.e. the user cannot tell Bintray which artifact is a metadata file. Except for that, metadata files can be uploaded to any path, same as any other artifact.
For example, in P2 the following file names are considered are metadata files (I might have missed some):
artifacts.xml/.jar/.xml.xz
, content.xml/.jar/.xml.xz
, compositeArtifacts.xml/.jar
, compositeContent.xml/.jar
, p2.index
.
So anytime you upload a file named (e.g.) artifacts.jar
to a generic or maven repository in Bintray, it is handled as a metadata file.
Another point to note, continuing the explanation above - when you upload a versioned artifact you must specify the package and version it shall be associated to. Whereas when you upload a metadata file (and again - Bintray identifies it by its name), Bintray does not expect package and version.
Bintray has several options to specify the package and version in the upload REST API:
- In the URL path:
PUT /content/:subject/:repo/:package/:version/:file_path
(note the:package/:version
parameters in the URL) - In the headers:
X-Bintray-Package: :package
X-Bintray-Version: :version
PUT /content/:subject/:repo/:file_path
(note there are no:package/:version
parameters in the URL) - As matrix parameters in the URL:
PUT /content/:subject/:repo/:file_path;bt_package=:package;bt_version=:version
For metadata files, in the second & third options Bintray ignores the package and version. In the first option Bintray handles the package and version as part of the path, so the result path in bintray includes them (not what you probably intended...)
Conclusion:
To make long story short - the best way to upload artifact to a P2 repository in Bintray is using wither the 2nd or 3rd upload option. This way - if it is a versioned file it has the package and version it shall be associated to. If it is a metadata file, the package and version are ignored and the files are uploaded to the correct target path.
For example, using cURL
:
curl -u$BT_USER:$BT_PASS -XPUT -T <file-to-upload> "https://api.bintray.com/content/$BT_OWNER/$BT_REPO/$FILEPATH" -H "X-Bintray-Package: $BT_PKG" -H "X-Bintray-Version: $BT_VER"
Here is a very good blog post: Publish an Eclipse P2 Composite Repository on Bintray
HTH,
Yinon

- 1,418
- 11
- 14
-
well but versioned files are by default put in a version subfolder right? so if I just upload everything, then metadata files won't land in that versioned folder, thus probably breaking everything? – Michał Zegan Aug 21 '17 at 13:15
-
For Bintray there is is no default path. Any file can be put under any path, the only real requirement is no path conflicts. You specify the target path when you upload the file (`$FILEPATH` in my `curl` example). If you use any package manager, e.g. maven, then it has its own structure requirements and you should follow it (otherwise it won't be able to resolve your dependencies...). – yinon Aug 21 '17 at 13:21
-
well my tests showed that if I uploaded something at least with the ui to a version, with the empty path or even /, it landed in the version/ folder unless you changed the path – Michał Zegan Aug 21 '17 at 13:35
-
First - you should automate your process and use the REST API, not the UI. Regarding the behavior of the UI - which repository type are you using? I did a quick test uploading a simple file to a generic repo with an empty target path and it was uploaded to the root (as expected). – yinon Aug 21 '17 at 13:42
-
I have to test again then. yes, automation, but I was testing mostly, how things behave etc. I will maybe test some time later again – Michał Zegan Aug 21 '17 at 13:53