Reputation: 10943
I think I am misunderstanding how the plugin architecture works and was hoping that someone could help me out. This is how I understand Maven works:
When mvn
runs inside a directory it reads the pom.xml
file and the files up through the hierarchy to the super POM. Maven then works through the project’s life cycle running the plugins that match each phase/goal against the code in the project. So if you specify a plugin in the parent POM then that plugin will be run against the child projects as if it was specified in the child project only.
My build has 3 projects:
proj-parent/ # Just specifies the modules to build
pom.xml
proj-java/ # Normal Java jar project
pom.xml
<normal java structure>
proj-php/ # PHP Yii project
pom.xml
src/
web/
jars/
js/
js-src/
index.php
I’d like to create a distributable containing a subset of the proj-php/
files along with the jar from proj-java
with all its dependencies.
This question is not about the details of my POMs but more about the strategy behind moving the files around using the available plugins. I’ve looked at assemblies but they only seem to be concerned with moving the files around inside a given project and not copying from one projects target folder to another.
Am I supposed to have a properties file containing a variable specifying a final build path so that the projects know where to copy the bits from each project in order to make the distributable. Am I going about this the right way?
I had thought of consolidating all 3 projects into 1 by moving the proj-php/src/web
into proj-java/src/main
and using assemblies. However, this makes things awkward for my development environment as I use Eclipse JDT/PDT (for the Java and PHP projects respectively). I run them both at the same time and they would conflict with each other due to their shared project root.
Update: Does anyone have any advice on how to organise my projects so that I can create a distributable that includes this things I want without any external scripts.
I suppose I'm expecting answers like: "You could get rid of the proj-parent
and pull proj-java/
in as a dependency of proj-php
, then use an assembly to move everything around within that project."
How do people organise a Maven project when they have a lot of non-jar files that need to be consolidated from several projects?
Upvotes: 0
Views: 71
Reputation: 920
This is a structure at my work and it works for us.
proj-parent/
|---pom.xml
|---pom.properties <-- if needed
|---proj-java/
| |--pom.xml
| \--<normal java structure>
\---proj-php/
|--pom.xml
|--src/
\--web/
That is for structure. Regarding dependencies and projects that share dependecies i will refer you to this site which will give you a fast know how.
If you get the time, do read other chapters from the same webpage. They helped me a lot.
Upvotes: 2