Exclude transitive POM in gradle

I am trying to exclude org.optaplanner bom Apache Camel import in Gradle. But it is not working as expected and giving me error as:

     Required by:
         project :
      > Could not resolve org.apache.camel:camel-core:2.24.1.
         > Could not parse POM https://<company-repo>/org/apache/camel/camel-core/2.24.1/camel-core-2.24.1.pom
            > Could not resolve org.apache.camel:camel-parent:2.24.1.
               > Could not resolve org.apache.camel:camel-parent:2.24.1.
                  > Could not parse POM https://<company-repo>/org/apache/camel/camel-parent/2.24.1/camel-parent-2.24.1.pom
                     > Could not find org.optaplanner:optaplanner-bom:7.14.0.Final.

I tried excluding as

compile ("org.apache.camel:camel-core:${camelVersion}") {
        exclude group: "org.optaplanner", module: "*"
}

or

compile ("org.apache.camel:camel-core:${camelVersion}") {
            exclude group: "org.optaplanner", module: "optaplanner-bom"
}

and also tried with

configurations {
    compile.exclude group: 'org.optaplanner'
}

Same situation while trying to exclude transitive pom!

Any help is appreciated or alternative way to get rid of this error!

FYI

Gradle 5.1.1

Java 1.8

Apache Camel 2.24.1

The exclude methods you are attempting are for excluding dependencies, not parent POMs or BOMs. Gradle needs all the parent POMs and BOMs to understand the POM model.

This is a total hack, but I believe that you could hack a bare bones/skeleton/empty pom file and store it in

myHackRepo/org/optaplanner/optaplanner-bom/7.14.0.Final/optaplanner-bom-7.14.0.Final.pom

You could then do

repositories {
   maven {
      uri file('myHackRepo')
   }
   maven {
      uri 'https://<company-repo>'
   }
} 

And gradle should find the empty pom file. I’m guessing you’ll then get errors at this point with version numbers not specified which are supposed to come from the BOM file

@Lance i don’t have word to explain how awesome you are! it perfectly worked as you mentioned!

I needed to use little bit different maven repo spec as:

repositories {
        maven { url "file:libs" }
}

Thanks again!