[ 
https://issues.apache.org/jira/browse/BEAM-3255?focusedWorklogId=88981&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-88981
 ]

ASF GitHub Bot logged work on BEAM-3255:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 09/Apr/18 15:47
            Start Date: 09/Apr/18 15:47
    Worklog Time Spent: 10m 
      Work Description: swegner commented on a change in pull request #5048: 
[BEAM-3255] Updates to support the release process via Gradle
URL: https://github.com/apache/beam/pull/5048#discussion_r180140165
 
 

 ##########
 File path: build_rules.gradle
 ##########
 @@ -478,65 +475,264 @@ ext.applyJavaNature = {
       }
       testCompile.extendsFrom shadowTest
     }
-
     // Ensure that shaded classes are part of the artifact set.
     artifacts.archives shadowJar
 
-    if (configuration.artifactId) {
-      task sourcesJar(type: Jar) {
-        from sourceSets.main.allSource
-        classifier = 'sources'
+    // TODO: Figure out how to create ShadowJar task for ShadowTestJar here
+    // that is extendable within each sub-project with any additional includes.
+    // This could mirror the "shadowJar" configuration block.
+    // Optionally, we could also copy the shading configuration from the main
+    // source set and apply it here.
+    //
+    // Shading the test jar has a lot less need but can still be beneficial for
+    // resolving class conflicts for tests during test execution or exposing
+    // test libraries for users.
+  }
+
+  task sourcesJar(type: Jar) {
+    from sourceSets.main.allSource
+    classifier = 'sources'
+  }
+  artifacts.archives sourcesJar
+
+  task testSourcesJar(type: Jar) {
+    from sourceSets.test.allSource
+    classifier = 'test-sources'
+  }
+  artifacts.archives testSourcesJar
+
+  task javadocJar(type: Jar, dependsOn: javadoc) {
+    classifier = 'javadoc'
+    from javadoc.destinationDir
+  }
+  artifacts.archives javadocJar
+
+  if (isRelease() || project.hasProperty('publishing')) {
+    apply plugin: "maven-publish"
+
+    // Only sign artifacts if we are performing a release
+    if (isRelease()) {
+      apply plugin: "signing"
+      signing {
+        useGpgCmd()
+        // Drop the unshaded jar because we don't want to publish it.
+        // Otherwise the unshaded one is the only one published since they
+        // both have no classifier and the names conflict.
+        def unshaded = configurations.archives.getArtifacts().matching({
+          artifact -> artifact.classifier == "" })
+        configurations.archives.getArtifacts().removeAll(unshaded)
+        sign configurations.archives
       }
-      task testSourcesJar(type: Jar) {
-        from sourceSets.test.allSource
-        classifier = 'test-sources'
+
+      model {
+        tasks.generatePomFileForMavenJavaPublication {
+          destination = file("$buildDir/generated-pom.xml")
+        }
+        tasks.publishMavenJavaPublicationToMavenLocal {
+          dependsOn project.tasks.signArchives
+        }
+        tasks.publishMavenJavaPublicationToMavenRepository {
+          dependsOn project.tasks.signArchives
+        }
       }
-      task javadocJar(type: Jar, dependsOn: javadoc) {
-        classifier = 'javadoc'
-        from javadoc.destinationDir
+    }
+
+    uploadArchives {
+      repositories {
+        mavenDeployer {
+          beforeDeployment { MavenDeployment deployment -> isRelease() && 
signing.signPom(deployment) }
+        }
       }
+    }
 
-      // If a publication artifact id is supplied, publish the shadow jar.
-      publishing {
-        publications {
-          mavenJava(MavenPublication) {
-            artifact(shadowJar) {
-              groupId "org.apache.beam"
-              artifactId configuration.artifactId
-              // Strip the "shaded" classifier.
-              classifier null
-              // Set readable name to project description.
-              pom.withXml {
-                asNode().appendNode('name', description)
+    publishing {
+      repositories {
+        maven {
+          url(project.properties['distMgmtSnapshotsUrl'] ?: isRelease()
+                  ? 
'https://repository.apache.org/service/local/staging/deploy/maven2'
+                  : 
'https://repository.apache.org/content/repositories/snapshots')
+
+          // We attempt to find and load credentials from ~/.m2/settings.xml 
file that a user
+          // has configured with the Apache release and snapshot staging 
credentials.
+          // <settings>
+          //   <servers>
+          //     <server>
+          //       <id>apache.releases.https</id>
+          //       <username>USER_TOKEN</username>
+          //       <password>PASS_TOKEN</password>
+          //     </server>
+          //     <server>
+          //       <id>apache.snapshots.https</id>
+          //       <username>USER_TOKEN</username>
+          //       <password>PASS_TOKEN</password>
+          //     </server>
+          //   </servers>
+          // </settings>
+          def settingsXml = new File(System.getProperty('user.home'), 
'.m2/settings.xml')
+          if (settingsXml.exists()) {
+            def serverId = (isRelease() ? 'apache.releases.https' : 
'apache.snapshots.https')
+            def m2SettingCreds = new 
XmlSlurper().parse(settingsXml).servers.server.find { server -> 
serverId.equals(server.id.text()) }
+            if (m2SettingCreds) {
+              credentials {
+                username m2SettingCreds.username.text()
+                password m2SettingCreds.password.text()
               }
             }
-            // TODO: Use the shadow test jar here instead of the test jar.
-            artifact packageTests {
-              classifier "tests"
+          }
+        }
+      }
+
+      publications {
+        mavenJava(MavenPublication) {
+          artifact shadowJar {
+            // Strip the "shaded" classifier.
+            classifier null
+          }
+          // TODO: Use the shadow test jar here instead of the test jar.
+          artifact packageTests {
+            classifier "tests"
+          }
+          artifact sourcesJar {
+            classifier "sources"
+          }
+          artifact testSourcesJar {
+            classifier "test-sources"
+          }
+          artifact javadocJar {
+            classifier "javadoc"
+          }
+
+          pom.withXml {
+            def root = asNode()
+            root.appendNode('name', project.description)
+            if (project.hasProperty("summary")) {
+                root.appendNode('description', project.summary)
             }
-            artifact sourcesJar {
-              classifier "sources"
+            root.appendNode('url', POM_URL)
 
 Review comment:
   I saw this setup on another project doing similar maven publishing from 
Gradle.
   
   1. Presumably it gives us the ability to access these variables from other 
places. Although I don't see that as a real use-case.
   2. It removes some of the cruft from the build_rules.gradle file. But it 
would actually be more straightforward to have all the logic in one place.
   
   Eventually I think it'd be cleaner to start with a template pom file with 
all of this filled in rather than build up the XML from code.
   
   But for now, I'll move these settings into build_rules.gradle

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 88981)
    Time Spent: 1h 50m  (was: 1h 40m)

> Update release process to use Gradle
> ------------------------------------
>
>                 Key: BEAM-3255
>                 URL: https://issues.apache.org/jira/browse/BEAM-3255
>             Project: Beam
>          Issue Type: Sub-task
>          Components: build-system
>            Reporter: Luke Cwik
>            Assignee: Alan Myrvold
>            Priority: Major
>          Time Spent: 1h 50m
>  Remaining Estimate: 0h
>
> This task is about configuring Gradle to generate pom's and artifacts 
> required to perform a release and update the nightly release snapshot Jenkins 
> jobs found here 
> https://github.com/apache/beam/blob/master/.test-infra/jenkins/job_beam_Release_NightlySnapshot.groovy
> We will also require some integration tests to run against the released 
> nightly snapshot artifacts to ensure that what was built is valid.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to