i have a minecraft fabric mod project
this is its struct
airgame-api-parent:
airgame-api-common:
airgame-api-client:
airgame-api-server:
airgame-api-all:
Initially, i build them as a single project, but with the increase of code and function, i added some another depend into my project. such as
mysql-connector
andHikariCP
.
its only needed in server side because the client does not need to connect my sql.
butmysql-connector
is too big. it caused my jar file size increase to 4MB+ from 100KB+.
I think it's unbearable.
So I disassembled my project.
the project airgame-api-common
is universal environment code: it can be running with client and server.
the project airgame-api-client
is client side only code. it just can be running with client. it depend with api-common
.
the project airgame-api-server
is server side only code. it just can be running with server. it depend with api-common
too.
the api-server
include some server-side code. example as mysql-connector
and HikariCP
.
and finally, the api-all
include all code of api-common
, api-client
and api-server
. In this way, I don't need to import api-client
and api-server
at the same time when coding other projects. (Actually, I can't do that because api-client
and api-server
used the same mod_id
. If I import them, when I execute the test, the running environment will contain both dependencies, and then crash due to mod_id
conflict.)
okay, first i try to use api project(":airgame-api-common")
in the api-client
, but it now work, other project that depend api-client
still can not see api-common
. i guess may plugin fabric-loom
changed gradle's build or depend logic.
the fabric-loom
docs say that i need use modApi
, i tried, but it look like cant be use to import self sub-project.
OK, I'm sorry to say a lot of things that have nothing to do with the problem, but I just want to show that I've done my best to solve the problem.
So now I guess there's one way left: add classpath and resources from api-common
to other projects before gradle starts compiling code. I think modifying build.gradle
can do it, but I don't know what to do.
I tried to read gradle's documentation, but I really didn't know much about the software, so I couldn't find much useful information. Can someone tell me?
I need the api-client
compile file have both its own code and api-common
code, and the api-common
code needs to be visible to the projects that depend on the api-client
.(This is also required for api-server
and api-all
. But I think if you teach me to configure api-client
, I should be able to configure others.)
Finally, my English is not very good, but I try my best to express my intention. I don't mean any harm to anyone. If I offend you, please forgive me.