Just got head into Maven and I’ve got situation where I have cyclic dependency problem.
my original structure was
|-mainProject
|-webProject
where mainProject has webProject as a dependency (war packaging).
Got error since webProject also depends on mainProject, so I changed the structure
|-coreProject
|-mainProject
|-webProject
so that core get packaged into a jar and both main&web have core as dependency.
Now I see different error while creating -shade.jar.
CoreProject’s components need to be used by both main&web projects.
What would be the best practice in this case?
my dependency graph looks like
mainProject(jar) -> webProject(war) --
|-> coreProject(jar) <-|
|-> jetty jars
I’m using embedded jetty in mainProject, so that my final outcome would be single jar file from mainProject which includes web&coreProjects.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:1.4:shade (default) on project mainProject: Error creating shaded jar: Invalid signature file digest for Manifest main attributes -> [Help 1]
I have tried filters such as
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
but still getting the same error
It’s highly unusual to have a WAR project as a dependency for another project in the way you described. A valid scenario I can think of is bundling the WAR into a ‘higher’ level archive (like an EAR). But in that case your dependency is defined in your EAR project and not the other way around. In any case, if you want to follow best practices then place your core classes in
mainProjectand set its packaging to JAR. Then add a dependency for it to yourwebProject.If both
mainProjectandwebProjectwill always be deployed together you should consider defining them as submodules in a multimodule POM.