Skip to content

Commit 6d1afa9

Browse files
Added bintray configuration
1 parent 7f21409 commit 6d1afa9

File tree

12 files changed

+130
-57
lines changed

12 files changed

+130
-57
lines changed

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,26 @@
22

33
# ReactantKUtils
44
A collection of Kotlin utility methods for Android
5+
6+
7+
### License
8+
9+
Copyright 2017 Jesper Sjöquist
10+
11+
Permission is hereby granted, free of charge, to any person obtaining a
12+
copy of this software and associated documentation files (the "Software"),
13+
to deal in the Software without restriction, including without limitation
14+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
15+
and/or sell copies of the Software, and to permit persons to whom the
16+
Software is furnished to do so, subject to the following conditions:
17+
18+
The above copyright notice and this permission notice shall be included in
19+
all copies or substantial portions of the Software.
20+
21+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
26+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27+
DEALINGS IN THE SOFTWARE.

build.gradle

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ buildscript {
88
dependencies {
99
classpath 'com.android.tools.build:gradle:2.3.0'
1010
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11-
12-
// NOTE: Do not place your application dependencies here; they belong
13-
// in the individual module build.gradle files
11+
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
12+
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
1413
}
1514
}
1615

@@ -23,3 +22,10 @@ allprojects {
2322
task clean(type: Delete) {
2423
delete rootProject.buildDir
2524
}
25+
26+
// Disable JavaDoc generation
27+
subprojects {
28+
tasks.withType(Javadoc) {
29+
excludes = ['**/*.kt'] // < ---- Exclude all kotlin files from javadoc file.
30+
}
31+
}

gradle.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,9 @@ org.gradle.jvmargs=-Xmx2048m
1515
# This option should only be used with decoupled projects. More details, visit
1616
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1717
# org.gradle.parallel=true
18+
19+
20+
VERSION_CODE = 1
21+
VERSION_NAME = 0.0.2
22+
GROUP_ID = se.reactant
23+
ARTIFACT_ID = reactantutils

reactantkutils/build.gradle

Lines changed: 0 additions & 24 deletions
This file was deleted.
File renamed without changes.

reactantutils/build.gradle

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'maven-publish'
4+
5+
ext {
6+
bintrayRepo = 'maven'
7+
bintrayName = 'reactantutils'
8+
9+
publishedGroupId = project.GROUP_ID
10+
libraryName = project.ARTIFACT_ID
11+
artifact = project.ARTIFACT_ID
12+
13+
libraryDescription = 'A collection of utility methods for Android written in Kotlin'
14+
15+
siteUrl = 'https://github.com/JesperSjoquist/ReactantUtils'
16+
gitUrl = 'https://github.com/JesperSjoquist/ReactantUtils.git'
17+
18+
libraryVersion = project.VERSION_NAME
19+
20+
developerId = 'JesperSjoquist'
21+
developerName = 'Jesper Sjöquist'
22+
developerEmail = 'jesper.sjoquist@gmail.com'
23+
24+
licenseName = 'MIT'
25+
licenseUrl = 'http://www.opensource.org/licenses/mit-license.php'
26+
allLicenses = ["MIT"]
27+
}
28+
29+
android {
30+
compileSdkVersion 25
31+
buildToolsVersion "25.0.0"
32+
33+
defaultConfig {
34+
minSdkVersion 8
35+
targetSdkVersion 25
36+
versionCode project.VERSION_CODE.toInteger()
37+
versionName project.VERSION_NAME
38+
39+
}
40+
}
41+
42+
task sourceJar(type: Jar) {
43+
from android.sourceSets.main.java.srcDirs
44+
classifier "source"
45+
}
46+
47+
publishing {
48+
publications {
49+
maven(MavenPublication) {
50+
groupId project.GROUP_ID
51+
artifactId project.ARTIFACT_ID
52+
version project.VERSION_NAME
53+
artifact(sourceJar)
54+
artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
55+
}
56+
}
57+
repositories {
58+
maven {
59+
url "$buildDir/repo"
60+
}
61+
}
62+
}
63+
64+
dependencies {
65+
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
66+
compile 'com.google.code.gson:gson:2.8.0'
67+
testCompile 'junit:junit:4.12'
68+
}
69+
70+
// Upload to Bintray
71+
apply plugin: 'com.jfrog.bintray'
File renamed without changes.

reactantkutils/src/main/java/se/reactant/reactantutils/log/LogExtensions.kt renamed to reactantutils/src/main/java/se/reactant/reactantutils/log/LogExtensions.kt

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import android.util.Log
55
import org.json.JSONArray
66
import org.json.JSONException
77
import org.json.JSONObject
8-
import se.reactant.reactantutils.BuildConfig
98

109
/**
1110
* Extensions for the Android util Log class
@@ -14,43 +13,36 @@ import se.reactant.reactantutils.BuildConfig
1413

1514
const val UNKNOWN_CLASS_TAG = "UNKNOWN CLASS"
1615
const val JSON_INDENTATION = 2
17-
private var cachedCallingClassIndex = -1
1816

19-
fun i(message: String? = "", throwable: Throwable? = null, tag: String? = ""): Unit {
20-
if (BuildConfig.DEBUG) Log.i(getCaller() + tag, message, throwable)
21-
}
17+
fun i(message: String? = "", throwable: Throwable? = null, tag: String? = "") =
18+
Log.i(getCaller() + tag, message, throwable)
2219

23-
fun d(message: String? = "", throwable: Throwable? = null, tag: String? = ""): Unit {
24-
if (BuildConfig.DEBUG) Log.d(getCaller() + tag, message, throwable)
25-
}
20+
fun d(message: String? = "", throwable: Throwable? = null, tag: String? = "") =
21+
Log.d(getCaller() + tag, message, throwable)
2622

27-
fun e(message: String? = "", throwable: Throwable? = null, tag: String? = ""): Unit {
28-
if (BuildConfig.DEBUG) Log.e(getCaller() + tag, message, throwable)
29-
}
23+
fun e(message: String? = "", throwable: Throwable? = null, tag: String? = "") =
24+
Log.e(getCaller() + tag, message, throwable)
3025

31-
fun v(message: String? = "", throwable: Throwable? = null, tag: String? = ""): Unit {
32-
if (BuildConfig.DEBUG) Log.v(getCaller() + tag, message, throwable)
33-
}
26+
fun v(message: String? = "", throwable: Throwable? = null, tag: String? = "") =
27+
Log.v(getCaller() + tag, message, throwable)
3428

35-
fun w(message: String? = "", throwable: Throwable? = null, tag: String? = ""): Unit {
36-
if (BuildConfig.DEBUG) Log.w(getCaller() + tag, message, throwable)
37-
}
29+
fun w(message: String? = "", throwable: Throwable? = null, tag: String? = "") =
30+
Log.w(getCaller() + tag, message, throwable)
3831

39-
fun wtf(message: String? = "", throwable: Throwable? = null, tag: String? = ""): Unit {
40-
if (BuildConfig.DEBUG) Log.wtf(getCaller() + tag, message, throwable)
41-
}
32+
fun wtf(message: String? = "", throwable: Throwable? = null, tag: String? = "") =
33+
Log.wtf(getCaller() + tag, message, throwable)
4234

43-
fun <T>json(obj: T, throwable: Throwable? = null, tag: String? = ""): Unit {
35+
fun <T> json(obj: T, throwable: Throwable? = null, tag: String? = ""): Int {
4436
val json = if (obj is String) obj.trim() else gson.toJson(obj)
4537

4638
try {
4739
when (json?.first()) {
48-
'{' -> Log.d(getCaller() + tag, JSONObject(json).toString(JSON_INDENTATION), throwable)
49-
'[' -> Log.d(getCaller() + tag, JSONArray(json).toString(JSON_INDENTATION), throwable)
50-
else -> Log.e(getCaller() + tag, "Invalid Json", throwable)
40+
'{' -> return Log.d(getCaller() + tag, JSONObject(json).toString(JSON_INDENTATION), throwable)
41+
'[' -> return Log.d(getCaller() + tag, JSONArray(json).toString(JSON_INDENTATION), throwable)
42+
else -> return Log.e(getCaller() + tag, "Invalid Json", throwable)
5143
}
5244
} catch (e: JSONException) {
53-
Log.e(getCaller() + tag, "Invalid Json", e)
45+
return Log.e(getCaller() + tag, "Invalid Json", e)
5446
}
5547
}
5648

@@ -63,12 +55,11 @@ private fun getCaller(): String {
6355

6456
// Find the last instance of the Log class in the current stack trace
6557
// and look for the calling Class in the next position
66-
if (cachedCallingClassIndex == -1)
67-
cachedCallingClassIndex = stackTrace.indexOfLast { it.className == "Log.LogExtensionsKt" } + 1
58+
val callingClassIndex = stackTrace.indexOfLast { it.className == "Log.LogExtensionsKt" } + 1
6859

6960
// Pull the calling class from the stack trace
70-
if (cachedCallingClassIndex != -1 && stackTrace.size >= cachedCallingClassIndex) {
71-
val callingClass = stackTrace[cachedCallingClassIndex]
61+
if (callingClassIndex > 0 && stackTrace.size >= callingClassIndex) {
62+
val callingClass = stackTrace[callingClassIndex]
7263

7364
if (callingClass.className.split("").isNotEmpty()) {
7465
return "(" + callingClass.fileName + ":" + callingClass.lineNumber + ")"

0 commit comments

Comments
 (0)