Added gradle android test project
This commit is contained in:
@@ -1,43 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<module type="JAVA_MODULE" version="4">
|
<module version="4">
|
||||||
<component name="FacetManager">
|
<component name="NewModuleRootManager" inherit-compiler-output="false">
|
||||||
<facet type="android" name="Android">
|
|
||||||
<configuration>
|
|
||||||
<option name="GEN_FOLDER_RELATIVE_PATH_APT" value="/gen" />
|
|
||||||
<option name="GEN_FOLDER_RELATIVE_PATH_AIDL" value="/gen" />
|
|
||||||
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/AndroidManifest.xml" />
|
|
||||||
<option name="RES_FOLDER_RELATIVE_PATH" value="/res" />
|
|
||||||
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/assets" />
|
|
||||||
<option name="LIBS_FOLDER_RELATIVE_PATH" value="/libs" />
|
|
||||||
<option name="USE_CUSTOM_APK_RESOURCE_FOLDER" value="false" />
|
|
||||||
<option name="CUSTOM_APK_RESOURCE_FOLDER" value="" />
|
|
||||||
<option name="USE_CUSTOM_COMPILER_MANIFEST" value="false" />
|
|
||||||
<option name="CUSTOM_COMPILER_MANIFEST" value="" />
|
|
||||||
<option name="APK_PATH" value="" />
|
|
||||||
<option name="LIBRARY_PROJECT" value="false" />
|
|
||||||
<option name="RUN_PROCESS_RESOURCES_MAVEN_TASK" value="true" />
|
|
||||||
<option name="GENERATE_UNSIGNED_APK" value="false" />
|
|
||||||
<option name="CUSTOM_DEBUG_KEYSTORE_PATH" value="" />
|
|
||||||
<option name="PACK_TEST_CODE" value="false" />
|
|
||||||
<option name="RUN_PROGUARD" value="false" />
|
|
||||||
<option name="PROGUARD_CFG_PATH" value="/proguard-project.txt" />
|
|
||||||
<resOverlayFolders>
|
|
||||||
<path>/res-overlay</path>
|
|
||||||
</resOverlayFolders>
|
|
||||||
<includeSystemProguardFile>true</includeSystemProguardFile>
|
|
||||||
<includeAssetsFromLibraries>false</includeAssetsFromLibraries>
|
|
||||||
<additionalNativeLibs />
|
|
||||||
</configuration>
|
|
||||||
</facet>
|
|
||||||
</component>
|
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
|
||||||
<exclude-output />
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/gen" isTestSource="false" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="jdk" jdkName="Android 2.3.3 Platform" jdkType="Android SDK" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath 'com.android.tools.build:gradle:2.0.0'
|
||||||
|
|
||||||
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
// in the individual module build.gradle files
|
||||||
|
}
|
||||||
|
}
|
||||||
|
apply plugin: 'com.android.application'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 16
|
||||||
|
buildToolsVersion "23.0.3"
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "org.jetbrains.kotlin.android.tests"
|
||||||
|
minSdkVersion 16
|
||||||
|
targetSdkVersion 16
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
testApplicationId "org.jetbrains.kotlin.android.tests.gradle"
|
||||||
|
testInstrumentationRunner "android.test.InstrumentationTestRunner"
|
||||||
|
}
|
||||||
|
buildTypes {
|
||||||
|
debug {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
main {
|
||||||
|
manifest.srcFile 'AndroidManifest.xml'
|
||||||
|
java {
|
||||||
|
srcDirs = ['src']
|
||||||
|
}
|
||||||
|
res.srcDirs = ['res']
|
||||||
|
}
|
||||||
|
androidTest {
|
||||||
|
java {
|
||||||
|
srcDirs = ['src']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
packagingOptions { exclude 'META-INF/build.txt' }
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
androidTestCompile 'junit:junit:4.12'
|
||||||
|
}
|
||||||
+5
-2
@@ -103,8 +103,11 @@ public class SDKDownloader {
|
|||||||
public void unzipAll() {
|
public void unzipAll() {
|
||||||
String androidSdkRoot = pathManager.getAndroidSdkRoot();
|
String androidSdkRoot = pathManager.getAndroidSdkRoot();
|
||||||
unzip(platformZipPath, pathManager.getPlatformFolderInAndroidSdk());
|
unzip(platformZipPath, pathManager.getPlatformFolderInAndroidSdk());
|
||||||
unzip(armImage, androidSdkRoot + "/system-images/android-" + ANDROID_VERSION + "/");
|
new File(pathManager.getPlatformFolderInAndroidSdk() + "/android-4.1.2").renameTo(new File(pathManager.getPlatformFolderInAndroidSdk() + "/android-16"));
|
||||||
unzip(x86Image, androidSdkRoot + "/system-images/android-" + ANDROID_VERSION + "/");
|
|
||||||
|
unzip(armImage, androidSdkRoot + "/system-images/android-" + ANDROID_VERSION + "/default/");
|
||||||
|
unzip(x86Image, androidSdkRoot + "/system-images/android-" + ANDROID_VERSION + "/default/");
|
||||||
|
|
||||||
unzip(platformToolsZipPath, androidSdkRoot);
|
unzip(platformToolsZipPath, androidSdkRoot);
|
||||||
unzip(skdToolsZipPath, androidSdkRoot);
|
unzip(skdToolsZipPath, androidSdkRoot);
|
||||||
|
|
||||||
|
|||||||
+66
@@ -0,0 +1,66 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2016 JetBrains s.r.o.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.android.tests.gradle;
|
||||||
|
|
||||||
|
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||||
|
import com.intellij.openapi.util.SystemInfo;
|
||||||
|
import org.jetbrains.kotlin.android.tests.OutputUtils;
|
||||||
|
import org.jetbrains.kotlin.android.tests.PathManager;
|
||||||
|
import org.jetbrains.kotlin.android.tests.run.RunResult;
|
||||||
|
import org.jetbrains.kotlin.android.tests.run.RunUtils;
|
||||||
|
import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GradleRunner {
|
||||||
|
private final List<String> listOfCommands;
|
||||||
|
|
||||||
|
public GradleRunner(PathManager pathManager) {
|
||||||
|
listOfCommands = new ArrayList<String>();
|
||||||
|
String cmdName = SystemInfo.isWindows ? "gradlew.bat" : "gradlew";
|
||||||
|
listOfCommands.add(pathManager.getTmpFolder() + "/" + cmdName);
|
||||||
|
listOfCommands.add("--build-file");
|
||||||
|
listOfCommands.add(pathManager.getTmpFolder() + "/build.gradle");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void clean() {
|
||||||
|
System.out.println("Building gradle project...");
|
||||||
|
RunResult result = RunUtils.execute(generateCommandLine("clean"));
|
||||||
|
OutputUtils.checkResult(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void build() {
|
||||||
|
System.out.println("Building gradle project...");
|
||||||
|
RunResult result = RunUtils.execute(generateCommandLine("build"));
|
||||||
|
OutputUtils.checkResult(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String connectedDebugAndroidTest() {
|
||||||
|
System.out.println("Starting tests...");
|
||||||
|
RunResult result = RunUtils.execute(generateCommandLine("connectedAndroidTest"));
|
||||||
|
return result.getOutput();
|
||||||
|
}
|
||||||
|
|
||||||
|
private GeneralCommandLine generateCommandLine(String taskName) {
|
||||||
|
GeneralCommandLine commandLine = new GeneralCommandLine(listOfCommands);
|
||||||
|
commandLine.addParameter(taskName);
|
||||||
|
return commandLine;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -33,6 +33,7 @@ public class PermissionManager {
|
|||||||
setExecPermissionForSimpleNamedFiles(new File(pathManager.getToolsFolderInAndroidSdk()));
|
setExecPermissionForSimpleNamedFiles(new File(pathManager.getToolsFolderInAndroidSdk()));
|
||||||
setExecPermissionForSimpleNamedFiles(new File(pathManager.getBuildToolsFolderInAndroidSdk() + "/" + SDKDownloader.BUILD_TOOLS));
|
setExecPermissionForSimpleNamedFiles(new File(pathManager.getBuildToolsFolderInAndroidSdk() + "/" + SDKDownloader.BUILD_TOOLS));
|
||||||
setExecPermissionForSimpleNamedFiles(new File(pathManager.getPlatformToolsFolderInAndroidSdk()));
|
setExecPermissionForSimpleNamedFiles(new File(pathManager.getPlatformToolsFolderInAndroidSdk()));
|
||||||
|
RunUtils.execute(generateChmodCmd(pathManager.getTmpFolder() + "/gradlew"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user