mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Clean up apt work.
This commit is contained in:
parent
e494e1a6b4
commit
f616bcee17
1 changed files with 36 additions and 20 deletions
|
@ -22,24 +22,25 @@ import javax.inject.Singleton
|
||||||
* (outputDir, etc...).
|
* (outputDir, etc...).
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, val configActor: ConfigActor<AptConfig>,
|
class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, val compilerUtils: CompilerUtils)
|
||||||
val compilerUtils: CompilerUtils)
|
: BasePlugin(), ICompilerFlagContributor, ISourceDirectoryContributor, ITaskContributor {
|
||||||
: BasePlugin(), ICompilerFlagContributor, ISourceDirectoryContributor, ITaskContributor,
|
|
||||||
IConfigActor<AptConfig> by configActor {
|
|
||||||
|
|
||||||
// ISourceDirectoryContributor
|
// ISourceDirectoryContributor
|
||||||
|
|
||||||
override fun sourceDirectoriesFor(project: Project, context: KobaltContext): List<File> {
|
override fun sourceDirectoriesFor(project: Project, context: KobaltContext): List<File> {
|
||||||
val config = configurationFor(project)
|
val result = arrayListOf<File>()
|
||||||
val result =
|
aptConfigs[project.name]?.let { config ->
|
||||||
if (config != null) {
|
result.add(File(
|
||||||
listOf(File(
|
|
||||||
KFiles.joinDir(project.directory,
|
KFiles.joinDir(project.directory,
|
||||||
KFiles.KOBALT_BUILD_DIR,
|
KFiles.KOBALT_BUILD_DIR,
|
||||||
config.outputDir,
|
config.outputDir)))
|
||||||
context.variant.toIntermediateDir())))
|
}
|
||||||
} else {
|
|
||||||
emptyList()
|
kaptConfigs[project.name]?.let { config ->
|
||||||
|
result.add(File(
|
||||||
|
KFiles.joinDir(project.directory,
|
||||||
|
KFiles.KOBALT_BUILD_DIR,
|
||||||
|
config.outputDir)))
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -48,6 +49,7 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va
|
||||||
companion object {
|
companion object {
|
||||||
const val PLUGIN_NAME = "Apt"
|
const val PLUGIN_NAME = "Apt"
|
||||||
const val KAPT_CONFIG = "kaptConfig"
|
const val KAPT_CONFIG = "kaptConfig"
|
||||||
|
const val APT_CONFIG = "aptConfig"
|
||||||
}
|
}
|
||||||
|
|
||||||
override val name = PLUGIN_NAME
|
override val name = PLUGIN_NAME
|
||||||
|
@ -93,7 +95,6 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va
|
||||||
listOf())
|
listOf())
|
||||||
|
|
||||||
val results = compilerUtils.invokeCompiler(project, context, javaCompiler, info)
|
val results = compilerUtils.invokeCompiler(project, context, javaCompiler, info)
|
||||||
println("RESULTS: $results")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,13 +109,22 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va
|
||||||
|
|
||||||
val result = arrayListOf<String>()
|
val result = arrayListOf<String>()
|
||||||
|
|
||||||
configurationFor(project)?.let { config ->
|
fun addFlags(outputDir: String) {
|
||||||
aptDependencies[project.name]?.let { aptDependencies ->
|
aptDependencies[project.name]?.let { aptDependencies ->
|
||||||
result.add("-s")
|
result.add("-s")
|
||||||
result.add(generated(project, context, config.outputDir))
|
result.add(generated(project, context, outputDir))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
aptConfigs[project.name]?.let { config ->
|
||||||
|
addFlags(config.outputDir)
|
||||||
|
}
|
||||||
|
|
||||||
|
kaptConfigs[project.name]?.let { config ->
|
||||||
|
addFlags(config.outputDir)
|
||||||
|
}
|
||||||
|
|
||||||
log(2, "New flags from apt: " + result.joinToString(" "))
|
log(2, "New flags from apt: " + result.joinToString(" "))
|
||||||
}
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,8 +134,14 @@ class AptPlugin @Inject constructor(val dependencyManager: DependencyManager, va
|
||||||
aptDependencies.put(dependencies.project.name, it)
|
aptDependencies.put(dependencies.project.name, it)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val aptConfigs: HashMap<String, AptConfig> = hashMapOf()
|
||||||
private val kaptConfigs: HashMap<String, KaptConfig> = hashMapOf()
|
private val kaptConfigs: HashMap<String, KaptConfig> = hashMapOf()
|
||||||
|
|
||||||
|
fun addAptConfig(project: Project, kapt: AptConfig) {
|
||||||
|
project.projectProperties.put(APT_CONFIG, kapt)
|
||||||
|
aptConfigs.put(project.name, kapt)
|
||||||
|
}
|
||||||
|
|
||||||
fun addKaptConfig(project: Project, kapt: KaptConfig) {
|
fun addKaptConfig(project: Project, kapt: KaptConfig) {
|
||||||
project.projectProperties.put(KAPT_CONFIG, kapt)
|
project.projectProperties.put(KAPT_CONFIG, kapt)
|
||||||
kaptConfigs.put(project.name, kapt)
|
kaptConfigs.put(project.name, kapt)
|
||||||
|
@ -138,7 +154,7 @@ class AptConfig(var outputDir: String = "generated/source/apt")
|
||||||
fun Project.apt(init: AptConfig.() -> Unit) {
|
fun Project.apt(init: AptConfig.() -> Unit) {
|
||||||
AptConfig().let {
|
AptConfig().let {
|
||||||
it.init()
|
it.init()
|
||||||
(Kobalt.findPlugin(AptPlugin.PLUGIN_NAME) as AptPlugin).addConfiguration(this, it)
|
(Kobalt.findPlugin(AptPlugin.PLUGIN_NAME) as AptPlugin).addAptConfig(this, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue