Maven parent POM issue - java

I have a parent POM that, I have used in my other project for dependency management. When I build my child project at that time, it will check in my repository to get parent pom. But at the same time is going to check for the maven central as well. But for obvious from there it is not found and with the exception, my build process is going to stop.
Can anyone tell me the reason why it is happening? Any help is appreciated.
For better understanding, I have attached a log.
[INFO] Downloading from bom-ci-maven: http://xxx:8800/api/v4/projects/xxx/packages/maven/com/xxx/project-bom/0.0.2-DEV/project-bom-0.0.2-DEV.pom
[INFO] Downloading from central: https://repo.maven.apache.org/maven2/com/xxx/project-bom/0.0.2-DEV/project-bom-0.0.2-DEV.pom
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for com.xxx:xxx:0.0.2-SNAPSHOT: Could not find artifact com.xxx:project-bom:pom:0.0.2-DEV in bom-ci-maven (http://xxx:8880/api/v4/projects/xxx/packages/maven) and 'parent.relativePath' points at wrong local POM # line 4, column 11
#

There are 2 ways to build a module separately from the rest of the modules, including parent.
The best way is to run this from the root directory of your project (note -am):
mvn package -pl child -am
Another option is more cumbersome, but may work faster if your module depends on multiple neighboring modules. First install all the dependencies into local repository. In case of snapshot dependencies it will cache it for some time and then will start checking remote Maven repositories again. This allows you to step into the child module and invoke commands relying on parent or other modules.
Additionally in case of <parent> you can specify a tag <relativePath>, but this one isn't recommended.

Related

Maven build failure from missing tycho dependency?

I'm attempting to build two Maven projects from Eclipse. One project constitutes a set of dependencies and libraries to be used for the other project which contains all of my source code. Both are configured as Maven projects using Tycho 1.0.0 .
I have a parent POM file that contains three modules: a folder containing my target file, the plugin containing the dependencies and the plugin that contains the source code. When trying to maven build on the parent POM, I get the following error:
Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:1.0.0:compile (default-compile) on project com.ericsson.cd-editor.ui: Execution default-compile of goal org.eclipse.tycho:tycho-compiler-plugin:1.0.0:compile failed: A required class was missing while executing org.eclipse.tycho:tycho-compiler-plugin:1.0.0:compile: freemarker/template/Configuration
Gonna post the full error log in pastebin since it's diffcult to read in a Stack Overflow post:
http://pastebin.com/EYnsqvpJ
Here is my parent POM file:
http://pastebin.com/wSAtwspV
I've been told by a colleague of mine that the reason this might be happening is that this dependency might be used by Tycho and cannot be found. The freemarker package is however available in my .m2/repository/.
It's really hard to tell where the error might be.
First, make sure the jar you have in your m2 archive actually contains the class the compiler is looking for.
You could check whether you dependencies are in the central maven repository, instead of making a project containing them.
Does the project that needs all the dependencies state them explicitly, e.g., in feature.xml or Manifest.mf? Otherwise tycho will not load them, even if they are accessible to maven.
Posting the pom.xml files for the modules might be helpful. Hope you'll figure it out :)

Maven child dependency error with parent version

We have the next project structure:
parentPom.xml
java projects
streambase projects
streambaseParentPom.xml
project1
project2 (has dependency of project1)
So we have a parentPom with inherits to streambaseParentPom and last one inherit to all streambase projects.
So, we make attemp to have in parentPom a properti called cerebro.version which define the version for parent.
We're getting issues when we have project1 as dependency of other projects, we're getting next error message:
[ERROR] Failed to execute goal on project eFX-SB7-Pricing: Could not resolve dependencies for project com.santander.fx:eFX-SB7-Pricing:jar:3.14.10.0.4-SNAPSHOT:
Failed to collect dependencies at com.santander.fx:eFX-SB7-Common:jar:3.14.10.0.4-SNAPSHOT:
Failed to read artifact descriptor for com.santander.fx:eFX-SB7-Common:jar:3.14.10.0.4-SNAPSHOT:
Could not transfer artifact com.santander.fx:eFX-SB7-Parent:pom:${cerebro.version} from/to eFX-External-Repository (http://lnx-efxbuild2.ants.ad.anplc.co.uk:8081/artifactory/ext-release-local):
Illegal character in path at index 109: http://lnx-efxbuild2.ants.ad.anplc.co.uk:8081/artifactory/ext-release-local/com/santander/fx/eFX-SB7-Parent/${cerebro.version}/eFX-SB7-Parent-${cerebro.version}.pom -> [Help 1]
Thanks in advance.
I am afraid it doesn't work like that. It is a bad idea to parameterize the <version> value since even if you managed to deploy it to your remote repo, any project using that artifact later on wouldn't have a clue what ${cerebro.version} should resolve to.
Remember, Maven works hard to keep your builds reproducible. If the build is dependent on some variable that was known at deploy time, but unknown for dependents, your build will no longer be reproducible.

Unable to build Shopizer project

When I execute the mvn install inside the project sm-core of Shopizer, I am getting the below error:
[ERROR] Failed to execute goal on project sm-core:
Could not resolve dependencies for project
com.shopizer:sm-core:jar:2.0.3-SNAPSHOT: The following
artifacts could not be resolved: com.shopizer:sm-core-model:
jar:2.0.3-SNAPSHOT, com.shopizer:sm-core-modules:jar:2.0.3-SNAPSHOT:
Failure to find com.shopizer:sm-core-model:jar:2.0.3-SNAPSHOT
in http://maven.springframework.org/snapshot was
cached in the local repository, resolution will not be
reattempted until the update interval of
org.springframework.maven.snapshot has elapsed or updates
are forced -> [Help 1]
How can I solve it?
The Shopizer project is actually a multi-module Maven project. This means that it has a root pom.xml of packaging pom and declares several <modules>.
Those modules, which are Maven project themselves, are typically found as sub-folders under this root folder, which is the case here: there are 4 sub-folders, which are exactly the 4 Maven modules. To compile those sort of projects, you need to invoke Maven from the root project, in this case, shopizer.
You may ask why. In a multi-module Maven project, there is generally inter-dependencies: one module is dependent on another. In this case, the scm-core module that you're trying to build has dependencies on both sm-core-model and sm-core-modules, which are two modules of that project. So when you're building it, Maven will try to look in your local repository those artifacts. The problem is that it won't find them: they have never been built before. Maven won't also find them on a public repository because we're dealing with SNAPSHOT dependencies. The solution is to start the build on the top project: Maven will order correctly the reactor so that when it builds scm-core, both those dependencies will have been built.
Put simply: in a multi-module Maven project, you should practically always invoke Maven commands from the root POM.
To solve your problem, you can check-out the 2.0.3 branch (which is the latest branch) and invoke mvn clean install on the root POM. I did just that successfully.

Jenkins: Maven project with modules that won't be build: no pom.xml found

I've got 3 maven projects.
Project A defines B and C as module in it's pom.xml
Now I want to use Jenkins.
I defined to checkout/build project A and I think I have to manually checkout/build B and C as well, right?
The project didn't find the pom.xml of the other projects.
I defined them with relative path.
It works fine on my local machine, but it crashes on Jenkins:
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM: Failure to find de.saenger:xyz:pom:1.0.0-SNAPSHOT
Now ... how to let the projects knowing each other?
Run mvn build on parent pom. It will build modules automatically.
You're running mvn build on module and mvn searches your local repository for parent pom to resolve dependencies but can't find the pom because you haven't built it yet.

Non-resolvable parent POM: Could not find artifact

I have recently looked into Gorilla Logic's open source testing tool and need to make some changes in order to be able to log something to the console. I have checked out the code out of source control for the "Android Agent" and now I am looking to build a new .jar agent file. I need to use the
mvn clean install to build the .jar file. When I try to build it the command line is giving this error
Non-resolvable parent POM: Could not find artifact com.gorillalogic.monkeytalk:monkeytalk:pom:1.0.12-SNAPSHOT and 'parent.relativePath' points at wrong local POM # line 6, column 10 -> [Help 2]
Can anyone help me with this or let me know what this means? Thanks. :)
I don't understand maven and just want to know what it means.
Here is the pom.xml file line 6-10
<parent>
<groupId>com.gorillalogic.monkeytalk</groupId>
<artifactId>monkeytalk</artifactId>
<version>1.0.12-SNAPSHOT</version>
<relativePath>/Users/henry/Desktop/monkeytalk-agent-android/parent/pom.xml</relativePath>
</parent>
This project seems to be module project under another maven project "moneytalk".
As this project can inherit properties, dependency management information, plugin information from the parent project, maven tries to read the parent pom.xml.
If the parent pom.xml is not available at the specified location, maven build will fail.
One option is to checkout all the projects including the parent project.
Other option is to place the pom.xml of the parent project at the required location (in your case /Users/henry/Desktop/monkeytalk-agent-android/parent/pom.xml
If there are lots of dependencies behind the project, they have to be pattered for first before building the main project.
Clean, compile and install such dependencies (from the "Maven" pane found on the right side of the IDE). First move such dependencies enclosed within their projects to the same main project directory.
Lastly, clean, compile and install the main project.

Categories