Gradle getting Permgen errors when building many projects

Hi,

I am using https://github.com/akhikhl/multiproject-git-gradle to build and release multiple Gradle projects, it works for like building 3-4 repos. As soon as i add more repos i get a Heap Dump. I would really appreciate any help on how i can fix these errors as i am out of ideas.

Here is the build.gradle https://github.com/akhikhl/multiproject-git-gradle/blob/master/build.gradle

I have the following in my gradle.properties (I just tried bumping up memory as much as i could just to see if it works. but fails every time.) This was the max i tried.

Also i am running with --no-daemon flag

GRADLE_OPTS="-Xms2048m -XX:+CMSClassUnloadingEnabled -XX:+HeapDumpOnOutOfMemoryError -XX:+CMSPermGenSweepingEnabled”

and in gradlew file

#!/usr/bin/env bash
  ##############################################################################
##
##
Gradle start up script for UN*X
##
##############################################################################
  # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
GRADLE_OPTS="-XX:MaxPermSize=7168m -Xmx12288m $GRADLE_OPTS"
DEFAULT_JVM_OPTS=""
  APP_NAME="Gradle"

Error code.

00:16:46.480 - :project2_releaseBuildNewVersionjava.lang.OutOfMemoryError: PermGen space
00:16:57.201 - Dumping heap to java_pid21851.hprof ...
00:17:00.093 - Heap dump file created [338646489 bytes in 2.892 secs]
00:17:07.772 -
FAILED
00:17:18.642 -
 00:17:18.642 - Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "main"
04:58:58.832 - Build was aborted