mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-25 16:07:12 -07:00
androidHome fix.
This commit is contained in:
parent
41904c0c75
commit
00a22e4d25
1 changed files with 26 additions and 19 deletions
|
@ -20,6 +20,7 @@ import com.google.common.collect.HashMultimap
|
|||
import com.google.inject.Inject
|
||||
import com.google.inject.Singleton
|
||||
import java.io.File
|
||||
import java.net.URI
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
|
||||
|
@ -77,7 +78,7 @@ public class AndroidPlugin @Inject constructor(val javaCompiler: JavaCompiler)
|
|||
return version as String
|
||||
}
|
||||
|
||||
fun androidHome(project: Project?) : String {
|
||||
fun androidHomeNoThrows(project: Project?): String? {
|
||||
var result = System.getenv("ANDROID_HOME")
|
||||
if (project != null) {
|
||||
configurations[project.name]?.androidHome?.let {
|
||||
|
@ -85,13 +86,12 @@ public class AndroidPlugin @Inject constructor(val javaCompiler: JavaCompiler)
|
|||
}
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
throw IllegalArgumentException("Neither androidHome nor \$ANDROID_HOME were defined")
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
fun androidHome(project: Project?) = androidHomeNoThrows(project) ?:
|
||||
throw IllegalArgumentException("Neither androidHome nor \$ANDROID_HOME were defined")
|
||||
|
||||
fun androidJar(project: Project): Path =
|
||||
Paths.get(androidHome(project), "platforms", "android-${compileSdkVersion(project)}", "android.jar")
|
||||
|
||||
|
@ -127,6 +127,7 @@ public class AndroidPlugin @Inject constructor(val javaCompiler: JavaCompiler)
|
|||
init {
|
||||
directory = cwd
|
||||
}
|
||||
|
||||
fun call(args: List<String>) = run(arrayListOf(aaptCommand) + args)
|
||||
}
|
||||
|
||||
|
@ -254,14 +255,20 @@ public class AndroidPlugin @Inject constructor(val javaCompiler: JavaCompiler)
|
|||
|
||||
// IClasspathContributor
|
||||
override fun entriesFor(project: Project?): Collection<IClasspathDependency> {
|
||||
if (project != null) {
|
||||
return classpathEntries.get(project.name) ?: listOf()
|
||||
return if (project != null) {
|
||||
classpathEntries.get(project.name) ?: listOf()
|
||||
} else {
|
||||
return listOf()
|
||||
listOf()
|
||||
}
|
||||
}
|
||||
|
||||
// IRepoContributor
|
||||
override fun reposFor(project: Project?) =
|
||||
listOf(Paths.get(KFiles.joinDir(androidHome(project), "extras", "android", "m2repository")).toUri())
|
||||
override fun reposFor(project: Project?): List<URI> {
|
||||
val home = androidHomeNoThrows(project)
|
||||
return if (home != null) {
|
||||
listOf(Paths.get(KFiles.joinDir(home, "extras", "android", "m2repository")).toUri())
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue