-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Android now produces an SDK aar, and the samples app now uses that as…
… a dependency. Added maven publishing (#52)
- Loading branch information
Justin Boswell
authored
Apr 24, 2020
1 parent
e124a1d
commit 532c3d2
Showing
9 changed files
with
226 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
import java.util.regex.Pattern | ||
|
||
apply plugin: 'com.android.library' | ||
|
||
Properties getGitTag() { | ||
def gitTag = "git describe --tags".execute().text.trim() | ||
def version = new Properties() | ||
def versionPattern = Pattern.compile('v(\\d+).(\\d+).(\\d+)(-(.+))?') | ||
def matcher = versionPattern.matcher(gitTag) | ||
if (matcher.matches()) { | ||
version['major'] = matcher.group(1) | ||
version['minor'] = matcher.group(2) | ||
version['patch'] = matcher.group(3) | ||
try { | ||
version['tag'] = matcher.group(5) | ||
} catch (Exception ex) {} | ||
} | ||
return version | ||
} | ||
|
||
ext { | ||
gitVersionName = { | ||
def version = getGitTag() | ||
def name = "${version['major']}.${version['minor']}.${version['patch']}" | ||
return name | ||
} | ||
gitVersionCode = { | ||
def version = getGitTag() | ||
try { | ||
def major = version['major'] as int | ||
def minor = version['minor'] as int | ||
def patch = version['patch'] as int | ||
return (major * 1000) + (minor * 100) + patch | ||
} catch (Exception ex) { | ||
return 0 | ||
} | ||
} | ||
gitVersionTag = { | ||
def version = getGitTag() | ||
return version['tag'] != '' ? '-' + version['tag'] : version['tag'] | ||
} | ||
} | ||
|
||
android { | ||
compileSdkVersion 29 | ||
buildToolsVersion "29.0.3" | ||
|
||
defaultConfig { | ||
minSdkVersion 26 | ||
targetSdkVersion 29 | ||
versionCode 1 | ||
versionName "1.0" | ||
ndkVersion "21.0.6113669" | ||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles 'consumer-rules.pro' | ||
} | ||
|
||
sourceSets { | ||
main { | ||
java.srcDir '../../sdk/src/main/java' | ||
} | ||
} | ||
|
||
buildTypes { | ||
debug { | ||
versionNameSuffix = gitVersionTag() | ||
} | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
versionNameSuffix "" | ||
} | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = 1.8 | ||
targetCompatibility = 1.8 | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
maven { | ||
url System.getenv('HOME') + "/.m2/repository" | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation 'software.amazon.awssdk.crt:android:0.5.4' | ||
implementation 'com.google.code.gson:gson:2.8.5' | ||
implementation 'androidx.appcompat:appcompat:1.1.0' | ||
testImplementation 'junit:junit:4.12' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.1' | ||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | ||
} | ||
|
||
// Publishing | ||
apply plugin: 'maven-publish' | ||
|
||
// Sources | ||
task androidSourcesJar(type: Jar) { | ||
archiveClassifier.set('sources') | ||
from android.sourceSets.main.java.srcDirs | ||
} | ||
|
||
// Docs | ||
task androidDocs(type: Javadoc) { | ||
source = android.sourceSets.main.java.srcDirs | ||
classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) | ||
android.libraryVariants.all { variant -> | ||
if (variant.name == 'release') { | ||
owner.classpath += variant.javaCompileProvider.get().classpath | ||
} | ||
} | ||
exclude '**/R.html', '**/R.*.html', '**/index.html' | ||
} | ||
|
||
task androidDocsJar(type: Jar) { | ||
archiveClassifier.set('javadoc') | ||
from androidDocs.destinationDir | ||
} | ||
|
||
afterEvaluate { | ||
publishing { | ||
publications { | ||
// Creates a Maven publication called "release". | ||
release(MavenPublication) { | ||
// Applies the component for the release build variant. | ||
from components.release | ||
|
||
// You can then customize attributes of the publication as shown below. | ||
groupId = 'software.amazon.awssdk.crt.iotdevicesdk' | ||
artifactId = 'aws-iot-device-sdk' | ||
version = android.defaultConfig.versionName | ||
} | ||
// Creates a Maven publication called “debug”. | ||
debug(MavenPublication) { | ||
// Applies the component for the debug build variant. | ||
from components.debug | ||
|
||
groupId = 'software.amazon.awssdk.crt.iotdevicesdk' | ||
artifactId = 'aws-iot-device-sdk' | ||
version = android.defaultConfig.versionName + '-SNAPSHOT' | ||
} | ||
} | ||
repositories { | ||
maven { | ||
def snapshotRepo = "https://aws.oss.sonatype.org/content/repositories/snapshots" | ||
def releaseRepo = "https://aws.oss.sonatype.org/" | ||
url = version.endsWith('SNAPSHOT') ? snapshotRepo : releaseRepo | ||
} | ||
} | ||
} | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
27 changes: 27 additions & 0 deletions
27
...sdk/src/androidTest/java/software/amazon/awssdk/iotdevicesdk/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package software.amazon.awssdk.iotdevicesdk; | ||
|
||
import android.content.Context; | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry; | ||
import androidx.test.ext.junit.runners.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 <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest { | ||
@Test | ||
public void useAppContext() { | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
|
||
assertEquals("software.amazon.awssdk.iotdevicesdk.test", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="software.amazon.awssdk.iotdevicesdk" /> |
17 changes: 17 additions & 0 deletions
17
android/iotdevicesdk/src/test/java/software/amazon/awssdk/iotdevicesdk/ExampleUnitTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package software.amazon.awssdk.iotdevicesdk; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Example local unit test, which will execute on the development machine (host). | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
public class ExampleUnitTest { | ||
@Test | ||
public void addition_isCorrect() { | ||
assertEquals(4, 2 + 2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
rootProject.name='IoTSamples' | ||
include ':app' | ||
include ':iotdevicesdk' |