[英]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. 我有一个由SBT管理的scala项目,其中包括许多类,这些类是链接到专有代码的适配器。 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
我需要确保每个适配器
--with-xxx
when running ./configure
in a C project) ./configure
时类似于--with-xxx
) What should the directory structure of something like this look like? 这样的目录结构应该是什么样的? What about the SBT project(s)?
SBT项目如何? I'd like to adhere to the usual Gradle directory structure if possible.
如果可能的话,我想坚持通常的Gradle目录结构。
The problem to consider is that each adapter depends on the core project (ie they inherit an Adapter
interface defined in the main project), and in turn the core project depends on individual adapters. 要考虑的问题是每个适配器都依赖于核心项目(即,它们继承了主项目中定义的
Adapter
接口),而核心项目又依赖于各个适配器。 So I'm not sure how to set this up to avoid circular dependencies, while isolating the core code from the adapter code. 因此,我不确定在设置核心代码与适配器代码的同时如何设置以避免循环依赖。
It can be achieved this way: 可以通过以下方式实现:
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: 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"
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.