Skip to content

Commit 324537b

Browse files
committed
Change uploadArchives task to publish jar file
removed dependency on resource value
1 parent e5303b3 commit 324537b

File tree

6 files changed

+61
-7
lines changed

6 files changed

+61
-7
lines changed

StudyplusAndroidSDK/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,11 @@ dependencies {
3434
forTesting.each{ instrumentTestCompile it }
3535
}
3636

37+
apply from: 'gradle/build.values.gradle'
38+
3739
if (gradle.startParameter.taskNames.contains('uploadArchives')) {
3840
apply from: 'gradle/build.publish.gradle'
3941
}
40-
4142
android.libraryVariants.all { variant ->
4243
def name = variant.name
4344
task "javadoc-$name"(type: Javadoc) {

StudyplusAndroidSDK/gradle.properties.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ signing.secretKeyRingFile=__your_value__
44

55
sonatypeUsername=__your_value__
66
sonatypePassword=__your_value__
7+
8+
debugApiEndPoint = __your_value__

StudyplusAndroidSDK/gradle/build.publish.gradle

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,30 @@ signing {
55
sign configurations.archives
66
}
77

8+
task sdkJar(type: Jar) {
9+
from fileTree(dir: 'build/classes/release').matching { include 'jp/studyplus/android/sdk/**' }
10+
}
11+
12+
task androidJavadocs(type: Javadoc) {
13+
source = android.sourceSets.main.allJava
14+
}
15+
16+
task androidJavadocsJar(type: Jar) {
17+
classifier = 'javadoc'
18+
from androidJavadocs.destinationDir
19+
}
20+
21+
task androidSourcesJar(type: Jar) {
22+
classifier = 'sources'
23+
from android.sourceSets.main.allSource
24+
}
25+
26+
artifacts {
27+
archives sdkJar
28+
archives androidSourcesJar
29+
archives androidJavadocsJar
30+
}
31+
832
uploadArchives {
933
repositories {
1034
mavenDeployer {
@@ -21,7 +45,6 @@ uploadArchives {
2145
pom.artifactId = "studyplus-android-sdk"
2246
pom.project {
2347
name 'Studyplus Android SDK'
24-
packaging 'aar'
2548
description 'Studyplus SDK for Android'
2649
url 'https://github.com/studyplus/Studyplus-Android-SDK'
2750
scm {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
def apiEndPoint = {
3+
def debugTasks = [
4+
':SDKExample:assembleDevelopmentDebug',
5+
]
6+
def isCurrentTaskForDebug = {
7+
debugTasks.any {
8+
gradle.startParameter.taskNames.contains it
9+
}
10+
}
11+
if (isCurrentTaskForDebug()){
12+
project.properties.debugApiEndPoint
13+
} else {
14+
"https://external-api.studyplus.jp"
15+
}
16+
}
17+
18+
android{
19+
def quote = { '"' + it + '"' }
20+
release {
21+
buildConfigField "String", "API_ENDPOINT", quote(apiEndPoint())
22+
}
23+
/**
24+
* CAUTION: this debug `buildConfigField` does NOT work!
25+
* rf. https://code.google.com/p/android/issues/detail?id=52962
26+
*/
27+
debug {
28+
buildConfigField "String", "API_ENDPOINT", quote(project.properties.debugApiEndPoint)
29+
}
30+
}

StudyplusAndroidSDK/src/main/java/jp/studyplus/android/sdk/service/auth/CertificationStore.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import com.google.common.base.Optional;
99

10-
import jp.studyplus.android.sdk.R;
10+
import jp.studyplus.android.sdk.BuildConfig;
1111
import jp.studyplus.android.sdk.service.api.ApiCertification;
1212

1313
import static android.content.SharedPreferences.Editor;
@@ -19,18 +19,17 @@ public class CertificationStore {
1919
private final SharedPreferences preferences;
2020

2121
private static String KEY_ACCESS_TOKEN = "access_token";
22-
private final String baseUrl;
22+
private static final String baseUrl = BuildConfig.API_ENDPOINT;
2323

2424
public static CertificationStore create(Context context) {
25-
String baseUrl = context.getString(R.string.studyplus_api_base_url);
2625
String prefName = "Certification:" + Uri.parse(baseUrl).getHost();
2726
SharedPreferences pref = context.getSharedPreferences(prefName, Context.MODE_PRIVATE);
2827
return new CertificationStore(pref, baseUrl);
2928
}
3029
private CertificationStore(SharedPreferences preferences, String baseUrl) {
3130
this.preferences = preferences;
32-
this.baseUrl = baseUrl;
3331
}
32+
3433
public void update(Intent data){
3534
if (data == null){
3635
return;
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
<resources>
22
<string name="app_name">StudyplusAndroidSDK</string>
3-
<string name="studyplus_api_base_url">https://external-api.studyplus.jp</string>
43
</resources>

0 commit comments

Comments
 (0)