You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by ta...@apache.org on 2016/07/14 13:12:24 UTC

svn commit: r1752658 - in /ofbiz/trunk: build.gradle settings.gradle

Author: taher
Date: Thu Jul 14 13:12:24 2016
New Revision: 1752658

URL: http://svn.apache.org/viewvc?rev=1752658&view=rev
Log:
Fix multiple flaws in the build scripts (mostly OS) related - OFBIZ-7779

Thank you Jacques Le Roux for reporting this! This commit achieves the
following improvements:

- refactor the code for the settings to make it more organized
  by moving blocks of code into more appropriate locations in
  the build script
- Remove the exclusion on a library that is no longer necessary
  thanks to work done by Gil Portenseigne to remove these libraries
- refactor settings.gradle to define projects in an OS independent way.
  I realized that the projects were improperly defined in windows
  which makes their count 49 as opposed to 52 projects on other OSes
- Introduce regex expressions to properly format the .classpath file
  for eclipse. The regex expressions makes identifying the unwanted
  items possible for all OSes

Luckily Jacques Le Roux uses Windows OS and as he was testing the framework
with eclipse he reported imporper path settings generated by the gradle
eclipse task.

Upon investigation, we realized multiple problems exist in the build scripts
relating to operating-system specific path delimiters. All tests pass
on both windows and Linux and eclipse is not complaining on either OS
from the .classpath generated file. Hence committing.


Modified:
    ofbiz/trunk/build.gradle
    ofbiz/trunk/settings.gradle

Modified: ofbiz/trunk/build.gradle
URL: http://svn.apache.org/viewvc/ofbiz/trunk/build.gradle?rev=1752658&r1=1752657&r2=1752658&view=diff
==============================================================================
--- ofbiz/trunk/build.gradle (original)
+++ ofbiz/trunk/build.gradle Thu Jul 14 13:12:24 2016
@@ -25,11 +25,22 @@ import org.apache.tools.ant.filters.Repl
 apply plugin: 'java'
 apply plugin: 'eclipse'
 
+// java settings
+def jvmArguments = ['-Xms128M', '-Xmx512M']
+ext.ofbizMainClass = 'org.ofbiz.base.start.Start'
+javadoc.failOnError = false
+sourceCompatibility = '1.8'
+targetCompatibility = '1.8'
+
+// root and subproject settings
+defaultTasks 'build'
+
 allprojects {
     repositories{
         jcenter()
     }
 }
+
 subprojects {
     configurations {
         // compile-time plugin libraries
@@ -39,16 +50,11 @@ subprojects {
     }
 }
 
-defaultTasks 'build'
-
-sourceCompatibility = '1.8'
-targetCompatibility = '1.8'
-
 configurations {
     junitLibs
 }
-dependencies {
 
+dependencies {
     // general framework libs
     compile 'apache-httpclient:commons-httpclient:3.1'
     compile 'apache-xerces:resolver:2.9.1'
@@ -159,6 +165,7 @@ dependencies {
     compile 'org.hamcrest:hamcrest-all:1.3'
     compile 'org.jdom:jdom:1.1'
     compile 'org.lucee:commons-lang:2.6.0'
+    compile 'org.owasp.esapi:esapi:2.1.0'
     compile 'org.slf4j:slf4j-api:1.6.4'
     compile 'org.springframework:spring-core:4.2.3.RELEASE'
     compile 'org.springframework:spring-test:4.2.3.RELEASE'
@@ -170,10 +177,6 @@ dependencies {
     compile 'xml-apis:xml-apis-ext:1.3.04'
     compile 'xml-apis:xml-apis:1.4.01'
 
-    compile ('org.owasp.esapi:esapi:2.1.0') {
-        exclude group: 'org.beanshell', module: 'bsh-core'
-    }
-
     // plugin libs
     subprojects.each { subProject ->
         compile project(path: subProject.path, configuration: 'pluginLibsCompile')
@@ -231,9 +234,6 @@ sourceSets {
     }
 }
 
-def jvmArguments = ['-Xms128M', '-Xmx512M']
-ext.ofbizMainClass = 'org.ofbiz.base.start.Start'
-
 jar {
     manifest {
         attributes(
@@ -244,7 +244,52 @@ jar {
     }
 }
 
-javadoc.failOnError = false
+// Eclipse plugin settings
+eclipse.classpath.file.whenMerged { classpath ->
+    /* The code inside this block removes unnecessary entries
+     * in the .classpath file which are generated automatically
+     * due to the settings in the sourceSets block
+     */
+    def osName = System.getProperty('os.name').toLowerCase()
+    def osDirSeparator = osName.contains('windows') ? '\\' : '/'
+
+    iterateOverActiveComponents { component ->
+        def componentName = component.toString() - rootDir.toString()
+        classpath.entries.removeAll { entry ->
+            // remove any "src" entries in .classpath of the form /componentName
+            entry.kind == 'src' &&
+            entry.path ==~ '.*/+(' + componentName.tokenize(osDirSeparator).last() + ')$'
+        }
+    }
+    classpath.entries.removeAll { entry ->
+        /* remove "src" entries in .classpath named: 
+         *   /framework, /applications, /specialpurpose and /hot-deploy 
+         */
+        entry.kind == 'src' &&
+            entry.path ==~ /(\/+framework)$/ ||
+            entry.path ==~ /(\/+applications)$/ ||
+            entry.path ==~ /(\/+specialpurpose)$/ ||
+            entry.path ==~ /(\/+hot-deploy)$/
+    }
+    getDirectoryInActiveComponentsIfExists('config').each { configDir ->
+        /* remove any "src" entries in .classpath of the form componentName/config
+         *
+         * windows format: \framework\base\config
+         * Unix format: /framework/base/config
+         * .classpath format: framework/base/config
+         *
+         * Must convert both windows and unix to .classpath format to
+         * be able to remove it from the file
+         */
+        def relativeDir = configDir.toString() - rootDir.toString() - osDirSeparator
+        def eclipseConfigSrc = osName.contains('windows') ? relativeDir.replaceAll("\\\\", "/") : relativeDir
+        classpath.entries.removeAll { entry ->
+            entry.kind == 'src' && 
+            entry.path == eclipseConfigSrc
+        }
+    }
+}
+tasks.eclipse.dependsOn(cleanEclipse)
 
 /* ========================================================
  * Tasks
@@ -522,28 +567,6 @@ gradle.taskGraph.afterTask { Task task,
     }
 }
 
-// remove sources of subprojects since compilation is centralized
-eclipse.classpath.file.whenMerged { classpath ->
-    iterateOverActiveComponents { component ->
-        classpath.entries.removeAll { entry ->
-            entry.kind == 'src' && entry.path == '/' + component.toString().tokenize('/').last()
-        }
-    }
-    classpath.entries.removeAll { entry ->
-        entry.kind == 'src' &&
-            entry.path == '/framework' ||
-            entry.path == '/applications' ||
-            entry.path == '/specialpurpose'
-    }
-    getDirectoryInActiveComponentsIfExists('config').each { configDir ->
-        classpath.entries.removeAll { entry ->
-            entry.kind == 'src' && entry.path == (configDir.toString() - rootDir.toString() - '/')
-        }
-    }
-}
-// remove eclipse files before regenerating them
-tasks.eclipse.dependsOn(cleanEclipse)
-
 // ========== Clean up tasks ==========
 task cleanCatalina(group: cleanupGroup, description: 'Clean Catalina data in runtime/catalina/work') << {
     delete "${rootDir}/runtime/catalina/work"

Modified: ofbiz/trunk/settings.gradle
URL: http://svn.apache.org/viewvc/ofbiz/trunk/settings.gradle?rev=1752658&r1=1752657&r2=1752658&view=diff
==============================================================================
--- ofbiz/trunk/settings.gradle (original)
+++ ofbiz/trunk/settings.gradle Thu Jul 14 13:12:24 2016
@@ -39,6 +39,8 @@ def iterateOverActiveComponents(applyFun
 }
 
 iterateOverActiveComponents { File component ->
+    def osName = System.getProperty('os.name').toLowerCase()
+    def osDirSeparator = osName.contains('windows') ? "\\\\" : "/"
     def subProject = (component.toString() - rootDir)
-    include subProject.replaceAll('/', ':')
+    include subProject.replaceAll(osDirSeparator, ':')
 }