Should the cnf folder be part of a library?

Let me be more precise - it’s about GitHub - apache/freemarker: Apache Freemarker which we use and were I contributed some tiny things in the past related to OSGi (e.g. make the bnd.bnd file available), so that contributing with Eclipse is easier.

Now I think about suggesting to add a /cnf folder with /build.bnd so that the project can be imported in Eclipse as a ready-to-use bndtools workspace.
The idea behind is to make it easier to contribute for devs who are working with bndtools (like me).

Currently there is no /cnf folder. So When I contribtue I create an own bnd-workspace locally and import the project into this workspace.

Should the project have its own /cnf folder and build.bnd although the project’s build toolchain does not use bnd / bndtools?
Or is my current approach to create the workspace locally and import the project the better approach?

Edit: My question is in the context of this related question, but I wanted to ask it separatly.

I guess you want to build a maven project as a bndtools workspace project?

First, to use the -buildrepo you could just keep building it as maven. Although I am not a fan of it, you could import these additional projects in an Eclipse with a bnd workspace.

Converting the build from one to the other is virtually impossible in the full generic form. Builds can do so many weird things that imho it tends to end in an endless series of chasing someone else’s code. Never fully correct.

However, if you’re willing to be pragmatic it should be possible to import a simple, singular, and plain maven project and convert it to a bnd workspace project. It won’t be able to cover all subtleties of a complex maven project but with some help (like a bnd file) it could be useful. This code could reside in bndlib or the repositories project since it would be useful for other drivers. We do have the basic code to read the pom and figure out all the dependencies so I think this is doable.

Then the second phase is importing a bnd workspace in Eclipse without the .classpath & .project files.

This feature is something I longed for a long time. It would be great if we could ignore the .project and .classpath files in git. This would also handle a lot of tiny errors where people make mistakes in the content of these files and the bnd file. (I wish we had done this from the start.) The BndExplorer WorkspaceSynchronizer is thinking in this direction.

I think not really. Freemarker already has a (generated) bnd.bnd file.
They have an ant-task (ant clean jar ide-dependencies) which prepares the project for importing it into an IDE like Eclipse and it uses bnd to create the bnd.bnd file. (they are discussing moving to maven or gradle… but at the moment still ant).

I import this project into a fresh Bnd workspace locally


which compiles and produces a nice generated/org.freemarker.freemarker.jar

Via -buildrepo: MavenLocal I push it to a local Maven repo from which I consume it in another Eclipse instance via my repo (see my other topic). (Note: The other Eclipse instance is running our application which uses Freemarker. This setup makes it easy to test app-specific things while still being able to contribute to Freemarker e.g. for improvements we need for our app).

This workflow works fine for me.

BUT: I now realise a flaw in my initial question :exploding_head:

I was asking to put the cnf inside the the freemarker project. This is nonsense I realize now - since the bnd workspace lives “around” it, containing the cnf folder and the freemarker bundle / folder.

So I guess I asked the wrong question.

Maybe my question should have been:
How could somebody else replicate my workspace setup (consisting of cnf + org.freemarker.freemarker) from my screenshot above?

Is it manual (as I do it) and I can only send somebody a written recipe?
Or is there a way to put “something” in git, somebody checks it out, executes a command and has the same workspace as I have?

I don’t know if this somehow relates to your answer @pkriens

OMG, ant? :slight_smile: That is a blast from the past.

The problem is that the osgi.bnd file in the build is for the bnd command line. Instead of using the -buildpath, it uses the classpath and only references the already compiled classes? Hmm, it even refers to bnd 1.50.0!

I also fail to see how the dependencies are handled? In the ant script I can see Ivy is used to copy all dependencies to the ide-dependencies but the osgi.bnd file is not referencing this dir?

Some free thinking …

The ideal situation seems to be to import the freemarker project as a git module in your workspace so it is a normal bnd project. Your dependencies are in ide-dependencies, so you would need a bnd.bnd like:

src:                    src/main/java, src/main/misc/identifierChars/src/main, src/gen/java
bin:                    target/classes
testsrc:                src/test/java
testbin:                target/test-classes
target-dir:             target

-generate: \
    src/main/javacc/FTL.jj; \
        output      = src/gen/java/; \
        generate    = '.javacc -OUTPUT_DIRECTORY=src/gen/java/freemarker/core src/main/javacc/FTL.jj'; \
        classpath   = ';version=7.0.12'
-buildpath ${replace;${lsa;ide-dependencies};.*;$0\\;version=file}

Bundle-SymbolicName: org.freemarker.freemarker
Bundle-Version: 2.3.33.nightly_20231108T095629Z
Bundle-License: Apache License, Version 2.0; see:

This requires you to run the ant ide-dependencies to create the ide-dependencies directory with all the dependencies.

I tested it. There are some issues to be resolved but it actually mostly compiles. I think most of the issues are actual issues …

See GitHub - pkriens/freemarker

Oh wow I didn’t expect so much. Thank you @pkriens .

Yes setting up Eclipse for freemarker requires currently some tweaks ("Build Path" -> "Exclude"): _Jython20*.java, _Jython22*.java etc.) so that it compiles. They have it described here.

I see.
Hmm I realize I have no clue why it works :wink:

Maybe it is a hybrid of Eclipse-Java Builder and BndBuilder.

Here is my guess:

  • Eclipse compiles into /build/classes
  • BndBuilder uses bnd.bnd (which is a result of the ide-dependencies task ) and uses the compiled classes in /build/classes into generated/org.freemarker.freemarker.jar
  • my own /cnf/build.bnd contains the -buildRepo: MavenLocal which publishes generated/org.freemarker.freemarker.jar to my local Maven repo

I think this might be the reason why it works for me™ :exploding_head:

Ok, I think this is what I am currently partly doing (I have my workspace and freemarker goes into it) … just without git module.

This seems to answer also my question. Workspace is my part and importing the external lib too.

I’m not sure how to interpret your bnd.bnd:
Is your bnd.bnd basically to build Freemarker with plain bnd? (instead of …ehm ant? and also instead of my why-the-hell-is-it-working way from above?)

If yes, then your bnd.bnd version could be a replacement for the current osgi.bnd (which gets copied into bnd.bnd by the ant-script?

I think somehow your .classpath file must contain the files in ide-dependencies? The >Referenced Libraries should show them.

Can you share this workspace on Github? Then I can take a look.

The (unfinished) work I proposed would properly build in a workspace. By using the ide-dependencies you could use it in bnd workspace basically.

Oh yes that is the case. It was part of the manual setup process described here (GitHub - apache/freemarker: Apache Freemarker).

I am back middle of next week. I see what I can do.

With the ${lsa} macro you can automate the -buildpath, as shown. Even the source generation seems to work with the -generate function! (Ok, I had to extend it a bit because the javacc has no Main-Class :frowning: ).

There seems some hacking going on in the ant that might be problematic but imho it is always better to try to do things without hacks. A lot of things have happened since ant was popular.

I think we can make this work in any workspace without too much effort. With a bit of effort, we could make it really nice.

Enjoy your time away