Skip to content

Commit

Permalink
Fix multiplatform support (#8)
Browse files Browse the repository at this point in the history
* Fix kotlin multiplatform and added an example

* Removed android target source at this moment

* Remove unnecessary iOS project in multiplatform example

* Fix travis file and added next release

* Add android to travis

* Fix kotlin-example

* Remove unnecessary repositories

* Fix Travis CI integration (#9)

* Update travis file

* Add licenses configuration

* Add missing build tool

* Apply review suggestions
  • Loading branch information
tonilopezmr authored Oct 14, 2019
1 parent e3ea934 commit 93a89b3
Show file tree
Hide file tree
Showing 51 changed files with 766 additions and 47 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ root = true
end_of_line = lf
insert_final_newline = true

[*.{kt,kts}]
[*.{kt, kts}]
indent_size = 2
insert_final_newline = false
max_line_length=100
max_line_length = 100
27 changes: 21 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
language: java

jdk:
- oraclejdk11
language: android
dist: trusty
android:
components:
- tools
- platform-tools
- build-tools-28.0.0-rc02
- build-tools-28.0.3
- build-tools-27.0.3
- android-27
- android-28
- extra-android-support
- extra-google-m2repository
- extra-android-m2repository
licenses:
- 'android-sdk-preview-license-52d11cd2'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'

script:
- ./gradlew ktlint test install --info
- ./gradlew install
- cd example
- cd examples/kotlin-example
- ./gradlew test --info
- cd ../multiplatform-example
- ./gradlew test --info
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ buildscript {
}
dependencies {
classpath 'com.karumi.hagu:hagu:0.1.1'
classpath 'com.karumi.hagu:hagu:0.1.3-SNAPSHOT'
}
}
apply plugin: 'hagu'
apply plugin: 'com.karumi.hagu'
kotlin.sourceSets["main"].kotlin.srcDirs("$buildDir/generated/kotlin/config")
```
Expand Down
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ buildscript {

allprojects {
group 'com.karumi.hagu'
version '0.1.1'
}
version '0.1.3-SNAPSHOT'
}
File renamed without changes.
6 changes: 3 additions & 3 deletions example/build.gradle → examples/kotlin-example/build.gradle
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ buildscript {

repositories {
mavenCentral()
maven { url uri("../repo") }
maven { url uri("../../repo") }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.karumi.hagu:hagu:0.1.1'
classpath 'com.karumi.hagu:gradle-plugin:0.1.3-SNAPSHOT'
}
}

apply plugin: 'kotlin'
apply plugin: 'hagu'
apply plugin: 'com.karumi.hagu'

sourceCompatibility = 1.8

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ class MainTest {
fun `hagu configuration file should contains number key`() {
assertEquals(11, HaguConfig.NUMBER_KEY)
}

}
40 changes: 40 additions & 0 deletions examples/multiplatform-example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

logs
target
/.idea
/.idea_modules
/.classpath
/.project
/.settings
.vscode
/RUNNING_PID
**/.DS_Store
.gradle/
build
out/
.kotlintest
local.properties
*.iml
*/Pods

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
41 changes: 41 additions & 0 deletions examples/multiplatform-example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'

android {
compileSdkVersion 28

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}

lintOptions {
textOutput 'stdout'
}

defaultConfig {
minSdkVersion 14
targetSdkVersion 28

applicationId 'com.example.karumi.hagu'

versionCode 1
versionName '1.0'
}

buildTypes {
debug {
applicationIdSuffix '.development'
signingConfig signingConfigs.debug
}
}
}

dependencies {
implementation project(':shared')

implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "com.android.support:appcompat-v7:28.0.0"

testImplementation group: 'junit', name: 'junit', version: '4.12'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.karumi.hagu">

<application
android:label="@string/app_name"
android:allowBackup="false"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.example.karumi.hagu

import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.widget.TextView
import com.karumi.hagu.generated.HaguConfig

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.main_activity)

findViewById<TextView>(R.id.messageTextView).text = "$HaguConfig.API_KEY"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView
android:id="@+id/messageTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

</LinearLayout>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="app_name">Hagu example</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.karumi.hagu

import com.karumi.hagu.generated.HaguConfig

import org.junit.Test
import junit.framework.TestCase.assertEquals

class AndroidSharedTest {

@Test
fun `hagu configuration file should be accessible from android`() {
assertEquals("some_api_key", HaguConfig.API_KEY)
}

@Test
fun `hagu configuration file should contains number key`() {
assertEquals(11, HaguConfig.NUMBER_KEY)
}
}
25 changes: 25 additions & 0 deletions examples/multiplatform-example/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
buildscript {
ext.kotlin_version = '1.3.50'

repositories {
mavenCentral()
maven { url uri("../../repo") }
google()
jcenter()
maven { url 'https://plugins.gradle.org/m2/' }
}

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'com.karumi.hagu:gradle-plugin:0.1.3-SNAPSHOT'
}
}

allprojects {
repositories {
mavenCentral()
google()
jcenter()
}
}
1 change: 1 addition & 0 deletions examples/multiplatform-example/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kotlin.code.style=official
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Wed Sep 25 02:02:28 CEST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
Loading

0 comments on commit 93a89b3

Please sign in to comment.