Missing artifact error in Maven - maven-2

I get a missing artifact error during Maven build because one of the dependencies declares it's parent artifact using a property for the version. Now the property itself is declared in the parent pom and my project's build fails giving this error:
[ERROR] Failed to execute goal on project abc: Unable to get dependency
information for xyz:pqr:jar:SNAPSHOT: Failed to process POM for
xyz:pqr:jar:SNAPSHOT: Non-resolvable parent POM xyz:pqr-parent:${someversion}
for xyz:pqr:${someversion}: Failed to resolve POM for
xyz:pqr-parent:${someversion} due to Missing:
----------
1) xyz:pqr-parent:pom:${someversion}
----------
1 required artifact is missing.
for artifact:
xyz:pqr-parent:pom:${someversion}
I have verified that the artifacts are present in correct location in the repository.
Is there a way to specify the value of someversion property used in the dependency pom?
If not, how should the dependency pom be changed to resolve the error?

I get a missing artifact error during Maven build because one of the dependencies declares it's parent artifact using a property for the version. Now the property itself is declared in the parent pom and my project's build fails giving this error (...)
This is a chicken and egg problem: you can't get the version of the parent to use from the parent.
Is there a way to specify the value of someversion property used in the dependency pom?
AFAIK, this is not possible, properties in project.parent.version do NOT get substituted. You might want to check MNG-624 (and vote for it) and related issues.
If not, how should the dependency pom be changed to resolve the error?
Use an "hard-coded" version in project.parent.version.

Related

while trying to add dependency getting the following error in POM missing artifact androidx.test.uiautomator

while i am trying to download depedency androidx.test.uiautomator using maven i am seeing a missing artifact error in my pom xml.
anyone faced such issue , can someone enlight me on this issue
dependency in maven https://mvnrepository.com/artifact/androidx.test.uiautomator/uiautomator/2.2.0
Pom XML error

Gradle subprojects refresh removes other dependencies

I have following project structure:
rootProject.name = 'toolbox-backend'
include 'toolbox-components-executor'
include 'toolbox-components-toolsyncer'
include 'toolbox-components-toolconfigparser'
toolsyncer i.e. has the dependency for the jgit library. While trying to edit the code in the service java file I see that IntelliJ shows the resolve in red - so it isn't found.
I found out that this happens when I resolve all projects at the same time. The toolsyncer subprojects shortly resolved the dependency but gets its dependencies removed as soon as the next subprojects starts to resolved and therefore removes the jgit dependency since it does not need it.
Whats the best practise here? Declare all dependencies needed in the root project?

get oozie-client dependency with Gradle build

I'm trying to build my project using IntelliJ and gradle. I have a dependency on oozie-client jar.
I defined the dependency in gradle as follows:
dependencies {
compile 'com.yahoo.oozie:oozie-core:3.0.0'
}
when I run buildDependency I get the following error:
* What went wrong:
Could not resolve all dependencies for configuration ':compile'.
Could not resolve com.yahoo.oozie:oozie-core:3.0.0.
Required by:
:TestRunnerFramework:1.0
Could not resolve com.yahoo.oozie:oozie-core:3.0.0.
Could not parse POM http://repo1.maven.org/maven2/com/yahoo/oozie/oozie-core/3.0.0/oozie-core-3.0.0.pom
Could not find any version that matches com.yahoo.oozie:oozie-main:3.0.0.
please advice,
This is either an incorrect POM (or incorrect parent POM), or a POM that Gradle fails to interpret correctly (there are a few known limitations around this). Often, the only solution is to edit the POM, for example in your binary artifact repository. If you think the problem is on Gradle's side, you can file an issue over at http://forums.gradle.org.

How do I show the Maven POM hierarchy?

I'm doing some scripting and I need to get a list of all the parent poms for any given pom. The dependency plugin seems to be only interested in the dependencies that are listed in the dependency section of the pom, but there doesn't seem to be a way to show the parent poms, which are also required dependencies for Maven to work.
Am I missing something basic?
There is no simple Maven command that will show you the chain of parent POMs for a pom.xml. The reason for this is that it is not a common question one would typically ask (more on that below). For your script, you'll just have to parse the pom.xml file, get the parent artifact coordinates, get a hold of the artifact's pom.xml file and then parse it's pom.xml file (and repeat). Sorry, but there is no short cut I know of, but other folks have solved similar problems.
You are right that technically the parent pom is a dependency of your project, but it is not a literal Maven Dependency and is handled completely differently. The chain of parent poms, along with active profiles, your settings.xml file, and the Maven super pom from the installation directory are all combined together to create your project's effective pom. The effective POM is what Maven really uses to do its work. So basically, the parent pom inheritance chain is already resolved and combined before the dependency plugin (or any other plugin) is even activated.
The questions most people typically ask is 'what does my REAL pom.xml really look like when Maven is done combining everything?' or 'What is the result my inheritance chain of parent poms?' or 'How are my pom.xml properties affected by an active profile?' The effective pom will tell you all of this.
I know you didn't ask, but for others reading this, if you want to see your parent pom.xml, simply open up the pom.xml in the M2Eclipse POM editor and click on the parent artifact link on the overview tab. In this way you can quickly move up the chain of pom.xml files with just a single click per pom. It would be a strange project that had more than 3 or 4 parent poms of inheritance.
If you want to see your effective pom, you can run the command mvn help:effective-pom. Alternatively, you can click on the Effective POM tab in M2Eclipse's POM editor.
Basic solution
mvn org.apache.maven.plugins:maven-dependency-plugin:3.1:display-ancestors
If your project defines version 3.1 or later you can use:
mvn dependency:display-ancestors
The output looks similar to:
[INFO] Ancestor POMs: org.springframework.boot:spring-boot-starter-parent:1.4.0.RELEASE <- org.springframework.boot:spring-boot-dependencies:1.4.0.RELEASE
Improved solution
The hierarchy-maven-plugin (that I wrote) can display additional information about imported poms like this :
[INFO] Displaying hierarchy. Set level=full to display dependencies in dependencyManagement
[INFO] PARENT org.springframework.boot:spring-boot-samples:1.4.1.BUILD-SNAPSHOT
[INFO] PARENT org.springframework.boot:spring-boot-starter-parent:1.4.1.BUILD-SNAPSHOT
[INFO] PARENT org.springframework.boot:spring-boot-dependencies:1.4.1.BUILD-SNAPSHOT
[INFO] IMPORT org.springframework:spring-framework-bom:4.3.3.BUILD-SNAPSHOT
[INFO] IMPORT org.springframework.data:spring-data-releasetrain:Hopper-BUILD-SNAPSHOT
[INFO] PARENT org.springframework.data.build:spring-data-build:1.8.4.BUILD-SNAPSHOT
[INFO] IMPORT org.springframework.integration:spring-integration-bom:4.3.1.RELEASE
[INFO] IMPORT org.springframework.security:spring-security-bom:4.1.3.RELEASE
Details are here : https://github.com/ExampleDriven/hierarchy-maven-plugin

maven release:perform and parent pom

I have a library which I "mavenized" recently and put into a local git repository.
In order to lock some plugin versions I created a simple parent pom which defines the plugin versions via pluginManagement (the parent pom file is not checked into any SCM repository). I specify the parent pom in my libraries pom file:
<parent>
<groupId>org.my.company</groupId>
<artifactId>superpom</artifactId>
<version>1</version>
</parent>
I use default directory structure.
When I try to perform a release using the release plugin I run into a problem.
mvn release:prepare runs fine however when I run mvn release:perform maven checks out the corresponding tag from my local git repository into the target/checkout folder and tries to run the deploy goal.
However the build fails with the error message that it can't find the parent pom file defined in my library pom file.
I assume that's related to the fact that maven tries to find the parent pom file in the target folder and it is not available there.
Is there an easy way how to solve this problem?
Update:
I have multiple unrelated GWT libraries which should share the common company parent pom file in order to specify plugin versions.
The parent pom is just used for defining some default versions and won't contain any module definitions because all GWT libraries are unrelated.
The GWT library are really simple and have no real dependencies to any other libraries apart from the default ones (gwt, junit)
Update2:
I solved the problem by installing the superpom into my local repository by running mvn install in the folder of my superpom.
The first fail you did is not to versionise the parent pom where you defined the pluginManagement area. This is the first step you must do put the pom.xml which you like to use a parent. Secondly you have to put the information about the VCS into the scm area of that pom. After you cleaned up everything you must do a mvn release:prepare release:perform of the parent pom. After that you are able to use it as a parent in your other projects. Furthermore you should define the distributionManagement area in your parent pom.