Created
May 24, 2017 12:24
-
-
Save Zellius/5c21f40fb0c297128850df4077fcb6d9 to your computer and use it in GitHub Desktop.
Copy classes from 'core' module to other modules
This file contains 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
//copy core classes to the project gen folder | |
def includeCoreClasses = { Project p -> | |
p.android.libraryVariants.all { variant -> | |
def outputDir = p.file("$p.buildDir/generated/core/${variant.dirName}") | |
def packageName = variant.generateBuildConfig.appPackageName | |
def mergeTask = p.tasks.create(name: "merge${variant.name.capitalize()}CoreClasses", type: Copy) { | |
from(project(':core').android.sourceSets.main.java.srcDirs) { | |
filter { String line -> | |
if (line == 'package ru.solodovnikov.rxlocationmanager') { | |
"package $packageName" | |
} else { | |
line | |
} | |
} | |
eachFile { | |
path = "${packageName.replaceAll('\\.', '/')}/$name" | |
} | |
} | |
into outputDir | |
} | |
variant.registerJavaGeneratingTask mergeTask, outputDir | |
} | |
} | |
project(':rxlocationmanager') { | |
includeCoreClasses(it) | |
} | |
project(':rxlocationmanager-rxjava2') { | |
includeCoreClasses(it) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment