Excluding by group but still including specific module

I need to exclude almost all dependencies of a certain group from my project, but I still need one specific one included. I know that I can use the configurations dsl to exclude by group like this:

configurations {
    all*.exclude group: 'org.somegroup'
}

The problem is then how can I include the one jar that is needed? I would like to do something like this (which obviously does not work).

configurations {
all*.exclude group: ‘org.somegroup’, module:’!theModuleNeeded"
}

Or maybe this:

configurations {
all*.exclude group: ‘org.somegroup’, module: { m ->!m.equals(“theModuleNeeded”) }
}

At the moment you can only exclude based on the attributes group and/or module (see ExcludeRule). Instead of trying to avoid an exclusion I’d just declare the dependency you want and force it.

I tried using force but it does work. Once the entire group has been
excluded, there is no way to include a specific model.

At the moment, I had to resort to excluding only by group + module and not
excluding the specific one that I want. This is a suboptimal solution since
there many modules in this group and I want to exclude all of them except
one.