Support several res/ directories
This commit is contained in:
@@ -34,11 +34,8 @@ import org.jetbrains.kotlin.lang.resolve.android.*
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
|
||||
public object AndroidConfigurationKeys {
|
||||
|
||||
public val ANDROID_RES_PATH: CompilerConfigurationKey<String> = CompilerConfigurationKey.create<String>("android resources search path")
|
||||
|
||||
public val ANDROID_RES_PATH: CompilerConfigurationKey<List<String>> = CompilerConfigurationKey.create<List<String>>("android resources search path")
|
||||
public val ANDROID_MANIFEST: CompilerConfigurationKey<String> = CompilerConfigurationKey.create<String>("android manifest file")
|
||||
|
||||
public val SUPPORT_V4: CompilerConfigurationKey<String> = CompilerConfigurationKey.create<String>("'true' if compiled with support-v4 library")
|
||||
}
|
||||
|
||||
@@ -46,7 +43,7 @@ public class AndroidCommandLineProcessor : CommandLineProcessor {
|
||||
companion object {
|
||||
public val ANDROID_COMPILER_PLUGIN_ID: String = "org.jetbrains.kotlin.android"
|
||||
|
||||
public val RESOURCE_PATH_OPTION: CliOption = CliOption("androidRes", "<path>", "Android resources path")
|
||||
public val RESOURCE_PATH_OPTION: CliOption = CliOption("androidRes", "<path>", "Android resources path", allowMultipleOccurrences = true)
|
||||
public val MANIFEST_FILE_OPTION: CliOption = CliOption("androidManifest", "<path>", "Android manifest file")
|
||||
public val SUPPORT_V4_OPTION: CliOption = CliOption("supportV4", "<path>", "Support android-v4 library", required = false)
|
||||
}
|
||||
@@ -57,7 +54,11 @@ public class AndroidCommandLineProcessor : CommandLineProcessor {
|
||||
|
||||
override fun processOption(option: CliOption, value: String, configuration: CompilerConfiguration) {
|
||||
when (option) {
|
||||
RESOURCE_PATH_OPTION -> configuration.put(AndroidConfigurationKeys.ANDROID_RES_PATH, value)
|
||||
RESOURCE_PATH_OPTION -> {
|
||||
val paths = configuration.getList(AndroidConfigurationKeys.ANDROID_RES_PATH).toArrayList()
|
||||
paths.add(value)
|
||||
configuration.put(AndroidConfigurationKeys.ANDROID_RES_PATH, paths)
|
||||
}
|
||||
MANIFEST_FILE_OPTION -> configuration.put(AndroidConfigurationKeys.ANDROID_MANIFEST, value)
|
||||
SUPPORT_V4_OPTION -> configuration.put(AndroidConfigurationKeys.SUPPORT_V4, value)
|
||||
else -> throw CliOptionProcessingException("Unknown option: ${option.name}")
|
||||
|
||||
+6
-5
@@ -55,8 +55,8 @@ public abstract class AndroidResourceManager(val project: Project) {
|
||||
return allChildren
|
||||
}
|
||||
|
||||
val resDirectory = fileManager.findFileByUrl("file://" + info.mainResDirectory)
|
||||
val allChildren = resDirectory?.getAllChildren() ?: listOf()
|
||||
val resDirectories = info.mainResDirectories.map { fileManager.findFileByUrl("file://$it") }
|
||||
val allChildren = resDirectories.flatMap { it?.getAllChildren() ?: listOf() }
|
||||
|
||||
return allChildren
|
||||
.filter { it.getParent().getName().startsWith("layout") && it.getName().toLowerCase().endsWith(".xml") }
|
||||
@@ -66,10 +66,11 @@ public abstract class AndroidResourceManager(val project: Project) {
|
||||
.mapValues { it.getValue().sortBy { it.getParent().getName().length() } }
|
||||
}
|
||||
|
||||
fun getMainResDirectory(): VirtualFile? {
|
||||
fun getModuleResDirectories(): List<VirtualFile> {
|
||||
val info = androidModuleInfo
|
||||
if (info == null) return null
|
||||
return VirtualFileManager.getInstance().findFileByUrl("file://" + info.mainResDirectory)
|
||||
if (info == null) return listOf()
|
||||
val fileManager = VirtualFileManager.getInstance()
|
||||
return info.mainResDirectories.map { fileManager.findFileByUrl("file://" + it) }
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ import kotlin.properties.Delegates
|
||||
public class CliAndroidResourceManager(
|
||||
project: Project,
|
||||
private val manifestPath: String,
|
||||
private val mainResDirectory: String
|
||||
private val mainResDirectory: List<String>
|
||||
) : AndroidResourceManager(project) {
|
||||
|
||||
override val androidModuleInfo by Delegates.lazy {
|
||||
|
||||
+2
-2
@@ -30,11 +30,11 @@ import com.intellij.psi.util.CachedValueProvider.Result
|
||||
public class CliAndroidUIXmlProcessor(
|
||||
project: Project,
|
||||
private val manifestPath: String,
|
||||
private val mainResDirectory: String
|
||||
private val mainResDirectories: List<String>
|
||||
) : AndroidUIXmlProcessor(project) {
|
||||
|
||||
override val resourceManager: CliAndroidResourceManager by Delegates.lazy {
|
||||
CliAndroidResourceManager(project, manifestPath, mainResDirectory)
|
||||
CliAndroidResourceManager(project, manifestPath, mainResDirectories)
|
||||
}
|
||||
|
||||
override val cachedSources: CachedValue<List<AndroidSyntheticFile>> by Delegates.lazy {
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.lang.resolve.android
|
||||
|
||||
public data class AndroidModuleInfo(val applicationPackage: String, val mainResDirectory: String?)
|
||||
public data class AndroidModuleInfo(val applicationPackage: String, val mainResDirectories: List<String>)
|
||||
|
||||
public abstract class AndroidResource(val id: String) {
|
||||
public abstract val className: String
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.myapp"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-permission android:name="android.permission.READ_CONTACTS"/>
|
||||
<uses-sdk
|
||||
android:minSdkVersion="18"
|
||||
android:targetSdkVersion="18" />
|
||||
<permission android:name="android"></permission>
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.Sample" >
|
||||
<activity
|
||||
android:name="com.example.android.basiccontactables.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTop">
|
||||
<meta-data
|
||||
android:name="android.app.searchable"
|
||||
android:resource="@xml/searchable" />
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.SEARCH" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<Button
|
||||
android:id="@+id/button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button2"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</FrameLayout>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/button"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/button3"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</FrameLayout>
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package kotlinx.android.synthetic.test
|
||||
|
||||
import android.app.*
|
||||
import android.view.*
|
||||
import android.widget.*
|
||||
import android.webkit.*
|
||||
import android.inputmethodservice.*
|
||||
import android.opengl.*
|
||||
import android.appwidget.*
|
||||
import android.support.v4.app.*
|
||||
import android.support.v4.view.*
|
||||
import android.support.v4.widget.*
|
||||
import kotlin.internal.flexible.ft
|
||||
|
||||
val android.app.Activity.button: ft<View, View?>
|
||||
get() = findViewById(0)
|
||||
|
||||
val android.app.Fragment.button: ft<View, View?>
|
||||
get() = getView().findViewById(0)
|
||||
|
||||
val android.app.Activity.button2: ft<Button, Button?>
|
||||
get() = findViewById(0) as? Button
|
||||
|
||||
val android.app.Fragment.button2: ft<Button, Button?>
|
||||
get() = getView().findViewById(0) as? Button
|
||||
|
||||
val android.app.Activity.button3: ft<Button, Button?>
|
||||
get() = findViewById(0) as? Button
|
||||
|
||||
val android.app.Fragment.button3: ft<Button, Button?>
|
||||
get() = getView().findViewById(0) as? Button
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package kotlinx.android.synthetic.test.view
|
||||
|
||||
import android.app.*
|
||||
import android.view.*
|
||||
import android.widget.*
|
||||
import android.webkit.*
|
||||
import android.inputmethodservice.*
|
||||
import android.opengl.*
|
||||
import android.appwidget.*
|
||||
import android.support.v4.app.*
|
||||
import android.support.v4.view.*
|
||||
import android.support.v4.widget.*
|
||||
import kotlin.internal.flexible.ft
|
||||
|
||||
val android.view.View.button: ft<View, View?>
|
||||
get() = findViewById(0)
|
||||
|
||||
val android.view.View.button2: ft<Button, Button?>
|
||||
get() = findViewById(0) as? Button
|
||||
|
||||
val android.view.View.button3: ft<Button, Button?>
|
||||
get() = findViewById(0) as? Button
|
||||
|
||||
+2
-2
@@ -41,10 +41,10 @@ public abstract class AbstractAndroidBoxTest : AbstractBlackBoxCodegenTest() {
|
||||
}
|
||||
|
||||
private fun createEnvironmentForConfiguration(configuration: CompilerConfiguration, path: String) {
|
||||
val resPath = path + "layout/"
|
||||
val layoutPaths = File(path).listFiles { it.name.startsWith("layout") && it.isDirectory() }!!.map { "$path${it.name}/" }
|
||||
val manifestPath = path + "AndroidManifest.xml"
|
||||
val supportV4 = File(path).name.startsWith("support")
|
||||
myEnvironment = createAndroidTestEnvironment(configuration, resPath, manifestPath, supportV4)
|
||||
myEnvironment = createAndroidTestEnvironment(configuration, layoutPaths, manifestPath, supportV4)
|
||||
}
|
||||
|
||||
public fun doCompileAgainstAndroidSdkTest(path: String) {
|
||||
|
||||
+2
-2
@@ -30,10 +30,10 @@ public abstract class AbstractAndroidBytecodeShapeTest : AbstractBytecodeTextTes
|
||||
}
|
||||
|
||||
private fun createEnvironmentForConfiguration(configuration: CompilerConfiguration, path: String) {
|
||||
val resPath = path + "res/layout/"
|
||||
val layoutPaths = getResPaths(path)
|
||||
val manifestPath = path + "../AndroidManifest.xml"
|
||||
val supportV4 = File(path).name.startsWith("support")
|
||||
myEnvironment = createAndroidTestEnvironment(configuration, resPath, manifestPath, supportV4)
|
||||
myEnvironment = createAndroidTestEnvironment(configuration, layoutPaths, manifestPath, supportV4)
|
||||
}
|
||||
|
||||
public override fun doTest(path: String) {
|
||||
|
||||
+2
-1
@@ -34,7 +34,8 @@ public abstract class AbstractAndroidXml2KConversionTest : UsefulTestCase() {
|
||||
val testDirectory = File(path)
|
||||
|
||||
val jetCoreEnvironment = getEnvironment()
|
||||
val parser = CliAndroidUIXmlProcessor(jetCoreEnvironment.project, path + "AndroidManifest.xml", path + "/res")
|
||||
val layoutPaths = getResPaths(path)
|
||||
val parser = CliAndroidUIXmlProcessor(jetCoreEnvironment.project, path + "AndroidManifest.xml", layoutPaths)
|
||||
parser.supportV4 = testDirectory.name.startsWith("support")
|
||||
|
||||
val actual = parser.parse(false).toMap { it.name }
|
||||
|
||||
+10
-5
@@ -30,15 +30,16 @@ import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
import org.jetbrains.kotlin.lang.resolve.android.CliAndroidUIXmlProcessor
|
||||
import java.io.File
|
||||
|
||||
private class AndroidTestExternalDeclarationsProvider(
|
||||
val project: Project,
|
||||
val resPath: String,
|
||||
val resPaths: List<String>,
|
||||
val manifestPath: String,
|
||||
val supportV4: Boolean
|
||||
) : ExternalDeclarationsProvider {
|
||||
override fun getExternalDeclarations(moduleInfo: ModuleInfo?): Collection<JetFile> {
|
||||
val parser = CliAndroidUIXmlProcessor(project, manifestPath, resPath)
|
||||
val parser = CliAndroidUIXmlProcessor(project, manifestPath, resPaths)
|
||||
parser.supportV4 = supportV4
|
||||
return parser.parseToPsi() ?: listOf()
|
||||
}
|
||||
@@ -46,15 +47,19 @@ private class AndroidTestExternalDeclarationsProvider(
|
||||
|
||||
fun UsefulTestCase.createAndroidTestEnvironment(
|
||||
configuration: CompilerConfiguration,
|
||||
resPath: String,
|
||||
resPaths: List<String>,
|
||||
manifestPath: String,
|
||||
supportV4: Boolean
|
||||
): KotlinCoreEnvironment {
|
||||
configuration.put(AndroidConfigurationKeys.ANDROID_RES_PATH, resPath)
|
||||
configuration.put(AndroidConfigurationKeys.ANDROID_RES_PATH, resPaths)
|
||||
configuration.put(AndroidConfigurationKeys.ANDROID_MANIFEST, manifestPath)
|
||||
val myEnvironment = KotlinCoreEnvironment.createForTests(getTestRootDisposable()!!, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
||||
val project = myEnvironment.project
|
||||
ExternalDeclarationsProvider.registerExtension(project, AndroidTestExternalDeclarationsProvider(project, resPath, manifestPath, supportV4))
|
||||
ExternalDeclarationsProvider.registerExtension(project, AndroidTestExternalDeclarationsProvider(project, resPaths, manifestPath, supportV4))
|
||||
ExpressionCodegenExtension.registerExtension(project, AndroidExpressionCodegenExtension())
|
||||
return myEnvironment
|
||||
}
|
||||
|
||||
fun getResPaths(path: String): List<String> {
|
||||
return File(path).listFiles { it.name.startsWith("res") && it.isDirectory() }!!.map { "$path${it.name}/" }
|
||||
}
|
||||
+1
-1
@@ -46,7 +46,7 @@ public class AndroidPsiTreeChangePreprocessor : PsiTreeChangePreprocessor, Simpl
|
||||
val module = projectFileIndex.getModuleForFile(file.getVirtualFile())
|
||||
if (module != null) {
|
||||
val resourceManager = AndroidResourceManager.getInstance(module)
|
||||
val mainResDirectory = resourceManager.getMainResDirectory()
|
||||
val mainResDirectory = resourceManager.getResDirectories()
|
||||
val baseDirectory = file.getParent()?.getParent()?.getVirtualFile()
|
||||
|
||||
//File from res/ directory was modified
|
||||
|
||||
+2
-2
@@ -54,10 +54,10 @@ public class IDEAndroidResourceManager(val module: Module) : AndroidResourceMana
|
||||
|
||||
private fun AndroidFacet.toAndroidModuleInfo(): AndroidModuleInfo? {
|
||||
val applicationPackage = getManifest()?.getPackage()?.toString()
|
||||
val mainResDirectory = getAllResourceDirectories().firstOrNull()?.getPath()
|
||||
val mainResDirectories = getAllResourceDirectories().map { it.getPath() }
|
||||
|
||||
return if (applicationPackage != null) {
|
||||
AndroidModuleInfo(applicationPackage, mainResDirectory)
|
||||
AndroidModuleInfo(applicationPackage, mainResDirectories)
|
||||
}
|
||||
else null
|
||||
}
|
||||
|
||||
+4
-4
@@ -44,11 +44,11 @@ public abstract class AbstractAndroidCompletionTest : KotlinAndroidTestCase() {
|
||||
|
||||
private fun completionType() = CompletionType.BASIC
|
||||
|
||||
fun doTest(testPath: String?) {
|
||||
myFixture.copyDirectoryToProject(getResDir()!!, "res")
|
||||
val virtualFile = myFixture.copyFileToProject(testPath + getTestName(true) + ".kt", "src/" + getTestName(true) + ".kt");
|
||||
fun doTest(path: String?) {
|
||||
getResourceDirs(path).forEach { myFixture.copyDirectoryToProject(it.name, it.name) }
|
||||
val virtualFile = myFixture.copyFileToProject(path + getTestName(true) + ".kt", "src/" + getTestName(true) + ".kt");
|
||||
myFixture.configureFromExistingVirtualFile(virtualFile)
|
||||
val fileText = FileUtil.loadFile(File(testPath + getTestName(true) + ".kt"), true)
|
||||
val fileText = FileUtil.loadFile(File(path + getTestName(true) + ".kt"), true)
|
||||
testCompletion(fileText, TargetPlatform.JVM, {
|
||||
count -> myFixture.complete(completionType())
|
||||
})
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ public abstract class AbstractAndroidFindUsagesTest : KotlinAndroidTestCase() {
|
||||
|
||||
public fun doTest(path: String) {
|
||||
val f = myFixture!!
|
||||
f.copyDirectoryToProject(getResDir()!!, "res")
|
||||
getResourceDirs(path).forEach { myFixture.copyDirectoryToProject(it.name, it.name) }
|
||||
val virtualFile = f.copyFileToProject(path + getTestName(true) + ".kt", "src/" + getTestName(true) + ".kt");
|
||||
f.configureFromExistingVirtualFile(virtualFile)
|
||||
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ public abstract class AbstractAndroidGotoTest : KotlinAndroidTestCase() {
|
||||
|
||||
public fun doTest(path: String) {
|
||||
val f = myFixture!!
|
||||
f.copyDirectoryToProject(getResDir()!!, "res")
|
||||
getResourceDirs(path).forEach { myFixture.copyDirectoryToProject(it.name, it.name) }
|
||||
val virtualFile = f.copyFileToProject(path + getTestName(true) + ".kt", "src/" + getTestName(true) + ".kt");
|
||||
f.configureFromExistingVirtualFile(virtualFile)
|
||||
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public abstract class AbstractAndroidRenameTest : KotlinAndroidTestCase() {
|
||||
|
||||
public fun doTest(path: String) {
|
||||
val f = myFixture!!
|
||||
f.copyDirectoryToProject(getResDir()!!, "res")
|
||||
getResourceDirs(path).forEach { myFixture.copyDirectoryToProject(it.name, it.name) }
|
||||
val virtualFile = f.copyFileToProject(path + getTestName(true) + ".kt", "src/" + getTestName(true) + ".kt");
|
||||
f.configureFromExistingVirtualFile(virtualFile)
|
||||
|
||||
|
||||
+7
-2
@@ -25,14 +25,19 @@ import org.jetbrains.kotlin.test.ConfigurationKind
|
||||
import org.jetbrains.kotlin.test.TestJdkKind
|
||||
import org.jetbrains.kotlin.test.JetTestUtils
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
import java.io.File
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
public abstract class AbstractParserResultEqualityTest : KotlinAndroidTestCase() {
|
||||
public fun doTest(path: String) {
|
||||
val project = myFixture.getProject()
|
||||
project.putUserData(TestConst.TESTDATA_PATH, path)
|
||||
myFixture.copyDirectoryToProject(getResDir(), "res")
|
||||
val cliParser = CliAndroidUIXmlProcessor(project, path + "../AndroidManifest.xml", path + getResDir() + "/layout/")
|
||||
val resDirs = getResourceDirs(path).map {
|
||||
myFixture.copyDirectoryToProject(it.name, it.name)
|
||||
"$path${it.name}/"
|
||||
}
|
||||
|
||||
val cliParser = CliAndroidUIXmlProcessor(project, path + "../AndroidManifest.xml", resDirs)
|
||||
val ideParser = IDEAndroidUIXmlProcessor(ModuleManager.getInstance(project).getModules()[0])
|
||||
|
||||
val cliResult = cliParser.parseToPsi()!!.joinToString("\n\n")
|
||||
|
||||
+15
-13
@@ -28,6 +28,7 @@ import com.intellij.facet.ModifiableFacetModel;
|
||||
import com.intellij.ide.startup.impl.StartupManagerImpl;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
@@ -38,7 +39,6 @@ import com.intellij.psi.PsiManager;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.impl.file.impl.FileManager;
|
||||
import com.intellij.testFramework.InspectionTestUtil;
|
||||
import com.intellij.testFramework.TestLogger;
|
||||
import com.intellij.testFramework.builders.JavaModuleFixtureBuilder;
|
||||
import com.intellij.testFramework.fixtures.*;
|
||||
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl;
|
||||
@@ -46,13 +46,13 @@ import com.intellij.testFramework.fixtures.impl.GlobalInspectionContextForTests;
|
||||
import org.jetbrains.android.facet.AndroidFacet;
|
||||
import org.jetbrains.android.facet.AndroidRootUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.android.KotlinAndroidTestCaseBase;
|
||||
import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode;
|
||||
import org.jetbrains.kotlin.idea.references.BuiltInsReferenceResolver;
|
||||
import org.jetbrains.kotlin.psi.JetFile;
|
||||
import org.jetbrains.kotlin.test.JetTestUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -77,9 +77,13 @@ public abstract class KotlinAndroidTestCase extends KotlinAndroidTestCaseBase {
|
||||
this(true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected String getResRelativePath() {
|
||||
return "res/";
|
||||
protected File[] getResourceDirs(String path) {
|
||||
return new File(path).listFiles(new FileFilter() {
|
||||
@Override
|
||||
public boolean accept(@NotNull File file) {
|
||||
return file.getName().startsWith("res") && file.isDirectory();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -119,10 +123,12 @@ public abstract class KotlinAndroidTestCase extends KotlinAndroidTestCaseBase {
|
||||
|
||||
androidSdk = createAndroidSdk(getTestSdkPath(), getPlatformDir());
|
||||
myFacet = addAndroidFacet(myModule, sdkPath, getPlatformDir(), isToAddSdk());
|
||||
if (new File(getResDir()).exists()) {
|
||||
myFixture.copyDirectoryToProject(getResDir(), "res");
|
||||
} else {
|
||||
TestLogger.getInstance(this.getClass()).info("No res directory found in test");
|
||||
for (File resDir : getResourceDirs(dirPath)) {
|
||||
if (resDir.exists()) {
|
||||
myFixture.copyDirectoryToProject(resDir.getName(), resDir.getName());
|
||||
} else {
|
||||
Logger.getInstance(this.getClass()).info("No res directory found in test");
|
||||
}
|
||||
}
|
||||
myAdditionalModules = new ArrayList<Module>();
|
||||
|
||||
@@ -182,10 +188,6 @@ public abstract class KotlinAndroidTestCase extends KotlinAndroidTestCaseBase {
|
||||
return "/additionalModules/" + moduleName;
|
||||
}
|
||||
|
||||
protected String getResDir() {
|
||||
return "res";
|
||||
}
|
||||
|
||||
public static void tuneModule(JavaModuleFixtureBuilder moduleBuilder, String moduleDirPath) {
|
||||
moduleBuilder.addContentRoot(moduleDirPath);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user