You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by pr...@apache.org on 2019/02/09 00:10:23 UTC

[geode] branch develop updated: GEODE-6323 Fix dependency tracking for manifest jars (#3126)

This is an automated email from the ASF dual-hosted git repository.

prhomberg pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git


The following commit(s) were added to refs/heads/develop by this push:
     new bcd82ae  GEODE-6323 Fix dependency tracking for manifest jars (#3126)
bcd82ae is described below

commit bcd82ae18e621c749e0512b618a4422aacb92b3c
Author: Robert Houghton <rh...@pivotal.io>
AuthorDate: Fri Feb 8 16:10:00 2019 -0800

    GEODE-6323 Fix dependency tracking for manifest jars (#3126)
    
    Because `doFirst` registers an action to be executed, it is not valid to be used as part of a task's configuration, causing aberrant behavior when combined with Gradle's output caching.
    
    If "configuration" must occur at execution time, then that configuration needs to be the output of a task on which the "configured" task depends.  We have done that here to correctly generate the classpath in our dependency jars.  For more information, see
    https://guides.gradle.org/using-build-cache/#suggestions_for_authoring_your_build
    
    Co-authored-by: Robert Houghton <rh...@pivotal.io>
    Co-authored-by: Patrick Rhomberg <pr...@pivotal.io>
---
 geode-assembly/build.gradle | 62 +++++++++++++++++++++++++++++++++------------
 1 file changed, 46 insertions(+), 16 deletions(-)

diff --git a/geode-assembly/build.gradle b/geode-assembly/build.gradle
index db01c2d..1a1da28 100755
--- a/geode-assembly/build.gradle
+++ b/geode-assembly/build.gradle
@@ -16,7 +16,7 @@
  */
 
 
-import java.nio.file.Paths 
+import java.nio.file.Paths
 
 evaluationDependsOn(":geode-core")
 
@@ -164,7 +164,7 @@ dependencies {
     exclude module: 'geode-core'
   }
   testRuntime(project(':geode-old-versions'))
-  
+
 
   acceptanceTestRuntime(project(':geode-old-versions'))
 
@@ -237,7 +237,7 @@ dependencies {
   webServerTomcat8('org.apache.tomcat:tomcat:' + project.'tomcat8.version' + '@zip')
   webServerTomcat9('org.apache.tomcat:tomcat:' + project.'tomcat9.version' + '@zip')
   webServerJetty('org.eclipse.jetty:jetty-distribution:' + project.'jetty.version' + '@zip')
-  
+
   gfshDependencies ('org.springframework:spring-web') {
     exclude module: 'spring-core'
     exclude module: 'commons-logging'
@@ -266,7 +266,7 @@ task defaultCacheConfig(type: JavaExec, dependsOn: classes) {
   }
 }
 
-// This closure sets the gemfire classpath.  If we add another jar to the classpath it must
+// This closure sets the geode classpath.  If we add another jar to the classpath it must
 // be included in the filter logic below.
 def cp = {
   // first add all the dependent project jars
@@ -305,34 +305,64 @@ def cp = {
   return jars.plus(depJars).unique().join(' ')
 }
 
-// Note: this dependency doesn't work if you change a library version from
-// a dependent project.  Please fix me.
-task depsJar (type: Jar, dependsOn: ':geode-core:classes') {
+task configureDepsJar(dependsOn: configurations.archives.dependencies) {
+  def output = project.buildDir.toPath().resolve('reports').resolve('deps_jar_cp.txt')
+  outputs.file {
+    output
+  }
+  doLast {
+    output.write(cp())
+  }
+}
+
+task configureGfshDepsJar(dependsOn: configurations.gfshDependencies.dependencies) {
+  inputs.files {
+    configureDepsJar
+  }
+  inputs.files {
+    project(':geode-core').webJar
+  }
+
+  def output = project.buildDir.toPath().resolve('reports').resolve('gfsh_deps_jar_cp.txt')
+  outputs.file {
+    output
+  }
+  doLast {
+    def classpath = configureDepsJar.outputs.files.singleFile.text + ' ' +
+        project(':geode-core').webJar.archiveName + ' ' +
+        configurations.gfshDependencies.collect { it.getName() }.flatten().join(' ')
+    output.write(classpath)
+  }
+}
+
+// Configure the manifest contents in a separate always-running task to ensure correctness of
+// these dependency jars
+task depsJar (type: Jar) {
+  inputs.files {
+    configureDepsJar
+  }
   description 'Assembles the jar archive that defines the gemfire classpath.'
   archiveName 'geode-dependencies.jar'
   doFirst {
     manifest {
-      attributes("Class-Path": cp())
+      attributes("Class-Path": configureDepsJar.outputs.files.singleFile.text)
     }
   }
 }
 
-// Note: this dependency doesn't work if you change a library version from
-// a dependent project.  Please fix me.
-task gfshDepsJar (type: Jar, dependsOn: ':geode-core:classes') {
+task gfshDepsJar (type: Jar) {
+  inputs.files {
+    configureGfshDepsJar
+  }
   description 'Assembles the jar archive that defines the gfsh classpath.'
   archiveName 'gfsh-dependencies.jar'
   doFirst {
     manifest {
-      attributes("Class-Path": cp() +
-        ' ' + project(':geode-core').webJar.archiveName +
-        ' ' + configurations.gfshDependencies.collect{ it.getName() }.flatten().join(' ')
-      )
+      attributes("Class-Path": configureGfshDepsJar.outputs.files.singleFile.text)
     }
   }
 }
 
-
 def docsDir = file("$buildDir/javadocs")
 task docs(type: Javadoc) {
   options.addStringOption('Xdoclint:none', '-quiet')