title: How to build Groovy JAR w/ Gradle and publish it to in-house repo
body: <p>I have a Groovy project and am trying to build it with Gradle. First I want a <code>package</code> task that creates a JAR by compiling it against its dependencies. Then I need to generate a Maven POM for that JAR and publish the JAR/POM to an in-house Artifactory repo. The <code>build.gradle</code>:</p>
  
  <pre><code>apply plugin: "groovy"
  apply plugin: "maven-publish"
  
  repositories {
      maven {
          name "artifactory01"
          url "http://myartifactory/artifactory/libs-release"
      }
  }
  dependencies {
      compile "long list starts here"
  }
  
  // Should compile up myapp-&lt;version&gt;.jar
  jar {
  }
  
  // Should publish myapp-&lt;version&gt;.jar and its (generated) POM to our in-house Maven/Artifactory repo.
  publishing {
      publications {
          myPublication(MavenPublication) {
              from components.java
              artifact sourceJar {
                  classifier "source"
              }
  
              pom.withXml {
                  // ???
              }
          }
      }
  }
  
  task wrapper(type: Wrapper) {
      gradleVersion = '1.11'
  }
  </code></pre>
  
  <p>However I do not believe I have set up versioning correctly with my <code>jar</code> task (for instance, how could I get it creating <code>myapp-1.2.1</code> vs. <code>myapp-1.2.2</code>? I also don't think I have my <code>publications</code> configuration set up correctly: what should go in <code>pom.withXml</code>?</p>