Gradle is not adding dependencies to generated POM file

I am using Gradle 4.5.1 in wrapper mode to build my app. The app is a simple module which generates a JAR artifact.

I have these dependencies defined under dependencies as compile configuration. The POM task is defined as this:

task writePom << {
	conf2ScopeMappings.mappings.remove(configurations.testCompile)
	conf2ScopeMappings.mappings.remove(configurations.testRuntime)
	pom {
	}.writeTo("$buildDir/libs/pom.xml")
}
assemble.dependsOn writePom

The build goes through, but the content there’s no content generated in POM.

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.demo</groupId>
  <artifactId>core-module</artifactId>
  <version>1.0-SNAPSHOT</version>
</project>

Can anybody help what’s going on?

I’m not sure if this is similar, but I used the below to add something to the POM that was uploaded inside publishing.publications.maven :

 pom.withXml {
        asNode().appendNode('description', '{"GitHash":"' + "${revision}" + '"}')
      }