I'm creating new project for Servicemix 4.4.0. My project will consist of several modules and one parent pom.xml, here is an example:
+- Module1
+- Module2
+- pom.xml (parent)
Each module contains element referring to the parent pom.
I was thinking about declaring all Servicemix dependencies in parent pom. This way, I would get rid of versions in child modules.
So my question is, how to include all Servicemix dependencies in my parent pom.xml without typing them directly one by one? Perhaps there is a way to import some Servicemix parent pom or something similar?
Servicemix4 is just an OSGi container with a bunch of features/bundles already installed, you don't want to import all the Servicemix dependencies into your project. Instead, build your project (using the maven-bundle-plugin) using only the dependencies necessary for your project and then deploy it into Servicemix4.
see these pages for more information...
http://servicemix.apache.org/SMX4/creating-a-bundle-using-maven.html
http://www.consulting-notes.com/2010/08/servicemix-developer-machine-setup.html
If you are just looking for the latest versions of artifacts, then you can get them here...
http://svn.apache.org/repos/asf/servicemix/smx4/features/trunk/pom.xml
Related
I would like to distribute the main artifact sources (main Java and tests) of a multi module project as a simple - standalone - Maven project.
The easy parts of this can be implemented using the maven-source-plugin. This also is able to include the POM in the generated source code jar. However, this is the artefact POM, which refers to the parent POM which is not included in the jar.
Other than creating the POM manually, is there a way to generate a minimal POM which contains the dependencies (extracted from the artifact POM and its parent)?
If you create the POM with the flatten-maven-plugin, all parent relations are resolved and you get an equivalent POM without the unnecessary parts.
https://www.mojohaus.org/flatten-maven-plugin/
Our warfile contains not the expected SNAPSHOT-Version of a jarfile, it contains an older release version via another dependency.
Simplified dependency:tree
war-x.x.x-SNAPSHOT
\- jar1-x.x.x-SNAPSHOT
+- jar2-x.x.x
| +- problemjar-x.x.x
+- jar3-x.x.x-SNAPSHOT
jar3-x.x.x-SNAPSHOT has a dependency "problemjar-x.x.y-SNAPSHOT" (newer version), but the war project build (and the dependency:tree) contains "problemjar-x.x.x" from "jar2-x.x.x".
For now, we "exclude" "problemjar-x.x.x" for "jar2-x.x.x".
But it would be nice to know the reason for this behaviour, IMHO the exclusion is just a workaround.
Notes:
The dependency "problemjar-x.x.y-SNAPSHOT" in "jar3-x.x.x-SNAPSHOT" is not "provided".
The Maven version is 3.2.5
The levels in the simplified dependency:tree above are correct, so the path to the older version is not shorter than the path to the newer SNAPSHOT version
edit: project structure
war and jar1 are children of one parent pom, the simplified dependency:tree is from the war project which has the jar1 project as a dependency. The others are normal/external dependencies, which applies to jar1 too as seen from the war project.
Maven does not take the newest version from the dependency tree.
It takes the nearest version, and in your case this is the first it encounters.
If you want to force Maven to take a specific version, it is better to use <dependencyManagement> instead of exclusions.
Make sure of the following:
1) Each child module should take it's version from it's parent, i.e. do not have a <version> tag only a <parent> tag that contains a version.
2) When you call the dependency from the same project always do it as follows:
<version>${project.version}</version>
I have a multi-module maven project with a reactor pom that I use to build the whole project, and a parent pom which all child modules inherit from.
There is a plugin I need to have in both the reactor and the parent poms, meaning I have a separate use for the plugin in the child modules and in the reactor pom used to aggregate the build. I'd like to manage the version of this plugin in one file, instead of manually changing it in both files every time.
Example:
Project structure:
--pom.xml //reactor pom - aggregates the build (contains the plugin)
----parent/pom.xml //parent pom - all child modules inherit this pom (contains the plugin)
----a/pom.xml //module a - inherits parent/pom.xml
----b/pom.xml //module b - inherits parent/pom.xml
----c/pom.xml //module c - inherits parent/pom.xml
Note: the parent pom is inherited by child modules only. Not by the reactor.
any help is greatly appreciated, thanks in advance
I have a parent project(has its own pom.xml) in which I import the child project as a jar with its own pom.xml.
In the parent pom.xml I have specified my child jar as a dependency - this gets resolved, but i want maven to resolve the dependencies required by my child jar.
My Use case to replicate :
When I include spring-web-mvc.jar the transitive dependencies are resolved automatically.
I have a similar requirement where I include my child.jar into a main framework project and expect the transitive dependencies to get resolved (Notw: the child.jar is not hosted it is packaged as jar and present on the local file system)
Current Structure:
Child Project:
|----/src/main/java
|----/src/main/resources
|----child-pom.xml
>This child project will be a jar as dependency in the parent project
Parent Project
|----/src/main/java
|----/src/main/resources
|----/src/main/webapp/WEB-INF/lib/child.jar
|---- parent-pom.xml
The problem:
When i create a war from parent project i want all the dependecy including transitive ones to show in WEB-INF lib.
Currently this is not happening.
First when talking of parent/ child Maven projects normaly you have your"childs" specified as modules in a common parent project which itself is beeing packed with the packaging type pom rather than make them a dependency of the parent project.
When it comes to the dependencies of your "childs" or generally "dependencies of your dependencies" those are called transitive dependencies and are pretty well explained in the official documentation found here: http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
The resolving of those transitive dependencies is one of Mavens core strenghts and guaranteed by default unless they lead to conflicts that make the build fail.
Two things to help here are having a closer look into the enforcer plugin (http://maven.apache.org/enforcer/maven-enforcer-plugin/) and the shader plugin (http://maven.apache.org/plugins/maven-shade-plugin/) .... well and the official documentation of corse (reading the whole thing takes less than a day - then supports you further for specific topics whereas we gladly further support you too if you already have pom.xml files and you are stuck somewhere.
While the enforcer-plugin covers certain conflicts regarding different versions of the same artefacts the shader plugin will just pack everything you specified to a single jar for reverseengineering (its not the normal use case but i sometimes use it that way if i am not absolutly sure what ends in my final archives).
Also worth a look at is the dependency-plugin already available in the maven distributions - mvn dependency:tree -Dverbose will give you pretty detailed information on the resolved dependencies (and probably version conflicts).
I've currently got a parent pom that declares two modules: an ear and a war. The ear is reliant on the war (and declares a dependency for it with group/artifact id and packaging type).
When packaging from the parent pom level, the reactor picks up both artifacts and properly packages the war into the ear as you would expect. However, when packaging from the ear's project pom (despite having declared elements in both projects pointing to the parent pom) the ear fails to find the war artifact.
I know that when packaging at the ear level Maven finds its way to the parent correctly, but does it not then iterate down to the various modules that the parent contains to pick up artifacts?
Thanks :)
That's the way Maven works. It's OK. When resolving dependencies, Maven looks for them in reactor, then local repository, then remote repos. So, when doing a build from a parent project level, both projects are in the reactor, so EAR can pick WAR easily. (To be specific, it's not because the parent-child relation, but the fact they are modules.) However, when you build an EAR module in isolation, reactor can't provide WAR as well as local repo as well as remote repos. If you install WAR module into local repo by mvn install and then try to build EAR, WAR artifact will be found using local repo.
Sounds like your parenting structure is broken, if the EAR depends on the WAR then it should be a child module.