Last active
August 29, 2015 14:05
-
-
Save welsh/ddff0ce0a087c82491c2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.regex.Pattern | |
apply plugin : SplitCopyDependenciesPlugin | |
class SplitCopyDependenciesPlugin implements Plugin<Project> { | |
void apply(Project project) { | |
project.extensions.create("splitCopyDependencies", SplitCopyDependenciesPluginExtension) | |
project.task('splitCopyDependencies') << { | |
def frameworkLib = [] | |
def extLib = [] | |
println "" | |
println "Building build/frameworkLib and build/extLib directories..." | |
def pattern = Pattern.quote(System.getProperty("file.separator")) | |
project.configurations.compile.each { File file -> | |
project.copy { | |
from file.absolutePath | |
def groupIdSplit = file.absolutePath.split(pattern) | |
def groupId = groupIdSplit[groupIdSplit.length - 5] | |
if(project.splitCopyDependencies.exactMatch) { | |
if(groupId.equals(project.splitCopyDependencies.frameworkGroup)) { | |
frameworkLib.add(file) | |
into 'build/frameworkLib' | |
} else { | |
extLib.add(file) | |
into 'build/extLib' | |
} | |
} else { | |
if(groupId.contains(project.splitCopyDependencies.frameworkGroup)) { | |
frameworkLib.add(file) | |
into 'build/frameworkLib' | |
} else { | |
extLib.add(file) | |
into 'build/extLib' | |
} | |
} | |
} | |
} | |
println "Built." | |
println "" | |
println "build/frameworkLib Contents:" | |
frameworkLib.each { File file -> println "\t" + file.name } | |
println "" | |
println "build/extLib Contents:" | |
extLib.each { File file -> println "\t" + file.name } | |
} | |
} | |
} | |
class SplitCopyDependenciesPluginExtension { | |
String frameworkGroup | |
boolean exactMatch | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment