Slide 1

Slide 1 text

Your Android 
 Open Source Library Think, Build, Ship and Tweak Sangsoo Nam [email protected]

Slide 2

Slide 2 text

Sangsoo Nam Senior Android Engineer at Spotify sangsoonam.github.io @sangsoonam

Slide 3

Slide 3 text

Open Source

Slide 4

Slide 4 text

Open Source Show your work

Slide 5

Slide 5 text

Open Source Show your work Teach others

Slide 6

Slide 6 text

Open Source Show your work Teach others Lower bugs

Slide 7

Slide 7 text

Open Source Show your work Teach others Lower bugs Upstream improvement

Slide 8

Slide 8 text

Open Source Show your work Teach others Lower bugs Great advertising Upstream improvement

Slide 9

Slide 9 text

Open Source Show your work Teach others Lower bugs It’s fun! Great advertising Upstream improvement

Slide 10

Slide 10 text

https:/ /spotify.github.io/

Slide 11

Slide 11 text

https:/ /spotify.github.io/

Slide 12

Slide 12 text

https:/ /spotify.github.io/

Slide 13

Slide 13 text

6

Slide 14

Slide 14 text

Open Source Library

Slide 15

Slide 15 text

Open Source Library Dagger2

Slide 16

Slide 16 text

Open Source Library Dagger2 Picasso

Slide 17

Slide 17 text

Open Source Library Dagger2 Picasso RxJava

Slide 18

Slide 18 text

Open Source Library Dagger2 Picasso RxJava OkHttp

Slide 19

Slide 19 text

Open Source Library Dagger2 Picasso RxJava OkHttp Guava

Slide 20

Slide 20 text

Open Source Library Dagger2 Picasso RxJava AutoValue OkHttp Guava

Slide 21

Slide 21 text

Open Source Library Dagger2 Picasso RxJava AutoValue OkHttp Guava compile ‘xxx:xxx:0.1.0’

Slide 22

Slide 22 text

Java Library

Slide 23

Slide 23 text

Think Build Ship

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

{ "items": [ ... { "uri": "spotify:track:7MHN1aCFtLXjownGhvEQlF", "attributes": { "format_attributes": [ { "key": "status", "value": "UP" }, ... ] } }, { "uri": "spotify:track:7nKBxz47S9SD79N086fuhn", "attributes": { "format_attributes": [ { "key": "status", "value": "DOWN" }, ... ] } }, { "uri": "spotify:track:3rOSwuTsUlJp0Pu0MkN8r8", "attributes": { "format_attributes": [ { "key": "status", "value": "EQUAL" }, ... ] ≈ ≈ ≈

Slide 26

Slide 26 text

if ("UP".equals(status)) { showIcon(iconUp); } else if("DOWN".equals(status)) { showIcon(iconDown); } else if("EQUAL".equals(status)) { showIcon(iconEqual); }

Slide 27

Slide 27 text

if ("UP".equals(status)) { showIcon(iconUp); } else if("DOWN".equals(status)) { showIcon(iconDown); } else if("EQUAL".equals(status)) { showIcon(iconEqual); } • Every time string comparison with “equals” method • Typo error (e.g Upper or lower case)

Slide 28

Slide 28 text

if (Status.UP == status) { showIcon(iconUp); } else if(Status.DOWN == status) { showIcon(iconDown); } else if(Status.EQUAL == status) { showIcon(iconEqual); } • No need to compare strings

Slide 29

Slide 29 text

Think Avoid comparing strings every time 
 for JSON data Build Ship

Slide 30

Slide 30 text

Ignore Case "UP" "DOWN" "EQUAL" Status.UP Status.DOWN Status.EQUAL "Up" "up" "DoWn" "down" “equaL"

Slide 31

Slide 31 text

Edge Cases "ALIEN" return null throw new EnumConstantNotPresentException()

Slide 32

Slide 32 text

Edge Cases "ALIEN" return null throw new EnumConstantNotPresentException() "SHUFFLE-PLAY" Mode.SHUFFLE_PLAY • Enum doesn’t allow “_” • Support conversion

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

No content

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

No content

Slide 43

Slide 43 text

EnumParser public enum Status { UP, DOWN, EQUAL; } @Test public void testEnumParser() { assertThat(EnumParser.forClass(Status.class).parse("UP")).isSameAs(Status.UP); assertThat(EnumParser.forClass(Status.class).parse("up")).isSameAs(Status.UP); assertThat(EnumParser.forClass(Status.class).parse("uP")).isSameAs(Status.UP); assertThat(EnumParser.forClass(Status.class).parse("DOWN")).isSameAs(Status.DOWN); assertThat(EnumParser.forClass(Status.class).parse("EQUAL")).isSameAs(Status.EQUAL); }

Slide 44

Slide 44 text

EnumParser @Test public void testEnumParser() { assertThat(EnumParser.forClass(Status.class).parse("ALIEN")).isNull(); } @Test(expected = EnumConstantNotPresentException.class) public void testEnumParserStrict() { EnumParser.forClass(Status.class).parseStrict("ALIEN") } @Test public void testEnumParserVariation() { EnumParser enumParser = EnumParser.forClass(Mode.class).withVariation( (mode) -> mode.name().replaceAll("_", "-") ); assertThat(enumParser.parse("SHUFFLE_PLAY")).isSameAs(Mode.SHUFFLE_PLAY); assertThat(enumParser.parse("SHUFFLE-PLAY")).isSameAs(Mode.SHUFFLE_PLAY); }

Slide 45

Slide 45 text

EnumParser @Test public void testEnumParser() { assertThat(EnumParser.forClass(Status.class).parse("ALIEN")).isNull(); } @Test(expected = EnumConstantNotPresentException.class) public void testEnumParserStrict() { EnumParser.forClass(Status.class).parseStrict("ALIEN") } @Test public void testEnumParserVariation() { EnumParser enumParser = EnumParser.forClass(Mode.class).withVariation( (mode) -> mode.name().replaceAll("_", "-") ); assertThat(enumParser.parse("SHUFFLE_PLAY")).isSameAs(Mode.SHUFFLE_PLAY); assertThat(enumParser.parse("SHUFFLE-PLAY")).isSameAs(Mode.SHUFFLE_PLAY); }

Slide 46

Slide 46 text

Think Avoid comparing strings every time 
 for JSON data Build EnumParser: 
 Case insensitive parser 
 from string to Enum Ship

Slide 47

Slide 47 text

Open Source Library

Slide 48

Slide 48 text

Open Source Library

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

No content

Slide 51

Slide 51 text

No content

Slide 52

Slide 52 text

No content

Slide 53

Slide 53 text

No content

Slide 54

Slide 54 text

“Is this open source project?”

Slide 55

Slide 55 text

Licenses Exclusive copyright by default. Have to say what others can do with it.

Slide 56

Slide 56 text

MIT Apache 2.0 GPLv3 Permissions • Commercial use • Distribution • Modification • Private use • Commercial use • Distribution • Modification • Private use • Patent use • Commercial use • Distribution • Modification • Private use • Patent use Conditions • License and copyright notice • License and copyright notice • State changes • License and copyright notice • State changes • Disclose source • Same license Limitations • Liability • Warranty • Liability • Warranty • Trademark use • Liability • Warranty Weaker Stronger https:/ /choosealicense.com/licenses/

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

Document What is this project? How to use it? Is it open source? Which license? How can I contribute?

Slide 62

Slide 62 text

https:/ /www.udacity.com/course/writing-readmes--ud777

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

CI Badges Make sure every thing works after any change. Show your project is stable and well tested.

Slide 66

Slide 66 text

Build Status

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

No content

Slide 69

Slide 69 text

No content

Slide 70

Slide 70 text

.travis.yml language: java

Slide 71

Slide 71 text

No content

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

Test Coverage

Slide 76

Slide 76 text

https:/ /coveralls.io/

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

build.gradle plugins { id 'jacoco' id 'com.github.kt3k.coveralls' version '2.8.1' } … jacocoTestReport { reports { xml.enabled = true // coveralls plugin depends on xml format report html.enabled = true } }

Slide 79

Slide 79 text

.travis.yml language: java after_success: - ./gradlew test jacocoTestReport coveralls

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

No content

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

Open Source Library

Slide 85

Slide 85 text

Open Source Library

Slide 86

Slide 86 text

compile 'com.google.dagger:dagger:2.11' compile 'com.squareup.picasso:picasso:2.5.2' compile 'com.squareup.okhttp3:okhttp:3.8.1'

Slide 87

Slide 87 text

Library Repository Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY

Slide 88

Slide 88 text

Library Repository compile ’xxx:xxx:0.1.0’ Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY

Slide 89

Slide 89 text

Library Repository compile ’xxx:xxx:0.1.0’ Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY

Slide 90

Slide 90 text

Library Repository compile ’xxx:xxx:0.1.0’ JFrog Bintray 
 jcenter Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY

Slide 91

Slide 91 text

Library Repository compile ’xxx:xxx:0.1.0’ Sonatype
 Maven Central JFrog Bintray 
 jcenter Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY

Slide 92

Slide 92 text

Library Repository compile ’xxx:xxx:0.1.0’ Sonatype
 Maven Central JFrog Bintray 
 jcenter Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY

Slide 93

Slide 93 text

jcenter Maven repository hosted by JFrog Bintray. Deliver library though CDN. Largest Java Repository. Support easy way to upload
 Maven Central

Slide 94

Slide 94 text

https:/ /bintray.com

Slide 95

Slide 95 text

No content

Slide 96

Slide 96 text

No content

Slide 97

Slide 97 text

No content

Slide 98

Slide 98 text

No content

Slide 99

Slide 99 text

Maven A project management and comprehension tool providing a way to help with managing: • Builds • Dependencies • Releases • Distributions
 group_id:artifact_id:version POM(Project Object Model) file describes the project. 'com.google.dagger:dagger:2.11'

Slide 100

Slide 100 text

build.gralde apply plugin: 'maven-publish' ... ext { PUBLISH_GROUP_ID = 'io.github.sangsoonam' PUBLISH_VERSION = '0.1.0' } 
 publishing { publications { MyPublication(MavenPublication) { from components.java groupId = PUBLISH_GROUP_ID version = PUBLISH_VERSION } } }

Slide 101

Slide 101 text

Command ~/enumparser> ./gradlew publishToMavenLocal :enumparser:generatePomFileForMyPublicationPublication :enumparser:compileJava UP-TO-DATE :enumparser:processResources UP-TO-DATE :enumparser:classes UP-TO-DATE :enumparser:jar :enumparser:publishMyPublicationPublicationToMavenLocal :enumparser:publishToMavenLocal BUILD SUCCESSFUL Total time: 5.307 secs ~/enumparser> ls -al ~/.m2/repository/io/github/sangsoonam/enumparser/0.1.0 total 16 drwxr-xr-x 4 sangsoo staff 136 Aug 8 21:36 . drwxr-xr-x 5 sangsoo staff 170 Aug 8 21:36 .. -rw-r--r-- 1 sangsoo staff 2174 Aug 8 21:37 enumparser-0.1.0.jar -rw-r--r-- 1 sangsoo staff 613 Aug 8 21:37 enumparser-0.1.0.pom

Slide 102

Slide 102 text

pom.xml ~/enumparser> cat ~/.m2/repository/io/github/sangsoonam/enumparser/0.1.0/enumparser-0.1.0.pom 4.0.0 io.github.sangsoonam enumparser 0.1.0 com.google.guava guava 11.0.1 runtime

Slide 103

Slide 103 text

No content

Slide 104

Slide 104 text

No content

Slide 105

Slide 105 text

Don’t release it manually!

Slide 106

Slide 106 text

build.gralde plugins { id "com.jfrog.bintray" version "1.7" } ... bintray { user = System.getenv('BINTRAY_USER') key = System.getenv('BINTRAY_API_KEY') publications = ['MyPublication'] publish = true pkg { repo = PUBLISH_ARTIFACT_ID name = PUBLISH_ARTIFACT_ID version { name = 'v' + PUBLISH_VERSION released = new Date() } } }

Slide 107

Slide 107 text

Command ~/enumparser> ./gradlew bintrayUpload :enumparser:generatePomFileForMyPublicationPublication :enumparser:compileJava UP-TO-DATE :enumparser:processResources UP-TO-DATE :enumparser:classes UP-TO-DATE :enumparser:jar UP-TO-DATE :enumparser:javadoc UP-TO-DATE :enumparser:javadocJar UP-TO-DATE :enumparser:sourceJar UP-TO-DATE :enumparser:publishMyPublicationPublicationToMavenLocal :enumparser:bintrayUpload BUILD SUCCESSFUL Total time: 6.62 secs

Slide 108

Slide 108 text

No content

Slide 109

Slide 109 text

No content

Slide 110

Slide 110 text

No content

Slide 111

Slide 111 text

build.gralde repositories { maven { url "http://dl.bintray.com/sangsoonam/enumparser" }
 jcenter() } dependencies { compile 'io.github.sangsoonam:enumparser:0.1.0' }

Slide 112

Slide 112 text

Artifact Repository

Slide 113

Slide 113 text

Artifact Repository Maven Release .jar + pom.xml JFrog Bintray 
 jcenter

Slide 114

Slide 114 text

Artifact Repository Maven Release .jar + pom.xml JFrog Bintray 
 jcenter Your Bintray Upload

Slide 115

Slide 115 text

Artifact Repository Maven Release .jar + pom.xml JFrog Bintray 
 jcenter Your Bintray Upload Sync

Slide 116

Slide 116 text

No content

Slide 117

Slide 117 text

No content

Slide 118

Slide 118 text

No content

Slide 119

Slide 119 text

No content

Slide 120

Slide 120 text

!

Slide 121

Slide 121 text

Maven Central Maven repository hosted by Sonatype. Well known. Quite hard to start but 
 have good guidelines for releasing.

Slide 122

Slide 122 text

https:/ /issues.sonatype.org/

Slide 123

Slide 123 text

https:/ /issues.sonatype.org/

Slide 124

Slide 124 text

https:/ /issues.sonatype.org/

Slide 125

Slide 125 text

No content

Slide 126

Slide 126 text

Artifact Repository Maven Release .jar + pom.xml JFrog Bintray 
 jcenter Your Bintray Upload Sync

Slide 127

Slide 127 text

Artifact Repository Maven Release .jar + pom.xml JFrog Bintray 
 jcenter Your Bintray Upload Sync Sonatype
 Maven Central Sync

Slide 128

Slide 128 text

No content

Slide 129

Slide 129 text

No content

Slide 130

Slide 130 text

Maven Central Requirements Have source and javadoc artifacts. POM(Project Object Model) should have enough information for the project. • Project Name • Project Description • Project URL • License • SCM URL • Developer information Artifacts should be signed for validation.

Slide 131

Slide 131 text

pom.xml ~/enumparser> cat ~/.m2/repository/io/github/sangsoonam/enumparser/0.1.0/enumparser-0.1.0.pom 4.0.0 io.github.sangsoonam enumparser 0.1.0 com.google.guava guava 11.0.1 runtime

Slide 132

Slide 132 text

build.gradle task javadocJar (type: Jar, dependsOn: javadoc) { classifier "sources" from javadoc.destinationDir } task sourceJar(type: Jar) { classifier "javadoc" from sourceSets.main.allJava } publishing { publications { MyPublication(MavenPublication) { from components.java groupId = PUBLISH_GROUP_ID version = PUBLISH_VERSION artifact sourceJar artifact javadocJar } } }

Slide 133

Slide 133 text

build.gradle task javadocJar (type: Jar, dependsOn: javadoc) { classifier "sources" from javadoc.destinationDir } task sourceJar(type: Jar) { classifier "javadoc" from sourceSets.main.allJava } publishing { publications { MyPublication(MavenPublication) { from components.java groupId = PUBLISH_GROUP_ID version = PUBLISH_VERSION artifact sourceJar artifact javadocJar } } } ≈

Slide 134

Slide 134 text

build.gradle publishing { publications { MyPublication(MavenPublication) { from components.java groupId = PUBLISH_GROUP_ID version = PUBLISH_VERSION artifact sourceJar artifact javadocJar pom.withXml { asNode().children().last() + pomConfig } } } }

Slide 135

Slide 135 text

build.gradle publishing { publications { MyPublication(MavenPublication) { from components.java groupId = PUBLISH_GROUP_ID version = PUBLISH_VERSION artifact sourceJar artifact javadocJar pom.withXml { asNode().children().last() + pomConfig } } } } ≈

Slide 136

Slide 136 text

build.gradle publishing { publications { MyPublication(MavenPublication) { from components.java groupId = PUBLISH_GROUP_ID version = PUBLISH_VERSION artifact sourceJar artifact javadocJar pom.withXml { asNode().children().last() + pomConfig } } } } ≈ def pomConfig = { description(PUBLISH_DESCRIPTION){} name PUBLISH_ARTIFACT_ID url GITHUB_URL licenses { license { name 'MIT License' url ‘http://www.opensource.org/...' } } scm { url GITHUB_URL } developers { developer { name DEVELOPER_NAME } } }

Slide 137

Slide 137 text

pom.xml ~/enumparser> cat ~/.m2/repository/io/github/sangsoonam/enumparser/0.1.0/enumparser-0.1.0.pom ... Utility for parsing a string to Enum constant. enumparser https://github.com/SangsooNam/enumparser MIT License http://www.opensource.org/licenses/mit-license.php https://github.com/SangsooNam/enumparser Sangsoo Nam

Slide 138

Slide 138 text

No content

Slide 139

Slide 139 text

No content

Slide 140

Slide 140 text

No content

Slide 141

Slide 141 text

Don’t release it manually!

Slide 142

Slide 142 text

Don’t release it manually!

Slide 143

Slide 143 text

build.gralde plugins { id "com.jfrog.bintray" version "1.7" } bintray { user = System.getenv('BINTRAY_USER') key = System.getenv('BINTRAY_API_KEY') publications = ['MyPublication'] publish = true pkg { repo = PUBLISH_ARTIFACT_ID name = PUBLISH_ARTIFACT_ID version { name = 'v' + PUBLISH_VERSION released = new Date() mavenCentralSync { user = System.getenv('OSS_USER') password = System.getenv('OSS_PASSWORD') } } } }

Slide 144

Slide 144 text

build.gralde plugins { id "com.jfrog.bintray" version "1.7" } bintray { user = System.getenv('BINTRAY_USER') key = System.getenv('BINTRAY_API_KEY') publications = ['MyPublication'] publish = true pkg { repo = PUBLISH_ARTIFACT_ID name = PUBLISH_ARTIFACT_ID version { name = 'v' + PUBLISH_VERSION released = new Date() mavenCentralSync { user = System.getenv('OSS_USER') password = System.getenv('OSS_PASSWORD') } } } } ≈

Slide 145

Slide 145 text

Command ~/enumparser> ./gradlew bintrayUpload :enumparser:generatePomFileForMyPublicationPublication :enumparser:compileJava UP-TO-DATE :enumparser:processResources UP-TO-DATE :enumparser:classes UP-TO-DATE :enumparser:jar UP-TO-DATE :enumparser:javadoc UP-TO-DATE :enumparser:javadocJar UP-TO-DATE :enumparser:sourceJar UP-TO-DATE :enumparser:publishMyPublicationPublicationToMavenLocal :enumparser:bintrayUpload BUILD SUCCESSFUL Total time: 6.62 secs

Slide 146

Slide 146 text

No content

Slide 147

Slide 147 text

“jcenter should be enough to release, but good to follow 
 Maven Central requirements”

Slide 148

Slide 148 text

Android Library

Slide 149

Slide 149 text

AAR Android Archive Library. Includes resources such as layouts, drawables, strings and etc.


Slide 150

Slide 150 text

Think Build Ship

Slide 151

Slide 151 text

Duotone Image A half-tone illustration made from a single original image with two different colours.

Slide 152

Slide 152 text

Duotone Image A half-tone illustration made from a single original image with two different colours.

Slide 153

Slide 153 text

Build Ship Think Convert images as a duotone

Slide 154

Slide 154 text

No content

Slide 155

Slide 155 text

No content

Slide 156

Slide 156 text

No content

Slide 157

Slide 157 text

No content

Slide 158

Slide 158 text

No content

Slide 159

Slide 159 text

No content

Slide 160

Slide 160 text

No content

Slide 161

Slide 161 text

No content

Slide 162

Slide 162 text

No content

Slide 163

Slide 163 text

No content

Slide 164

Slide 164 text

No content

Slide 165

Slide 165 text

Sample Code

Slide 166

Slide 166 text

No content

Slide 167

Slide 167 text

No content

Slide 168

Slide 168 text

No content

Slide 169

Slide 169 text

No content

Slide 170

Slide 170 text

No content

Slide 171

Slide 171 text

No content

Slide 172

Slide 172 text

No content

Slide 173

Slide 173 text

No content

Slide 174

Slide 174 text

Build DuotoneImageView:
 Custom ImageView for Android Ship Think Convert images as a duotone

Slide 175

Slide 175 text

No content

Slide 176

Slide 176 text

No content

Slide 177

Slide 177 text

No content

Slide 178

Slide 178 text

CI Badges Make sure every thing works after any change. Show your project is stable and well tested.

Slide 179

Slide 179 text

Build Status

Slide 180

Slide 180 text

No content

Slide 181

Slide 181 text

.travis.yml language: android jdk: oraclejdk8 android: components: - tools - platform-tools - build-tools-25.0.1 - android-25 - extra-android-m2repository

Slide 182

Slide 182 text

No content

Slide 183

Slide 183 text

No content

Slide 184

Slide 184 text

Test Coverage

Slide 185

Slide 185 text

No content

Slide 186

Slide 186 text

build.gradle buildscript { dependencies { classpath 'com.dicedmelon.gradle:jacoco-android:0.1.1' } } plugins { id 'jacoco-android' id 'com.github.kt3k.coveralls' version '2.5.0-x' } android { ... testOptions { unitTests.all { jacoco { // To include Robolectric tests includeNoLocationClasses = true } } } } coveralls { jacocoReportPath = "${buildDir}/reports/jacoco/jacocoTestDebugUnitTestReport/jacocoTestDebugUnitTestReport.xml" }

Slide 187

Slide 187 text

.travis.yml language: android ... after_success: - ./gradlew testDebugUnitTest jacocoTestReport coveralls

Slide 188

Slide 188 text

No content

Slide 189

Slide 189 text

No content

Slide 190

Slide 190 text

Artifact Repository compile ’xxx:xxx:0.1.0’ Sonatype
 Maven Central JFrog Bintray 
 jcenter Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY

Slide 191

Slide 191 text

Artifact Repository compile ’xxx:xxx:0.1.0’ Sonatype
 Maven Central JFrog Bintray 
 jcenter Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY

Slide 192

Slide 192 text

No content

Slide 193

Slide 193 text

build.gralde apply plugin: 'maven-publish' ext { PUBLISH_GROUP_ID = 'io.github.sangsoonam' PUBLISH_VERSION = '0.1.1' } publishing { publications { MyPublication(MavenPublication) { groupId = PUBLISH_GROUP_ID version = PUBLISH_VERSION artifact "${project.buildDir}/outputs/aar/${project.name}-release.aar" } } } ≈

Slide 194

Slide 194 text

Command ~/duotoneimageview> ./gradlew publishToMavenLocal :duotoneimageview:generatePomFileForMyPublicationPublication :duotoneimageview:javadoc :duotoneimageview:javadocJar :duotoneimageview:sourceJar :duotoneimageview:publishMyPublicationPublicationToMavenLocal :duotoneimageview:publishToMavenLocal BUILD SUCCESSFUL Total time: 7.791 secs ~/duotoneimageview> ls -al ~/.m2/repository/io/github/sangsoonam/duotoneimageview/0.1.0 total 96 drwxr-xr-x 6 sangsoo staff 204 Aug 9 09:51 . drwxr-xr-x 4 sangsoo staff 136 Aug 9 09:51 .. -rw-r--r-- 1 sangsoo staff 16749 Aug 9 08:43 duotoneimageview-0.1.0.aar -rw-r--r-- 1 sangsoo staff 925 Aug 9 09:51 duotoneimageview-0.1.0.pom

Slide 195

Slide 195 text

No content

Slide 196

Slide 196 text

No content

Slide 197

Slide 197 text

build.gralde plugins { id "com.jfrog.bintray" version "1.7" } ... bintray { user = System.getenv('BINTRAY_USER') key = System.getenv('BINTRAY_API_KEY') publications = ['MyPublication'] publish = true pkg { repo = PUBLISH_ARTIFACT_ID name = PUBLISH_ARTIFACT_ID version { name = PUBLISH_VERSION released = new Date() } } }

Slide 198

Slide 198 text

Command ~/duotoneimageview> ./gradlew bintrayUpload :duotoneimageview:generatePomFileForMyPublicationPublication :duotoneimageview:javadoc UP-TO-DATE :duotoneimageview:javadocJar UP-TO-DATE :duotoneimageview:sourceJar UP-TO-DATE :duotoneimageview:publishMyPublicationPublicationToMavenLocal :duotoneimageview:bintrayUpload BUILD SUCCESSFUL Total time: 9.842 secs

Slide 199

Slide 199 text

No content

Slide 200

Slide 200 text

No content

Slide 201

Slide 201 text

Maven Central Requirements Have source and javadoc artifacts. POM(Project Object Model) should have enough information for the project. • Project Name • Project Description • Project URL • License • SCM URL • Developer information Artifacts should be signed for validation.

Slide 202

Slide 202 text

build.gradle task sourceJar(type: Jar) { classifier = 'sources' from android.sourceSets.main.java.srcDirs } task javadoc(type: Javadoc) { source = android.sourceSets.main.java.srcDirs classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) } task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' from javadoc.destinationDir } publishing { publications { MyPublication(MavenPublication) { groupId = PUBLISH_GROUP_ID version = PUBLISH_VERSION artifact "${project.buildDir}/outputs/aar/${project.name}-release.aar" artifact sourceJar artifact javadocJar } } }

Slide 203

Slide 203 text

build.gradle task sourceJar(type: Jar) { classifier = 'sources' from android.sourceSets.main.java.srcDirs } task javadoc(type: Javadoc) { source = android.sourceSets.main.java.srcDirs classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) } task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' from javadoc.destinationDir } publishing { publications { MyPublication(MavenPublication) { groupId = PUBLISH_GROUP_ID version = PUBLISH_VERSION artifact "${project.buildDir}/outputs/aar/${project.name}-release.aar" artifact sourceJar artifact javadocJar } } } ≈

Slide 204

Slide 204 text

build.gradle publishing { publications { MyPublication(MavenPublication) { groupId = PUBLISH_GROUP_ID version = PUBLISH_VERSION ... artifact sourceJar artifact javadocJar pom.withXml { asNode().children().last() + pomConfig } } } } ≈ def pomConfig = { description(PUBLISH_DESCRIPTION){} name PUBLISH_ARTIFACT_ID url GITHUB_URL licenses { license { name 'MIT License' url ‘http://www.opensource.org/...' } } scm { url GITHUB_URL } developers { developer { name DEVELOPER_NAME } } }

Slide 205

Slide 205 text

No content

Slide 206

Slide 206 text

build.gralde plugins { id "com.jfrog.bintray" version "1.7" } bintray { user = System.getenv('BINTRAY_USER') key = System.getenv('BINTRAY_API_KEY') publications = ['MyPublication'] publish = true pkg { repo = PUBLISH_ARTIFACT_ID name = PUBLISH_ARTIFACT_ID version { name = PUBLISH_VERSION released = new Date() mavenCentralSync { user = System.getenv('OSS_USER') password = System.getenv('OSS_PASSWORD') } } } } ≈

Slide 207

Slide 207 text

Command ~/duotoneimageview> ./gradlew bintrayUpload :duotoneimageview:generatePomFileForMyPublicationPublication :duotoneimageview:javadoc UP-TO-DATE :duotoneimageview:javadocJar UP-TO-DATE :duotoneimageview:sourceJar UP-TO-DATE :duotoneimageview:publishMyPublicationPublicationToMavenLocal :duotoneimageview:bintrayUpload BUILD SUCCESSFUL Total time: 9.842 secs

Slide 208

Slide 208 text

No content

Slide 209

Slide 209 text

No content

Slide 210

Slide 210 text

Summary • Your code is valuable for other developers. Open your code. • Don’t forget the license • Document, document and document. • Continuous Integration: building and unit testing. • Release your library: jcenter or Maven central • Tweak if you have requests or pull request. Lib App Lib Lib

Slide 211

Slide 211 text

Open source repositories • https://github.com/SangsooNam/enumparser • https://github.com/SangsooNam/duotoneimageview Questions Sangsoo Nam [email protected]

Slide 212

Slide 212 text

No content