Can Gradle reuse maven parent POM?

Can gradle reuse maven parent POM?

We have a pom.xml which predifine all the required dependencies, how can I use it like in maven?

If you are consuming a dependency from a Maven repository, the relevant metadata (POM, parent POMs) is evaluated, transitive dependencies are resolved.

I assume you are talking about a different use case though, a “bill of materials” (BOM). Today Gradle doesn’t not provide this functionality out-of-the-box. However, there are two Open Source plugins you might want to check out that implement similar functionality:

nope, I am talking about maven pom. How to consume a maven pom dependency?

I tried this but not work,

dependencies {
compile ‘test:testParent:1.0.0’
}

While you can declare test:testParent:1.0.0@pom it doesn’t seem to resolve transitive dependencies.

  • Is it correct to assume that your dependency only has a published POM but no JAR file?
  • My guess is that your build fails if the declared dependency can’t find the JAR file in the dependency declaration above?

It’s fair to assume that Gradle doesn’t have support for this use case at the moment.

Does your POM use pom packaging? That’s worked for me
before using a normal dependency (without the @pom).

Oh, Yeah

I also got it works. For my case, I must include repositories inside my configuration. e.g.:

repositories {
	mavenLocal();
}

or

repositories {
    	mavenCentrall();
    }

Werid.

About using mavenLocal(). You probably already pulled down the artifacts/metadata with Maven before. Gradle doesn’t use the Maven local cache by default.