geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From upthewatersp...@apache.org
Subject geode git commit: GEODE-2434: Generate old version classpaths in doLast
Date Tue, 07 Feb 2017 17:00:38 GMT
Repository: geode
Updated Branches:
  refs/heads/develop 1d5ae68ef -> 77c1c6e1d


GEODE-2434: Generate old version classpaths in doLast

The geode-old-versions/build.gradle was generating the classpath
properties file during the build configuration phase, rather than the
execution phase.

Also converting the file to an actual properties file so that it will
handle special characters properly.


Project: http://git-wip-us.apache.org/repos/asf/geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/geode/commit/77c1c6e1
Tree: http://git-wip-us.apache.org/repos/asf/geode/tree/77c1c6e1
Diff: http://git-wip-us.apache.org/repos/asf/geode/diff/77c1c6e1

Branch: refs/heads/develop
Commit: 77c1c6e1d9aa0afa4a9c86e82c56c782365888c4
Parents: 1d5ae68
Author: Dan Smith <upthewaterspout@apache.org>
Authored: Mon Feb 6 15:00:48 2017 -0800
Committer: Dan Smith <upthewaterspout@apache.org>
Committed: Tue Feb 7 08:55:41 2017 -0800

----------------------------------------------------------------------
 .../test/dunit/standalone/VersionManager.java   | 40 +++++++-------
 geode-old-versions/build.gradle                 | 57 +++++++++-----------
 2 files changed, 43 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/geode/blob/77c1c6e1/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/VersionManager.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/VersionManager.java
b/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/VersionManager.java
index 7bda948..c06d4e8 100755
--- a/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/VersionManager.java
+++ b/geode-core/src/test/java/org/apache/geode/test/dunit/standalone/VersionManager.java
@@ -19,13 +19,17 @@ import org.apache.geode.test.dunit.VM;
 
 import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Properties;
 
 /**
  * VersionManager loads the class-paths for all of the releases of Geode configured for
@@ -106,17 +110,19 @@ public class VersionManager {
 
   private void findVersions() {
     // this file is created by the gradle task createClasspathsPropertiesFile
-    File propFile = new File("../../../geode-old-versions/build/geodeOldVersionClasspaths.txt");
+    File propFile = new File(
+        "../../../geode-old-versions/build/generated-resources/main/geodeOldVersionClasspaths.txt");
     if (!propFile.exists()) {
       // running under an IDE
-      propFile = new File("../geode-old-versions/build/geodeOldVersionClasspaths.txt");
+      propFile = new File(
+          "../geode-old-versions/build/generated-resources/main/geodeOldVersionClasspaths.txt");
     }
     String oldver = "ZZZ";
     if (propFile.exists()) {
       System.out.println("found geodeOldVersionClasspaths.txt - loading properties");
-      Map<String, String> dunitProperties = loadProperties(propFile);
-      for (Map.Entry<String, String> entry : dunitProperties.entrySet()) {
-        String version = entry.getKey();
+      Properties dunitProperties = loadProperties(propFile);
+      for (Map.Entry<Object, Object> entry : dunitProperties.entrySet()) {
+        String version = (String) entry.getKey();
         if (version.startsWith("test") && version.length() >= "test".length())
{
           if (version.equals("test")) {
             version = CURRENT_VERSION;
@@ -126,7 +132,7 @@ public class VersionManager {
               oldver = version;
             }
           }
-          classPaths.put(version, entry.getValue());
+          classPaths.put(version, (String) entry.getValue());
           testVersions.add(version);
         }
       }
@@ -146,23 +152,15 @@ public class VersionManager {
    * Properties.load() because that method interprets back-slashes as escape characters,
causing
    * class-paths on Windows machines to be garbled.
    */
-  private Map<String, String> loadProperties(File propFile) {
-    Map<String, String> dunitProperties = new HashMap<>();
-    try {
-      String propertyLine;
-      FileReader reader = new FileReader(propFile);
-      BufferedReader breader = new BufferedReader(reader);
-      while ((propertyLine = breader.readLine()) != null) {
-        propertyLine = propertyLine.trim();
-        if (propertyLine.length() != 0 || !propertyLine.startsWith("#")) {
-          String[] split = propertyLine.split("=");
-          dunitProperties.put(split[0], split[1]);
-        }
-      }
+  private Properties loadProperties(File propFile) {
+    Properties props = new Properties();
+    try (FileReader reader = new FileReader(propFile)) {
+      props.load(reader);
     } catch (IOException e) {
-      e.printStackTrace();
+      throw new RuntimeException(e);
     }
-    return dunitProperties;
+
+    return props;
   }
 
 

http://git-wip-us.apache.org/repos/asf/geode/blob/77c1c6e1/geode-old-versions/build.gradle
----------------------------------------------------------------------
diff --git a/geode-old-versions/build.gradle b/geode-old-versions/build.gradle
index a09b2d7..9aff3d2 100644
--- a/geode-old-versions/build.gradle
+++ b/geode-old-versions/build.gradle
@@ -18,7 +18,7 @@
 
 disableMavenPublishing()
 
-def addTestSource(def source, def geodeVersion, def includeEclipse) {
+def addTestSource(def source, def geodeVersion) {
 //  def sourceSet =
   sourceSets.create(source, {
     compileClasspath += configurations.provided
@@ -33,45 +33,36 @@ def addTestSource(def source, def geodeVersion, def includeEclipse) {
   dependencies.add "${source}Compile", "org.apache.geode:geode-cq:$geodeVersion"
   dependencies.add "${source}Compile", "org.apache.geode:geode-rebalancer:$geodeVersion"
 
-  dependencies.add "${source}Compile", sourceSets.test.output
+}
+
+// Add sourceSets for backwards compatibility, rolling upgrade, and
+// pdx testing.
+addTestSource('test100', '1.0.0-incubating')
+//addTestSource('test110', '1.1.0')
 
-//  dependencies.add "${source}Compile", configurations.testCompile
-//  dependencies.add "${source}Runtime", configurations.testRuntime
+def generatedResources = "$buildDir/generated-resources/main"
 
-  if(!includeEclipse) {
-    eclipse {
-      classpath {
-        file {
-          //Manually remove the source directory from the generated
-          //classpath I could not get this to work with minusConfigurations
-          whenMerged { classpath ->
-            classpath.entries.removeAll {
-              entry -> entry.kind == 'src' && entry.path == "src/${source}/java"
-            }
-          }
-        }
-      }
-    }
+sourceSets {
+  main {
+    output.dir(generatedResources, builtBy: 'createGeodeClasspathsFile')
   }
 }
 
-// Add sourceSets for backwards compatibility, rolling upgrade, and
-// pdx testing.
-addTestSource('test100', '1.0.0-incubating', true)
-//addTestSource('test110', '1.1.0', true)
+task createGeodeClasspathsFile  {
+  File classpathsFile = file("$generatedResources/geodeOldVersionClasspaths.txt")
+  outputs.file(classpathsFile);
+
+  doLast {
+    Properties versions = new Properties();
+    project(':geode-old-versions').sourceSets.each {
+      versions.setProperty(it.name,it.runtimeClasspath.getAsPath()) 
+    }
 
+    classpathsFile.getParentFile().mkdirs();
 
-task createGeodeClasspathsFile {
-    File dir = file("$buildDir");
-    if (!dir.exists()) { dir.mkdirs() }
-    File classpathsFile = file("$buildDir/geodeOldVersionClasspaths.txt")
-    if (classpathsFile.exists()) {
-        classpathsFile.delete();
+    new FileOutputStream(classpathsFile).withStream { fos ->
+      versions.store(fos, '')
     }
-    classpathsFile.createNewFile();
-    // add other backward-compatibility projects here
-    project(':geode-old-versions').sourceSets.each {
-        classpathsFile.append(it.name+"="+it.runtimeClasspath.getAsPath()+"\n") }
+  }
 }
 
-createGeodeClasspathsFile


Mime
View raw message