From 17d131889cb9e31b5f26d42d247809c83bf17993 Mon Sep 17 00:00:00 2001 From: yangchengdong Date: Tue, 22 Jan 2019 11:23:14 +0800 Subject: [PATCH] add kotlin supported module. --- build.gradle | 5 +- kotlin/.gitignore | 1 + kotlin/build.gradle | 81 +++++++++++++++++++ kotlin/proguard-rules.pro | 21 +++++ .../demo/kotlin/ExampleInstrumentedTest.java | 26 ++++++ kotlin/src/main/AndroidManifest.xml | 2 + .../com/eastwood/demo/kotlin/KotlinService.kt | 14 ++++ .../mis/com/eastwood/demo/kotlin/IKotlin.kt | 14 ++++ .../mis/com/eastwood/demo/kotlin/IKotlin1.kt | 10 +++ .../com/eastwood/demo/kotlin/JavaObject.java | 24 ++++++ kotlin/src/main/res/values/strings.xml | 3 + .../eastwood/demo/kotlin/ExampleUnitTest.java | 17 ++++ settings.gradle | 2 +- 13 files changed, 217 insertions(+), 3 deletions(-) create mode 100644 kotlin/.gitignore create mode 100644 kotlin/build.gradle create mode 100644 kotlin/proguard-rules.pro create mode 100644 kotlin/src/androidTest/java/com/eastwood/demo/kotlin/ExampleInstrumentedTest.java create mode 100644 kotlin/src/main/AndroidManifest.xml create mode 100644 kotlin/src/main/java/com/eastwood/demo/kotlin/KotlinService.kt create mode 100644 kotlin/src/main/mis/com/eastwood/demo/kotlin/IKotlin.kt create mode 100644 kotlin/src/main/mis/com/eastwood/demo/kotlin/IKotlin1.kt create mode 100644 kotlin/src/main/mis/com/eastwood/demo/kotlin/JavaObject.java create mode 100644 kotlin/src/main/res/values/strings.xml create mode 100644 kotlin/src/test/java/com/eastwood/demo/kotlin/ExampleUnitTest.java diff --git a/build.gradle b/build.gradle index 5005e57..a26d105 100644 --- a/build.gradle +++ b/build.gradle @@ -1,16 +1,17 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - + ext.kotlin_version = '1.3.0' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.2.1' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // micro-module - classpath 'com.eastwood.tools.plugins:micro-module:1.2.1' + classpath 'com.eastwood.tools.plugins:micro-module:1.3.1' // auto-inject classpath 'com.eastwood.tools.plugins:auto-inject:1.0.3' diff --git a/kotlin/.gitignore b/kotlin/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/kotlin/.gitignore @@ -0,0 +1 @@ +/build diff --git a/kotlin/build.gradle b/kotlin/build.gradle new file mode 100644 index 0000000..a09120b --- /dev/null +++ b/kotlin/build.gradle @@ -0,0 +1,81 @@ +apply plugin: 'com.android.library' +apply plugin: 'mis' + +apply plugin: 'kotlin-android' + +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 27 + + defaultConfig { + minSdkVersion 14 + targetSdkVersion 27 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } +} + +mis { + publications { + main { + groupId 'com.eastwood.demo' + artifactId 'kotlin-sdk' + // version '1.0.0-SNAPSHOT' // 初次配置时不设置,发布至maven时设置 + + dependencies { + // 只支持 compileOnly 和 implementation + +// compileOnly 'com.google.code.gson:gson:2.8.1' + // or +// implementation 'com.google.code.gson:gson:2.8.1' + +// compileOnly misPublication('com.eastwood.demo:module-main-sdk') + } + } + } + + repositories { +// maven { +// url "http://******" +// credentials { +// username '******' +// password '******' +// } +// } + + maven { + url "http://10.10.9.201:8081/repository/android-dev/" + credentials { + username 'admin' + password 'admin123' + } + } + } + +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + + implementation 'com.android.support:appcompat-v7:27.1.1' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" +} diff --git a/kotlin/proguard-rules.pro b/kotlin/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/kotlin/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/kotlin/src/androidTest/java/com/eastwood/demo/kotlin/ExampleInstrumentedTest.java b/kotlin/src/androidTest/java/com/eastwood/demo/kotlin/ExampleInstrumentedTest.java new file mode 100644 index 0000000..aa2f8c1 --- /dev/null +++ b/kotlin/src/androidTest/java/com/eastwood/demo/kotlin/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package com.eastwood.demo.kotlin; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("com.eastwood.demo.kotlin.test", appContext.getPackageName()); + } +} diff --git a/kotlin/src/main/AndroidManifest.xml b/kotlin/src/main/AndroidManifest.xml new file mode 100644 index 0000000..9ed3c58 --- /dev/null +++ b/kotlin/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + diff --git a/kotlin/src/main/java/com/eastwood/demo/kotlin/KotlinService.kt b/kotlin/src/main/java/com/eastwood/demo/kotlin/KotlinService.kt new file mode 100644 index 0000000..81d20b0 --- /dev/null +++ b/kotlin/src/main/java/com/eastwood/demo/kotlin/KotlinService.kt @@ -0,0 +1,14 @@ +package com.eastwood.demo.kotlin + +/** + * + * @author eastwood + * createDate: 2019-01-21 + */ +class KotlinService : IKotlin { + + override fun test() { + TODO("not implemented") //To change body of created functions use File | Settings | File Templates. + } + +} \ No newline at end of file diff --git a/kotlin/src/main/mis/com/eastwood/demo/kotlin/IKotlin.kt b/kotlin/src/main/mis/com/eastwood/demo/kotlin/IKotlin.kt new file mode 100644 index 0000000..5a22eff --- /dev/null +++ b/kotlin/src/main/mis/com/eastwood/demo/kotlin/IKotlin.kt @@ -0,0 +1,14 @@ +package com.eastwood.demo.kotlin + +/** + * + * @author eastwood + * createDate: 2019-01-21 + */ +interface IKotlin { + + var javaObject:JavaObject + + fun test() + +} \ No newline at end of file diff --git a/kotlin/src/main/mis/com/eastwood/demo/kotlin/IKotlin1.kt b/kotlin/src/main/mis/com/eastwood/demo/kotlin/IKotlin1.kt new file mode 100644 index 0000000..409821e --- /dev/null +++ b/kotlin/src/main/mis/com/eastwood/demo/kotlin/IKotlin1.kt @@ -0,0 +1,10 @@ +package com.eastwood.demo.kotlin + +/** + * + * @author eastwood + * createDate: 2019-01-21 + */ +interface IKotlin1 { + fun test() +} \ No newline at end of file diff --git a/kotlin/src/main/mis/com/eastwood/demo/kotlin/JavaObject.java b/kotlin/src/main/mis/com/eastwood/demo/kotlin/JavaObject.java new file mode 100644 index 0000000..eca43b9 --- /dev/null +++ b/kotlin/src/main/mis/com/eastwood/demo/kotlin/JavaObject.java @@ -0,0 +1,24 @@ +package com.eastwood.demo.kotlin; + +/** + * @author eastwood + * createDate: 2019-01-21 + */ +public class JavaObject implements IKotlin { + + @Override + public JavaObject getJavaObject() { + return null; + } + + @Override + public void setJavaObject(JavaObject javaObject) { + + } + + @Override + public void test() { + + } + +} diff --git a/kotlin/src/main/res/values/strings.xml b/kotlin/src/main/res/values/strings.xml new file mode 100644 index 0000000..67b44b1 --- /dev/null +++ b/kotlin/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + kotlin + diff --git a/kotlin/src/test/java/com/eastwood/demo/kotlin/ExampleUnitTest.java b/kotlin/src/test/java/com/eastwood/demo/kotlin/ExampleUnitTest.java new file mode 100644 index 0000000..b0e41c7 --- /dev/null +++ b/kotlin/src/test/java/com/eastwood/demo/kotlin/ExampleUnitTest.java @@ -0,0 +1,17 @@ +package com.eastwood.demo.kotlin; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * Example local unit test, which will execute on the development machine (host). + * + * @see Testing documentation + */ +public class ExampleUnitTest { + @Test + public void addition_isCorrect() { + assertEquals(4, 2 + 2); + } +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 9c9c4e7..9f5dfdd 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,4 +1,4 @@ includeBuild './mis-plugin' include ':mis-core' -include ':app', ':library', ':micro-module' \ No newline at end of file +include ':app', ':library', ':micro-module', ':kotlin' \ No newline at end of file