mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Fix BuildConfig.
This commit is contained in:
parent
a2de187e46
commit
6168e50c3f
5 changed files with 18 additions and 13 deletions
|
@ -149,9 +149,7 @@ class Variant(val initialProductFlavor: ProductFlavorConfig? = null,
|
|||
// that directory will be added when trying to find recursively all the sources in it
|
||||
generatedSourceDirectory = File(result.relativeTo(File(project.directory)).absolutePath)
|
||||
val outputGeneratedSourceDirectory = File(result, pkg.replace('.', File.separatorChar))
|
||||
val compilers = ActorUtils.selectAffinityActors(project, context, context.pluginInfo.compilerContributors)
|
||||
val outputDir = File(outputGeneratedSourceDirectory,
|
||||
"BuildConfig" + compilers[0].sourceSuffixes[0])
|
||||
val outputDir = File(outputGeneratedSourceDirectory, "BuildConfig" + contributor.suffix)
|
||||
KFiles.saveFile(outputDir, code)
|
||||
log(2, "Generated ${outputDir.path}")
|
||||
return result
|
||||
|
|
|
@ -8,4 +8,9 @@ import com.beust.kobalt.Variant
|
|||
interface IBuildConfigContributor : ISimpleAffinity<Project> {
|
||||
fun generateBuildConfig(project: Project, context: KobaltContext, packageName: String, variant: Variant,
|
||||
buildConfigs: List<BuildConfig>) : String
|
||||
|
||||
/**
|
||||
* The suffix of the generated BuildConfig, e.g. ".java".
|
||||
*/
|
||||
val suffix: String
|
||||
}
|
||||
|
|
|
@ -173,7 +173,8 @@ open class JvmCompilerPlugin @Inject constructor(
|
|||
} else {
|
||||
compilers.forEach { compiler ->
|
||||
if (containsSourceFiles(project, compiler)) {
|
||||
val info = createCompilerActionInfo(project, context, isTest, sourceSuffixes = compiler.sourceSuffixes)
|
||||
val info = createCompilerActionInfo(project, context, isTest, sourceDirectories,
|
||||
sourceSuffixes = compiler.sourceSuffixes)
|
||||
val thisResult = compiler.compile(project, context, info)
|
||||
results.add(thisResult)
|
||||
if (!thisResult.success && failedResult == null) {
|
||||
|
@ -214,7 +215,8 @@ open class JvmCompilerPlugin @Inject constructor(
|
|||
var result: TaskResult? = null
|
||||
compilers.forEach { compiler ->
|
||||
result = docGenerator.generateDoc(project, context, createCompilerActionInfo(project, context,
|
||||
isTest = false, sourceSuffixes = compiler.sourceSuffixes))
|
||||
isTest = false, sourceDirectories = sourceDirectories,
|
||||
sourceSuffixes = compiler.sourceSuffixes))
|
||||
}
|
||||
return result!!
|
||||
} else {
|
||||
|
@ -236,7 +238,7 @@ open class JvmCompilerPlugin @Inject constructor(
|
|||
* Runs all the contributors and interceptors relevant to that task.
|
||||
*/
|
||||
protected fun createCompilerActionInfo(project: Project, context: KobaltContext, isTest: Boolean,
|
||||
sourceSuffixes: List<String>): CompilerActionInfo {
|
||||
sourceDirectories: Set<File>, sourceSuffixes: List<String>): CompilerActionInfo {
|
||||
copyResources(project, JvmCompilerPlugin.SOURCE_SET_MAIN)
|
||||
|
||||
val fullClasspath = if (isTest) dependencyManager.testDependencies(project, context)
|
||||
|
@ -252,8 +254,8 @@ open class JvmCompilerPlugin @Inject constructor(
|
|||
else File(project.classesDir(context))
|
||||
buildDirectory.mkdirs()
|
||||
|
||||
val initialSourceDirectories = arrayListOf<File>()
|
||||
|
||||
val initialSourceDirectories = ArrayList<File>(sourceDirectories)
|
||||
// Source directories from the contributors
|
||||
initialSourceDirectories.addAll(
|
||||
if (isTest) {
|
||||
|
|
|
@ -62,9 +62,9 @@ class JavaPlugin @Inject constructor(val javaCompiler: JavaCompiler)
|
|||
= project.sourceDirectoriesTest.map { File(it) }.toList()
|
||||
|
||||
// IBuildConfigContributor
|
||||
override fun affinity(project: Project): Int {
|
||||
return if (project.projectExtra.suffixesFound.contains("java")) 1 else 0
|
||||
}
|
||||
override fun affinity(project: Project) = if (project.projectExtra.suffixesFound.contains("java")) 1 else 0
|
||||
|
||||
override val suffix = ".java"
|
||||
|
||||
override fun generateBuildConfig(project: Project, context: KobaltContext, packageName: String,
|
||||
variant: Variant, buildConfigs: List<BuildConfig>): String {
|
||||
|
|
|
@ -127,9 +127,9 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors)
|
|||
}
|
||||
|
||||
// IBuildConfigContributor
|
||||
override fun affinity(project: Project): Int {
|
||||
return if (project.projectExtra.suffixesFound.contains("kotlin")) 2 else 0
|
||||
}
|
||||
override fun affinity(project: Project) = if (project.projectExtra.suffixesFound.contains("kotlin")) 2 else 0
|
||||
|
||||
override val suffix = ".kt"
|
||||
|
||||
override fun generateBuildConfig(project: Project, context: KobaltContext, packageName: String,
|
||||
variant: Variant, buildConfigs: List<BuildConfig>): String {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue