Q:

How to structure a JVM project to isolate proprietary code?

I have a scala project managed by SBT, which includes a number of classes that are adapters that link to proprietary code. These have commercial licenses that preclude distribution of linked libraries, as well as the adapter code that I've written myself.
I want to isolate these adapters from the rest of my code so that I could in theory distribute my project as open-source. I need to ensure that each adapter

Is version-controlled separately. 
Can be selectively switched on/off during compilation & JAR creation (kind of like --with-xxx when running ./configure in a C project)

What should the directory structure of something like this look like? What about the SBT project(s)? I'd like to adhere to the usual Gradle directory structure if possible.
The problem to consider is that each adapter depends on the core project (i.e. they inherit an Adapter interface defined in the main project), and in turn the core project depends on individual adapters. So I'm not sure how to set this up to avoid circular dependencies, while isolating the core code from the adapter code.

A:

It can be achieved this way:

Extract the adapter interface from the 'core' module into a new module 'adpater-api';
Declare it as a dependency for the 'core' module and all the adapter implementation modules;
Declare 'core' as a dependency of the adapter implementation modules.
Each module can be versioned separately.
And adapter implementation modules are packaged separately.

Project layout:
root
├── adapter-a
│   └── src
│       └── main
│           ├── resources
│           └── scala
├── adapter-api
│   └── src
│       └── main
│           ├── resources
│           └── scala
├── adapter-b
│   └── src
│       └── main
│           ├── resources
│           └── scala
└── core
    └── src
        └── main
            ├── resources
            └── scala

build.sbt:
lazy val root = project
  .in(file("."))
  .aggregate(adapterApi, core, adapterA, adapterB)

lazy val adapterApi = project
  .in(file("adapter-api"))
  .settings(
    version := "1.0"
  )

lazy val core = project
  .in(file("core"))
  .dependsOn(adapterApi)
  .settings(
    version := "1.5"
  )

lazy val adapterA = project
  .in(file("adapter-a"))
  .dependsOn(adapterApi, core)
  .settings(
    version := "1.2"
  )

lazy val adapterB = project
  .in(file("adapter-b"))
  .dependsOn(adapterApi, core)
  .settings(
    version := "1.0"
  )

