mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Fix bogus app/ directories.
This commit is contained in:
parent
cf1ebb29bb
commit
88ac8ed492
4 changed files with 30 additions and 24 deletions
|
@ -3,7 +3,6 @@ package com.beust.kobalt
|
|||
import com.beust.kobalt.api.*
|
||||
import com.beust.kobalt.misc.KFiles
|
||||
import com.beust.kobalt.misc.log
|
||||
import com.beust.kobalt.misc.warn
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
|
@ -53,11 +52,17 @@ class Variant(val initialProductFlavor: ProductFlavorConfig? = null,
|
|||
}
|
||||
|
||||
fun archiveName(project: Project, archiveName: String?, suffix: String) : String {
|
||||
val result =
|
||||
if (isDefault) {
|
||||
archiveName ?: project.name + "-" + project.version + suffix
|
||||
} else {
|
||||
val base = if (archiveName != null) archiveName.substring(0, archiveName.length - suffix.length)
|
||||
else project.name + "-" + project.version
|
||||
val result: String =
|
||||
base + "-${productFlavor.name}" + "-${buildType.name}"
|
||||
|
||||
result
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
|
@ -132,7 +137,6 @@ class Variant(val initialProductFlavor: ProductFlavorConfig? = null,
|
|||
|
||||
fun toIntermediateDir() : String {
|
||||
if (isDefault) {
|
||||
warn("DEFAULT VARIANT NOT IMPLEMENTED")
|
||||
return ""
|
||||
} else {
|
||||
return KFiles.joinDir(productFlavor.name, buildType.name)
|
||||
|
|
|
@ -43,7 +43,7 @@ fun Project.android(init: AndroidConfig.() -> Unit) : AndroidConfig {
|
|||
@Singleton
|
||||
public class AndroidPlugin @Inject constructor(val javaCompiler: JavaCompiler, val merger: Merger)
|
||||
: ConfigPlugin<AndroidConfig>(), IClasspathContributor, IRepoContributor, ICompilerFlagContributor,
|
||||
ICompilerInterceptor, ISourceDirectoriesIncerceptor, IBuildDirectoryIncerceptor {
|
||||
ICompilerInterceptor, IBuildDirectoryIncerceptor {
|
||||
override val name = "android"
|
||||
|
||||
fun isAndroid(project: Project) = configurationFor(project) != null
|
||||
|
@ -347,22 +347,27 @@ public class AndroidPlugin @Inject constructor(val javaCompiler: JavaCompiler, v
|
|||
|
||||
// IBuildDirectoryInterceptor
|
||||
override fun intercept(project: Project, context: KobaltContext, buildDirectory: String): String {
|
||||
if (isAndroid(project)) {
|
||||
val result = KFiles.joinDir(AndroidFiles.intermediates(project), "classes",
|
||||
context.variant.toIntermediateDir())
|
||||
return result
|
||||
} else {
|
||||
return buildDirectory
|
||||
}
|
||||
|
||||
// ISourceDirectoriesInterceptor
|
||||
override fun intercept(project: Project, context: KobaltContext, sourceDirectories: List<File>): List<File> {
|
||||
return sourceDirectories.map { File("app", it.path)}
|
||||
}
|
||||
|
||||
// ICompilerInterceptor
|
||||
override fun intercept(project: Project, context: KobaltContext, actionInfo: CompilerActionInfo)
|
||||
: CompilerActionInfo {
|
||||
val result: CompilerActionInfo =
|
||||
if (isAndroid(project)) {
|
||||
val newOutputDir = KFiles.joinDir("kobaltBuild", "intermediates", "classes",
|
||||
context.variant.toIntermediateDir())
|
||||
return actionInfo.copy(outputDir = File(newOutputDir))
|
||||
actionInfo.copy(outputDir = File(newOutputDir))
|
||||
} else {
|
||||
actionInfo
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ class Merger @Inject constructor() {
|
|||
private fun mergeAndroidManifest(project: Project, variant: Variant) {
|
||||
val dest = AndroidFiles.mergedManifest(project, variant)
|
||||
log(1, "Manifest merging not implemented, copying it to $dest")
|
||||
KFiles.copy(Paths.get("app/src/main/AndroidManifest.xml"), Paths.get(dest))
|
||||
KFiles.copy(Paths.get("src/main/AndroidManifest.xml"), Paths.get(dest))
|
||||
}
|
||||
|
||||
interface IFileMerger {
|
||||
|
@ -101,11 +101,11 @@ class Merger @Inject constructor() {
|
|||
*/
|
||||
private fun mergeResources(project: Project, variant: Variant) {
|
||||
val dest = AndroidFiles.Companion.mergedResources(project, variant)
|
||||
log(1, "Resource merging not implemented, copying app/src/main/res to $dest")
|
||||
log(1, "Resource merging not implemented, copying src/main/res to $dest")
|
||||
listOf(variant.buildType.name, variant.productFlavor.name, "main").forEach {
|
||||
log(1, " CURRENT VARIANT: $it, Copying app/src/$it/res into $dest")
|
||||
|
||||
val fromDir = File("app/src/$it/res")
|
||||
val fromDir = File("src/$it/res")
|
||||
KFiles.findRecursively(fromDir).forEach {
|
||||
val fromFile = File(fromDir, it)
|
||||
val toFile = File(dest, it)
|
||||
|
|
|
@ -34,9 +34,6 @@
|
|||
<build-directory-interceptors>
|
||||
<class-name>com.beust.kobalt.plugin.android.AndroidPlugin</class-name>
|
||||
</build-directory-interceptors>
|
||||
<source-directories-interceptors>
|
||||
<class-name>com.beust.kobalt.plugin.android.AndroidPlugin</class-name>
|
||||
</source-directories-interceptors>
|
||||
<compiler-interceptors>
|
||||
<class-name>com.beust.kobalt.plugin.android.AndroidPlugin</class-name>
|
||||
</compiler-interceptors>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue