-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
retrofit & room code moved into a reusable library module.
- Loading branch information
Showing
76 changed files
with
425 additions
and
174 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,172 @@ | ||
plugins { | ||
id 'com.android.library' | ||
id 'maven-publish' | ||
} | ||
|
||
android { | ||
namespace 'io.syslogic.github.api' | ||
compileSdk 34 | ||
|
||
defaultConfig { | ||
minSdk 22 | ||
targetSdk 34 | ||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
consumerProguardFiles "consumer-rules.pro" | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_17 | ||
targetCompatibility JavaVersion.VERSION_17 | ||
} | ||
|
||
buildFeatures { | ||
buildConfig true | ||
dataBinding true | ||
} | ||
|
||
buildTypes { | ||
debug { | ||
// it breaks the data-binding, eg. when running ./gradlew :library:publishToMavenLocal | ||
testCoverageEnabled false | ||
minifyEnabled false | ||
} | ||
release { | ||
minifyEnabled false | ||
} | ||
} | ||
|
||
lint { | ||
lintConfig rootProject.file('lint.xml') | ||
checkAllWarnings true | ||
warningsAsErrors true | ||
abortOnError false | ||
showAll false | ||
} | ||
|
||
publishing { | ||
singleVariant('release') { | ||
withSourcesJar() | ||
withJavadocJar() | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
|
||
// Annotations | ||
implementation "androidx.annotation:annotation:$annotation_version" | ||
|
||
// Material Design Components | ||
implementation "com.google.android.material:material:$material_version" | ||
|
||
// App Compat | ||
implementation "androidx.appcompat:appcompat:$appcompat_version" | ||
|
||
// Data-Binding Runtime | ||
implementation "androidx.databinding:databinding-runtime:$agp_version" | ||
|
||
// Room Runtime | ||
annotationProcessor "androidx.room:room-compiler:$room_version" | ||
testImplementation "androidx.room:room-testing:$room_version" | ||
implementation "androidx.room:room-runtime:$room_version" | ||
|
||
// Retrofit2 | ||
implementation "com.google.code.gson:gson:$gson_version" | ||
implementation "com.squareup.retrofit2:retrofit:$retrofit_version" | ||
implementation ("com.squareup.retrofit2:converter-gson:$retrofit_version") { | ||
exclude group: "com.google.code.gson", module: "gson" | ||
} | ||
|
||
testImplementation 'junit:junit:4.13.2' | ||
androidTestImplementation 'androidx.test.ext:junit:1.1.5' | ||
} | ||
|
||
tasks.register('javadoc', Javadoc) { | ||
|
||
title = "GitHub API Client ${android.defaultConfig.versionName}" | ||
source = android.sourceSets.main.java.srcDirs | ||
destinationDir = file("${project.buildDir}/outputs/javadoc/") | ||
configurations.implementation.setCanBeResolved(true) | ||
classpath = files(new File("${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar")) | ||
classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) | ||
classpath += fileTree(dir: "$buildDir/tmp/aarsToJars/") | ||
classpath += configurations.implementation | ||
exclude "**/BuildConfig.java", "**/R.java" | ||
failOnError false | ||
|
||
// options.verbose() | ||
// javadoc: warning - The code being documented uses modules but the packages | ||
// defined in https://developer.android.com/reference/ are in the unnamed module. | ||
options.links "https://docs.oracle.com/en/java/javase/17/docs/api/" | ||
options.linksOffline "https://developer.android.com/reference", "${android.sdkDirectory}/docs/reference" | ||
options.linkSource true | ||
options.author true | ||
|
||
doFirst { | ||
|
||
// extract AAR files | ||
configurations.implementation.filter { it.name.endsWith('.aar') }.each { aar -> | ||
copy { | ||
from zipTree(aar) | ||
include "**/classes.jar" | ||
into "$buildDir/tmp/aarsToJars/${aar.name.replace('.aar', '')}/" | ||
} | ||
} | ||
|
||
// provide JAR, which contains the generated data-binding classes | ||
def aar_main = new File("$buildDir/intermediates/aar_main_jar") | ||
if (aar_main.exists()) { | ||
copy { | ||
from aar_main | ||
include "**/classes.jar" | ||
into "$buildDir/tmp/aarsToJars/aar_main_jar/" | ||
} | ||
} | ||
} | ||
} | ||
|
||
javadoc.onlyIf { | ||
new File("$buildDir/intermediates/aar_main_jar").exists() | ||
} | ||
|
||
tasks.register('javadocJar', Jar) { | ||
dependsOn javadoc | ||
archiveClassifier.set('javadoc') | ||
from javadoc.destinationDir | ||
} | ||
|
||
tasks.register('sourcesJar', Jar) { | ||
from android.sourceSets.main.java.srcDirs | ||
archiveClassifier.set('sources') | ||
} | ||
|
||
artifacts { | ||
archives javadocJar | ||
archives sourcesJar | ||
} | ||
|
||
group = 'io.syslogic' | ||
version = version_name | ||
|
||
afterEvaluate { | ||
publishing { | ||
publications { | ||
release(MavenPublication) { | ||
groupId = group | ||
artifactId = 'github-retrofit2-client' | ||
from components.getByName('release') | ||
version = version_name | ||
pom { | ||
name = 'GitHub API Client' | ||
description = 'A simple client library for Android' | ||
url = "https://github.com/syslogic/${artifactId}" | ||
scm { | ||
connection = "scm:git:git://github.com/syslogic/${artifactId}.git" | ||
developerConnection = "scm:git:ssh://github.com/syslogic/${artifactId}.git" | ||
url = "https://github.com/syslogic/${artifactId}/" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Empty file.
26 changes: 26 additions & 0 deletions
26
library/src/androidTest/java/io/syslogic/github/api/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,26 @@ | ||
package io.syslogic.github.api; | ||
|
||
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("io.syslogic.github.api.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,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
</manifest> |
19 changes: 19 additions & 0 deletions
19
library/src/main/java/io/syslogic/github/api/Constants.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,19 @@ | ||
package io.syslogic.github.api; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
/** | ||
* Common Constants | ||
* | ||
* @author Martin Zeitler | ||
*/ | ||
public final class Constants { | ||
@NonNull public static final String GITHUB_API_BASE_URL = "https://api.github.com/"; | ||
@NonNull public static final String GITHUB_DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; | ||
|
||
/** Table Names */ | ||
@NonNull public static final String TABLE_QUERY_STRINGS = "query_strings"; | ||
@NonNull public static final String TABLE_REPOSITORIES = "repositories"; | ||
@NonNull public static final String TABLE_LICENSES = "licenses"; | ||
@NonNull public static final String TABLE_OWNERS = "owners"; | ||
} |
23 changes: 10 additions & 13 deletions
23
...yslogic/github/retrofit/GithubClient.java → .../io/syslogic/github/api/GithubClient.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
20 changes: 9 additions & 11 deletions
20
...slogic/github/retrofit/GithubService.java → ...io/syslogic/github/api/GithubService.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
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
4 changes: 2 additions & 2 deletions
4
...ogic/github/content/IContentProvider.java → .../github/api/content/IContentProvider.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
6 changes: 3 additions & 3 deletions
6
...a/io/syslogic/github/model/BaseModel.java → .../syslogic/github/api/model/BaseModel.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
6 changes: 3 additions & 3 deletions
6
...java/io/syslogic/github/model/Branch.java → .../io/syslogic/github/api/model/Branch.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
Oops, something went wrong.