fix android jps build test case
- add proper way of setting up android sdk for jps
- add missing android plugin runtime library
Original commit: 95fd4006d9
This commit is contained in:
committed by
Yan Zhulanow
parent
7864e14870
commit
6e3e9b6346
+39
-2
@@ -17,17 +17,54 @@
|
||||
package org.jetbrains.jet.jps.build.android
|
||||
|
||||
import org.jetbrains.jps.builders.JpsBuildTestCase
|
||||
import org.jetbrains.jps.android.model.JpsAndroidSdkProperties
|
||||
import org.jetbrains.jps.android.model.JpsAndroidSdkType
|
||||
import org.jetbrains.jps.model.library.JpsOrderRootType
|
||||
import org.jetbrains.jps.model.JpsSimpleElement
|
||||
import org.jetbrains.jps.model.library.sdk.JpsSdk
|
||||
import org.jetbrains.jps.model.impl.JpsSimpleElementImpl
|
||||
|
||||
import java.io.File
|
||||
|
||||
public abstract class AbstractAndroidJpsTestCase : JpsBuildTestCase() {
|
||||
private val SDK_NAME = "Android_SDK"
|
||||
|
||||
private val SDK_NAME = "Android API 17 Platform"
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
System.setProperty("kotlin.jps.tests", "true")
|
||||
}
|
||||
|
||||
public fun doTest(path: String) {
|
||||
addJdk(SDK_NAME, getHomePath() + "/androidSDK/platforms/android-17" + "/android.jar")
|
||||
addJdkAndAndroidSdk()
|
||||
loadProject(path + getTestName(true) + ".ipr")
|
||||
rebuildAll()
|
||||
makeAll().assertSuccessful()
|
||||
deleteDirectory(File(path + "/out"))
|
||||
}
|
||||
|
||||
public fun deleteDirectory(path: File): Boolean {
|
||||
if (path.exists() && path.isDirectory()) {
|
||||
val files = path.listFiles()!!
|
||||
for (i in files.indices) {
|
||||
if (files[i].isDirectory()) {
|
||||
deleteDirectory(files[i])
|
||||
}
|
||||
else {
|
||||
files[i].delete()
|
||||
}
|
||||
}
|
||||
}
|
||||
return (path.delete())
|
||||
}
|
||||
|
||||
private fun addJdkAndAndroidSdk(): JpsSdk<JpsSimpleElement<JpsAndroidSdkProperties>> {
|
||||
val jdkName = "java_sdk"
|
||||
addJdk(jdkName)
|
||||
val properties = JpsAndroidSdkProperties("android-17", jdkName)
|
||||
val sdkPath = getHomePath() + "/androidSDK/"
|
||||
val library = myModel!!.getGlobal().addSdk<JpsSimpleElement<JpsAndroidSdkProperties>>(SDK_NAME, sdkPath, "", JpsAndroidSdkType.INSTANCE, JpsSimpleElementImpl(properties))
|
||||
library!!.addRoot(File(sdkPath + "/platforms/android-17/android.jar"), JpsOrderRootType.COMPILED)
|
||||
return library.getProperties()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
<uses-sdk android:minSdkVersion="17"/>
|
||||
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
|
||||
<application android:label="app_name" >
|
||||
<activity android:name=".MyActivity"
|
||||
android:label="@string/app_name">
|
||||
android:label="app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
<category android:name="android.intent.category.LAUNCHER"/>
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World, MyActivity"
|
||||
android:id="@+id/LOL"/>
|
||||
android:id="@+id/textField"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="Androids_SDK" jdkType="Android SDK" />
|
||||
<orderEntry type="jdk" jdkName="Android API 17 Platform" jdkType="Android SDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||
</component>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<module fileurl="file://$PROJECT_DIR$/simple.iml" filepath="$PROJECT_DIR$/simple.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="Android_SDK" project-jdk-type="Android SDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="Android API 17 Platform" project-jdk-type="Android SDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.example.myapp;
|
||||
|
||||
/**
|
||||
* Created by miha on 8/6/14.
|
||||
*/
|
||||
public class Foo {
|
||||
public static void main(String[] args) {
|
||||
System.out.println(R.id.LOL);
|
||||
}
|
||||
}
|
||||
@@ -4,16 +4,9 @@ import android.app.Activity
|
||||
import android.os.Bundle
|
||||
|
||||
public class MyActivity : Activity() {
|
||||
/**
|
||||
* Called when the activity is first created.
|
||||
*/
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.main)
|
||||
println(R.id.LOL)
|
||||
fuck
|
||||
this.LOL
|
||||
LOL.setText("UIGFVIYUGFKGYUFOD")
|
||||
LOL.setText("test")
|
||||
textField.setText("test")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user