Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adding ability to publish to maven central #5

Merged
merged 4 commits into from
Mar 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
compileSdkVersion versions.android.compileSdk
buildToolsVersion versions.android.buildTools

defaultConfig {
applicationId "com.google.android_maps_utils_ktx"
minSdkVersion 21
targetSdkVersion 29
minSdkVersion versions.android.minSdk
targetSdkVersion versions.android.targetSdk
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
Expand All @@ -39,10 +41,12 @@ android {

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$versions.kotlin"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation deps.kotlin
implementation deps.androidx.appcompat
implementation deps.androidx.coreKtx

// Tests
testImplementation deps.junit
androidTestImplementation deps.androidx.junit
androidTestImplementation deps.androidx.espresso
}
92 changes: 92 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,17 @@

buildscript {
ext.versions = [
'android' : [
"buildTools": "29.0.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way to pull these from the android-maps-utils Java library? Keeping these in sync will be a pain.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I can think of. As long as we keep the dependencies really light (i.e. maps-utils-ktx should only depend on AMU and kotlin-specific libs) keeping them in sync shouldn't be too much of a hassle.

That said, I'll remove appcompat as a dependency since it doesn't really need it. Eventually playServicesMaps and kotlinxCoroutines should be removed too and instead be a dependency on a maps-ktx module (i.e. KTX for Maps Core).

"compileSdk": 29,
"minSdk" : 15,
"targetSdk" : 29
],
'androidMapsUtils' : '1.0.0',
'androidx' : [
'appcompat': '1.1.0',
'coreKtx' : '1.2.0',
'espresso' : '3.2.0',
'test' : '1.2.0',
'junit' : '1.1.1',
],
Expand All @@ -34,6 +42,8 @@ buildscript {
'androidMapsUtils' : "com.google.maps.android:android-maps-utils:$versions.androidMapsUtils",
'androidx' : [
'appcompat': "androidx.appcompat:appcompat:$versions.androidx.appcompat",
'coreKtx' : "androidx.core:core-ktx:$versions.androidx.coreKtx",
'espresso' : "androidx.test.espresso:espresso-core:$versions.androidx.espresso",
'test' : "androidx.test:core:$versions.androidx.test",
'junit' : "androidx.test.ext:junit:$versions.androidx.junit"
],
Expand All @@ -57,11 +67,93 @@ buildscript {
}
}

ext.projectArtifactId = { project ->
if (project.name == 'maps-utils-ktx') {
return project.name
} else {
return null
}
}

/**
* Shared configs across subprojects
*/
allprojects {
group = 'com.google.maps.android'
project.ext.artifactId = rootProject.ext.projectArtifactId(project)
version = '0.1'

repositories {
google()
jcenter()
}
}

/**
* Publishing and signing info
*/
subprojects { project ->
if (project.ext.artifactId == null) return

apply plugin: 'maven-publish'
apply plugin: 'signing'

publishing {
publications {
aar(MavenPublication) {
groupId project.group
artifactId project.ext.artifactId
version project.version

pom {
scm {
connection = 'scm:[email protected]:googlemaps/android-maps-ktx.git'
developerConnection = 'scm:[email protected]:googlemaps/android-maps-ktx.git'
url = 'https://github.com/googlemaps/android-maps-ktx'
}

licenses {
license {
name = 'The Apache Software License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution = 'repo'
}
}

organization {
name = 'Google Inc'
url = 'http://developers.google.com/maps'
}

developers {
developer {
name = 'Google Inc.'
}
}
}

afterEvaluate {
artifact "$buildDir/outputs/aar/$project.name-release.aar"
artifact dokkaJar
artifact sourcesJar
}
}
}
}

repositories {
maven {
name = "mavencentral"
url = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
credentials {
username sonatypeUsername
password sonatypePassword
}
}
}

signing {
sign publishing.publications.aar
}
}

Expand Down
9 changes: 9 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@ android.useAndroidX=true
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official

# variables required to allow build.gradle to parse,
# override in ~/.gradle/gradle.properties
signing.keyId=
signing.password=
signing.secretKeyRingFile=

sonatypeUsername=
sonatypePassword=
File renamed without changes.
21 changes: 14 additions & 7 deletions lib/build.gradle → maps-utils-ktx/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@ apply plugin: 'kotlin-android-extensions'
apply plugin: 'org.jetbrains.dokka'

android {
compileSdkVersion 29
buildToolsVersion "29.0.3"

compileSdkVersion versions.android.compileSdk
buildToolsVersion versions.android.buildTools

defaultConfig {
minSdkVersion 15
targetSdkVersion 29
minSdkVersion versions.android.minSdk
targetSdkVersion versions.android.targetSdk
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
}
Expand All @@ -47,7 +45,6 @@ android {
dependencies {
api deps.kotlin
implementation deps.androidMapsUtils
implementation deps.androidx.appcompat
implementation deps.playServicesMaps
implementation deps.kotlinxCoroutines

Expand Down Expand Up @@ -80,3 +77,13 @@ jacoco {
tasks.withType(Test) {
jacoco.includeNoLocationClasses = true
}

task sourcesJar(type: Jar) {
from android.sourceSets.main.java.source
archiveClassifier = "sources"
}

task dokkaJar(type: Jar, dependsOn: dokka) {
from dokka.outputDirectory
archiveClassifier = "javadoc"
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package com.google.maps.android.ktx.geometry

import com.google.maps.android.geometry.Point
import junit.framework.Assert.assertEquals
import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test

Expand All @@ -34,12 +34,12 @@ class PointTest {
@Test
fun `destructure x`() {
val (x, _) = point
assertEquals(1.0, x)
assertEquals(1.0, x, 1e-6)
}

@Test
fun `destructure y`() {
val (_, y) = point
assertEquals(2.0, y)
assertEquals(2.0, y, 1e-6)
}
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include ':app', ':lib'
include ':app', ':maps-utils-ktx'
rootProject.name='android-maps-utils-ktx'