title: How to use a pom file in the Maven deployer plugin for Gradle?
body: <p>I need to be able to generate a pom file locally and deploy the project to sonatype.<br></p>
  
  <p>Here is how I am doing so:</p>
  
  <pre><code>task createPom {
      doLast {
          pom.project {
              groupId = "com.example"
              //...
          }.writeTo("pom.xml")
      }
  }
  
  uploadArchives {
      repositories {
          mavenDeployer {
              beforeDeployment { MavenDeployment deployment -&gt; signing.signPom(deployment) }
  
              repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
                  authentication(userName: ossrhUsername, password: ossrhPassword)
              }
  
              snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
                  authentication(userName: ossrhUsername, password: ossrhPassword)
              }
  
              pom.project {
                  groupId = "com.example"
                  //...
              }
  
          }
      }
  }
  </code></pre>
  
  <p>As you noticed it doesn't follow the DRY principle as I am writing the same pom file two times. If I need to add or remove any field in the POM file I need to remove it in both places.<br>
  I have an idea. We can say that the <code>uploadArchives</code> task depends on the <code>createPom</code> task like this <code>uploadArchives (dependsOn: createPom)</code>. Now we could generate a POM file and then read when use <code>mavenDeployer</code>. But how to tell <code>mavenDeployer</code> to read pom from the file and not generate default pom file? Or if it is possible to generate global pom variable and use it in both tasks.</p>