Correct utilization of -generate

I’ve created a CodeGenerator for EMF and it works quite well. I unfortunately seem to be to dense to properly use the standard abilities the -generate gives. Namely to properly utilize the attributes of a statment.

Right now my instruction looks as follows:

-generate:\
	model/test.genmodel;\
		generate=geckoEMF;\
		genmodel=model/test.genmodel;\
		logfile=test.log;\
		output=src-gen

I know that the output and als the genmodel shouldn’t be necessary, but I have no idea how to
A. properly form the instruction and B. how to read it.

I provide an Options Interface as per the documentation:

@ExternalPlugin(name = "geckoEMF", objectClass = Generator.class)
public class GeckoEmfGenerator implements Generator<GeneratorOptions> {
 public interface GeneratorOptions extends Options {
    	String genmodel();
    	Optional<File> output();
    	String logfile();
    }
.
.
.

In the end none of the methods return anything.
In addition I tried to get the argument model/test.genmodel I have duplicated via the genmodel attribute via options._arguments(), but the list is empty.

Am I missing something?

Obviously :slight_smile:

This is the example in the manual:

-generate:   \
    gen/**.java; \ 
        output='src-gen/' ; \ 
        generate='javagen -o src-gen gen/'

So in your case I expect the following to work:

-generate:\
	model/test.genmodel/; \
		output=src-gen/; \
		generate="geckoEMF -g model/test.genmodel -l test.log -o src-gen"; \

I see… I should RTFM in detail next time and not not only look at the pretty pictures (code snippets in this case).

It looks as if there is no way to get the source fileset inside my generator without redefining the input as an argument? Am I missing something? If not, I believe it would be nice to provide it via the context as well.

Well, the code snippet showed the correct usage?

How hard is it to define a property?

output = src-gen/
-generate:\
	model/test.genmodel/; \
		output=${output}; \
		generate="geckoEMF -g model/test.genmodel -l test.log -o ${output}"; \

Realize that the extension have a much broader usage than the -generate instruction.

However, looking at the code, the BuildContext you get is a Processor and the attributes on the -generate instruction are set on it. So you should be able to get the output property from the context.

Yes defining a property is easy, but this is not my point. I already do retrieve e.g. the output from the context. What I would like to get as well is the defined file set (in the exampel case the model/test.genmodel).

I showed the generator example to a future user and the first question I’ve got was: “Why do I need to define the genmodel twice?”. It makes total sense if the generator is a Main class or a system command, where arguments are the only way to transport information to it. For a generator as ExternalPlugin this does not apply from my perspective.

I’m not quite sure what you mean by this. Do you mean the external plugin or are you referring to our other discussion around the Workspace Extensions?

Well, they tend to go to an almost identical handling

The -generate is based on the External Plugins facility. This facility is agnostic of -generate.

However. I think it can be squeezed into the code. You will need to pass the file set to the downstream methods and make a method to get this file set on the Build Context.

I’ve no problem if someone wants to add this.

I might do this at some point.

Damn, I need more time to manage all the things I want to do vs the things I actually get paid for…

Tell me … Bndtools is at such a wonderful place now. It is already a wonderful environment to develop in but there are so many enticing functions that seem to be not that much work …