modules with shared sources

已回答

Hi

Is there any supported way to have shared sources between different modules? Imagine module_a and module_b defining their own content roots plus taking sources from one common content root.

Gradle works with such configuration just fine and IDEA happily imports and builds it, though editor isn't very happy when opening shared files. Main problem is I can't change module settings: IDEA refuses to save them with a "Two modules in a project cannot share the same content root" error.

I can't extract common part in a separate module because it won't even compile: there are a lot of missing classes that are provided (in different ways) by module_a and module_b. (It's an attempt to share Grammar-Kit generated parser by both idea plugin and a standalone parser; generated and most of surrounding hand-written classes are common, but stubs and some of the helpers are different)

thanks!

1

There is no point in changing module settings for the projects imported from Gradle or Maven, all your changes will be discarded after the Refresh.

If the Gradle imported project works and builds in IDEA, it's the way it should be configured and you don't need to change anything.

0

Not able to change settings is not the main problem here, just an indication that something is wrong with the project. Another one is IDEA getting confused (showing false positives) when editing sources from module_a or module_b that depend on this common part. I can make a sample project if you're interested, but I think the root cause is still the same: shared content root.

Perhaps the only reasonable workaround is copying this shared part to two separate locations

0

> Main problem is I can't change module settings

> Not able to change settings is not the main problem here

Hmm...

0

IDEA doesn't support the same content root for multiple modules. Each module must be a self contained unit that can be built, then dependencies will work properly.

1

OK, sorry for my Friday night wording and thanks for the answer =) 

0

请先登录再写评论。