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
|
// that directory will be added when trying to find recursively all the sources in it
|
||||||
generatedSourceDirectory = File(result.relativeTo(File(project.directory)).absolutePath)
|
generatedSourceDirectory = File(result.relativeTo(File(project.directory)).absolutePath)
|
||||||
val outputGeneratedSourceDirectory = File(result, pkg.replace('.', File.separatorChar))
|
val outputGeneratedSourceDirectory = File(result, pkg.replace('.', File.separatorChar))
|
||||||
val compilers = ActorUtils.selectAffinityActors(project, context, context.pluginInfo.compilerContributors)
|
val outputDir = File(outputGeneratedSourceDirectory, "BuildConfig" + contributor.suffix)
|
||||||
val outputDir = File(outputGeneratedSourceDirectory,
|
|
||||||
"BuildConfig" + compilers[0].sourceSuffixes[0])
|
|
||||||
KFiles.saveFile(outputDir, code)
|
KFiles.saveFile(outputDir, code)
|
||||||
log(2, "Generated ${outputDir.path}")
|
log(2, "Generated ${outputDir.path}")
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -8,4 +8,9 @@ import com.beust.kobalt.Variant
|
||||||
interface IBuildConfigContributor : ISimpleAffinity<Project> {
|
interface IBuildConfigContributor : ISimpleAffinity<Project> {
|
||||||
fun generateBuildConfig(project: Project, context: KobaltContext, packageName: String, variant: Variant,
|
fun generateBuildConfig(project: Project, context: KobaltContext, packageName: String, variant: Variant,
|
||||||
buildConfigs: List<BuildConfig>) : String
|
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 {
|
} else {
|
||||||
compilers.forEach { compiler ->
|
compilers.forEach { compiler ->
|
||||||
if (containsSourceFiles(project, 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)
|
val thisResult = compiler.compile(project, context, info)
|
||||||
results.add(thisResult)
|
results.add(thisResult)
|
||||||
if (!thisResult.success && failedResult == null) {
|
if (!thisResult.success && failedResult == null) {
|
||||||
|
@ -214,7 +215,8 @@ open class JvmCompilerPlugin @Inject constructor(
|
||||||
var result: TaskResult? = null
|
var result: TaskResult? = null
|
||||||
compilers.forEach { compiler ->
|
compilers.forEach { compiler ->
|
||||||
result = docGenerator.generateDoc(project, context, createCompilerActionInfo(project, context,
|
result = docGenerator.generateDoc(project, context, createCompilerActionInfo(project, context,
|
||||||
isTest = false, sourceSuffixes = compiler.sourceSuffixes))
|
isTest = false, sourceDirectories = sourceDirectories,
|
||||||
|
sourceSuffixes = compiler.sourceSuffixes))
|
||||||
}
|
}
|
||||||
return result!!
|
return result!!
|
||||||
} else {
|
} else {
|
||||||
|
@ -236,7 +238,7 @@ open class JvmCompilerPlugin @Inject constructor(
|
||||||
* Runs all the contributors and interceptors relevant to that task.
|
* Runs all the contributors and interceptors relevant to that task.
|
||||||
*/
|
*/
|
||||||
protected fun createCompilerActionInfo(project: Project, context: KobaltContext, isTest: Boolean,
|
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)
|
copyResources(project, JvmCompilerPlugin.SOURCE_SET_MAIN)
|
||||||
|
|
||||||
val fullClasspath = if (isTest) dependencyManager.testDependencies(project, context)
|
val fullClasspath = if (isTest) dependencyManager.testDependencies(project, context)
|
||||||
|
@ -252,8 +254,8 @@ open class JvmCompilerPlugin @Inject constructor(
|
||||||
else File(project.classesDir(context))
|
else File(project.classesDir(context))
|
||||||
buildDirectory.mkdirs()
|
buildDirectory.mkdirs()
|
||||||
|
|
||||||
val initialSourceDirectories = arrayListOf<File>()
|
|
||||||
|
|
||||||
|
val initialSourceDirectories = ArrayList<File>(sourceDirectories)
|
||||||
// Source directories from the contributors
|
// Source directories from the contributors
|
||||||
initialSourceDirectories.addAll(
|
initialSourceDirectories.addAll(
|
||||||
if (isTest) {
|
if (isTest) {
|
||||||
|
|
|
@ -62,9 +62,9 @@ class JavaPlugin @Inject constructor(val javaCompiler: JavaCompiler)
|
||||||
= project.sourceDirectoriesTest.map { File(it) }.toList()
|
= project.sourceDirectoriesTest.map { File(it) }.toList()
|
||||||
|
|
||||||
// IBuildConfigContributor
|
// IBuildConfigContributor
|
||||||
override fun affinity(project: Project): Int {
|
override fun affinity(project: Project) = if (project.projectExtra.suffixesFound.contains("java")) 1 else 0
|
||||||
return if (project.projectExtra.suffixesFound.contains("java")) 1 else 0
|
|
||||||
}
|
override val suffix = ".java"
|
||||||
|
|
||||||
override fun generateBuildConfig(project: Project, context: KobaltContext, packageName: String,
|
override fun generateBuildConfig(project: Project, context: KobaltContext, packageName: String,
|
||||||
variant: Variant, buildConfigs: List<BuildConfig>): String {
|
variant: Variant, buildConfigs: List<BuildConfig>): String {
|
||||||
|
|
|
@ -127,9 +127,9 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IBuildConfigContributor
|
// IBuildConfigContributor
|
||||||
override fun affinity(project: Project): Int {
|
override fun affinity(project: Project) = if (project.projectExtra.suffixesFound.contains("kotlin")) 2 else 0
|
||||||
return if (project.projectExtra.suffixesFound.contains("kotlin")) 2 else 0
|
|
||||||
}
|
override val suffix = ".kt"
|
||||||
|
|
||||||
override fun generateBuildConfig(project: Project, context: KobaltContext, packageName: String,
|
override fun generateBuildConfig(project: Project, context: KobaltContext, packageName: String,
|
||||||
variant: Variant, buildConfigs: List<BuildConfig>): String {
|
variant: Variant, buildConfigs: List<BuildConfig>): String {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue