# Supporting the 'class' modifier in the Workspace Projects

**URL:** <https://bnd.discourse.group/t/supporting-the-class-modifier-in-the-workspace-projects/312>\
**Category:** GENERAL\
**Created:** [June 6, 2023, 8:38am UTC](https://bnd.discourse.group/t/supporting-the-class-modifier-in-the-workspace-projects/312 "2023-06-06T08:38:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkriens](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/pkriens/32/3_2.png) [@pkriens](https://bnd.discourse.group/u/pkriens)\
**Post date:** [June 6, 2023, 8:38am UTC](https://bnd.discourse.group/t/supporting-the-class-modifier-in-the-workspace-projects/312/1 "2023-06-06T08:38:50Z")

</div>

If you’re using the bnd Workspace model, releasing to a Maven Repository becomes remarkably simple. You can even release multiple JARs from a single project using sub bundles. However, one missing feature was the ability to include auxiliary files.

Maven follows a specific naming convention when releasing artifacts to a directory. Each artifact’s name is constructed using the `GAV` (Group:Artifact:Version) format. For instance, the GAV for `bndlib` is `biz.aQute.bnd:biz.aQute.bndlib:7.0.0`. This GAV is then mapped to a file path, with the group expanded into a hierarchy based on dots. The metadata, represented by the POM file, is located at:

```
  ${group.replace('.','/')}/${artifact}/${version}/${artifact}-${version}.pom

```

Occasionally, there is a need to release additional files, such as project sources or javadoc. This is accomplished using a classifier. For instance, you can typically find the sources in a path like:

```
  ${group.replace('.','/')}/${artifact}/${version}/${artifact}-${version}-${classifier}.pom

```

However, until recently, bnd projects were unable to create their own class files. Fortunately, this limitation has now been addressed!

```auto
-maven-release \
       extra;\
        path=files/feature.json;
        class=feature

```

You can now take any file from a project that releases to Maven and add it as a class file to the release. The [`-maven-release`](https://bnd.bndtools.org/instructions/maven-release.html) instruction already supported parameters for source and javadoc generation but you can now add one or more `extra` keys in the parameters. The `extra` takes a path to a file and a class. If no class is specified, it will make a dummy class.

Very easy and sometimes a life saver. Enjoy

---

<div class="post-metadata">

**Author:** ![laeubi](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/laeubi/32/131_2.png) [@laeubi](https://bnd.discourse.group/u/laeubi)\
**Post date:** [June 12, 2023, 6:51am UTC](https://bnd.discourse.group/t/supporting-the-class-modifier-in-the-workspace-projects/312/2 "2023-06-12T06:51:30Z")

</div>

I just wanted to note that it might be better to use `classifier` instead of `class` as this can be confused with java-class files and makes it hard to read:

> **[Code is read much more often than it is written, so plan accordingly - The...](https://devblogs.microsoft.com/oldnewthing/20070406-00/?p=27343)**
>
> Design for readability. Even if you don’t intend anybody else to read your code, there’s still a very good chance that somebody will have to stare at your code and figure out what it does: That person is probably going to be you,

Also `extra` might be a obvious choice from a technical point of view, from maven terminology `artifact` is a much more better term (as maven reference such things as attached artifact of a project):  
[https://www.mojohaus.org/build-helper-maven-plugin/attach-artifact-mojo.html](https://www.mojohaus.org/build-helper-maven-plugin/attach-artifact-mojo.html)

---

<div class="post-metadata">

**Author:** ![pkriens](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/pkriens/32/3_2.png) [@pkriens](https://bnd.discourse.group/u/pkriens)\
**Post date:** [June 12, 2023, 7:53am UTC](https://bnd.discourse.group/t/supporting-the-class-modifier-in-the-workspace-projects/312/3 "2023-06-12T07:53:07Z")

</div>

The problem is that maven terminology is for artifact is overloaded and often ambiguous in many contexts. I.e. the _artifact id_ is actually the id of the abstract thing that is released over time, it is only a part of the id of an _archive_ (the actual file). That is why I created a set of classes in bnd modeling an unambiguous naming for the maven entities:

- Archive (Revision,classifier,packaging)
- Revision (Program, Version)
- Program (groupid,artifactid)

However, for this new function, I mistakenly thought I’d use ‘class’ in the Archive class but we used `classifier` there as well so it is more consistent. So that was a good catch. And since instead of `extra` the use of `archive` would be more consistent so I changed that as well.

Thanks.

---

<div class="post-metadata">

**Author:** ![laeubi](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/laeubi/32/131_2.png) [@laeubi](https://bnd.discourse.group/u/laeubi)\
**Post date:** [June 12, 2023, 11:06am UTC](https://bnd.discourse.group/t/supporting-the-class-modifier-in-the-workspace-projects/312/4 "2023-06-12T11:06:02Z")

</div>

An artifact do not need to be an archive, it can be anything(especially in your example it is a textfile formatted as json …

An artifact has an id, a group a version (and type) and a classifier (that can be empty) and if it is resolved it has a file.

---

<div class="post-metadata">

**Author:** ![pkriens](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/pkriens/32/3_2.png) [@pkriens](https://bnd.discourse.group/u/pkriens)\
**Post date:** [June 12, 2023, 1:15pm UTC](https://bnd.discourse.group/t/supporting-the-class-modifier-in-the-workspace-projects/312/5 "2023-06-12T13:15:45Z")

</div>

> An artifact has an id, a group a version (and type) and a classifier (that can be empty) and if it is resolved it has a file

See how you have to woozle because the id of your artifact is **not** the `artifact id`? 🙂

I think I once had a discussion about this with Jason van Zijl and I recall he agreed that the name `artifact id` was a bit unfortunate. But it is in the mist of time. Anyway, spent enough time on this topic.
