In the default setup of the workspace, the gradle build tool & eclipse share the same output directories. In general, this means you always have to clean in each tool and in the case of Eclipse stop the incremental builder.
All the output directories are defined in macros. In general, the ${target-dir} is the main output directory and the ${bin} and ${testbin} are placed inside this directory. So by redefining ${target-dir} in cnf/build/bnd we can redirect all output.
bnd has a macro ${driver} that indicates which build tool (a.k.a. the driver) is used. We can then use this as follows:
target-dir target${if;${driver;eclipse};;/${driver}}
bin ${target-dir}/classes
testbin ${target-dir}/test-classes
About the unresolved macro, not sure what happens here. I’ve updated the code to use ${def;driver-modifier} but do not understand why that would be necessary. Will look at the code and come back.
Hmm, embarrassing. As far as I can see it does work but it creates this superfluous directory. It seems that the following definition goes better (and is simpler):
Great, thank you. I can confirm, that with the following block in cnf/build.bnd and doing 1.) an Eclipse Build followed by 2.) a gradle build on command line the resulting folder / jar structure is like:
cnf/build.bnd:
target-dir target${if;${driver;eclipse};;/${driver}}
bin ${target-dir}/classes
testbin ${target-dir}/test-classes
Gradle creates a gradle-subfolder inside target where the .jar is placed.
This is a nice addition and will cause less confusion for developers wondering why their Eclipse starts rebuilding everything when they start a gradle clean build
The default for target-dir seems to be generated when not defined. This has been the case for us.
In this case it may be a better idea to use the prefix generated instead of target like
Only thing to be aware of is that sometimes, like in Github actions, the target folder is used to upload artifacts. This can be confusing since they’re not somewhere else than they used to be.
I’ve been longing to generate the .classpath properly from the bnd information. However, there was pushback to this idea because maybe some workspaces have private information in it. To me this is not worth the inconvenience to be so easily able to do it wrong.
A quick fix on the warning (with the repeat support) might be very useful. The code to generate the class file already exists.
Yuck! Always fix the root problem when possible, regardless of the amount of work. You, or the poor slobs coming after you will know why … When you let yourself (or your workspace) go, it always surprises me how quick it gathers problems.
Having a clean hygienic workspace is such a wonderful feeling!