java - Maven share sources in modules with custom resources -
i have maven project should output 3 jar files. of them share same sources have different resources.
my project structure this:
project/ +-- src/main/java - sources folder +-- src/main/resources - shared resources (some images) +-- pom.xml +-- modulea/ | +-- src/main/java - empty folder | +-- src/main/resources - custom resources | +-- pom.xml +-- moduleb/ | +-- src/main/java - 1 additional java class | +-- src/main/resources - custom resources | +-- pom.xml +-- c & d ...
how make maven generate 4 jar files custom resources , merged java files? if resources override, possible make custom priority?
i've tried using
<build> <sourcedirectory>${parent.basedir}/src/main/java</sourcedirectory> </build>
in child pom.xml didn't work
update 1
so i've changed structure to:
project/ +-- src/main/java - empty +-- src/main/resources - empty +-- pom.xml +-- coremodule/ | +-- src/main/java/ - shared sources | +-- src/main/resources/ - custom resources | | +-- coretext.txt | +-- pom.xml +-- modulea/ | +-- src/main/java - empty folder | +-- src/main/resources - custom resources | +-- pom.xml +-- moduleb/ | +-- src/main/java - 1 additional java class | +-- src/main/resources - custom resources | +-- pom.xml +-- c & d ...
and i've used maven-shade-plugin make modulea.jar , moduleb.jar shared sources , resources.
now facing issue maven-shade-plugin not offer filter or replace-text tools. need change text in coretext.txt according rules in module. simple string replace in file. there way filter in maven-shade-plugin?
this depends heavily on you're doing specialized projects (modulea->moduled).
you want declare "project" dependency of each module, make uberjar. can done maven-shade-plugin, or possibly assembly plugin (again, depending on need). there onejar plugin, , if you're using spring boot, can make standalone jar.
also, fwiw, it's bad practice make parent project ("project" in case) actual project, , instead create proper "parent pom", shared-java module child (along module a->d).
Comments
Post a Comment