Correct/simple way to access own FacetConfiguration from BuilderService

Answered

Hi all,

What Is the  simple/correct way to access the custom FacetConfiguration (or FacetState) for module from a BuilderService?

There is the FacetManager of course but that uses the Module and Project related API. The API around BuilderService use JpsModule and JpsProject on the other hand. 

Do I need to implement a JpsModelSerializerExtension to serialize the configuration from the IDE to the builder? Is there an example of a plugin which implements this? 

Any pointer would be much appreciated!

Best regards,

Johan

0
4 comments

Hello,

Is it secret maybe?  :-P

I've implemented a simple facet for my little plugin (MyFacetConfiguration, MyFacetState, etc...). And this works fine so far. The values represented in MyFacetState end up in the .iml file. But I'm looking for way to obtain the facet stare values from within a BuilderService implementation.

I fail to understand how to do this. I previously mentioned implementing a JpsModelSerializerExtension but don't see what role it actually plays in all this. From the code of erlang plugin it seems one still has to do a lot of xml parsing from within the JPS code. I must be missing something here :'(

Kinds regards,

Johan

0

You need to implement org.jetbrains.jps.model.serialization.facet.JpsFacetConfigurationSerializer together with org.jetbrains.jps.model.serialization.JpsModelSerializerExtension

0

Hi Yann,

No I got that part (I mentioned it in my original question in fact). I struggle to find a way to access the deserialized facet configuration from with the builder service. I can "find" it through the ModuleChunk but not the CompileContext provided by BaseInstrumentingBuilder API. Is there another way to get hold of the facet data?

More generally though I am looking for a good explanation of the communication between the IDE and JPS. The xml serialization based hand over between the two is not clear to me. State needs to be represented both on the IDE side and again on the JPS side. I'm confused to say the least :(

Best regards,

Johan

 

0

Sorry for delay:

> State needs to be represented both on the IDE side and again on the JPS side.

Correct. General idea is that JpsFacetConfigurationSerializer will serialize and deserialize XML to/from certain Java class, which should be designed and implemented. Then use the Project instance obtained from a Context to query this component.

In org.jetbrains.jps.incremental.instrumentation.BaseInstrumentingBuilder#instrument, you can access org.jetbrains.jps.incremental.CompileContext#getProjectDescriptor to obtain JpsModel, then locate facet settings:

JpsProject.getContainer().getChild()
0

Please sign in to leave a comment.