Skip to content

Commit 4f78b90

Browse files
committed
Prepare for JitPack
1 parent 13cc2b8 commit 4f78b90

9 files changed

Lines changed: 145 additions & 53 deletions

File tree

Binary file not shown.

platform/android/MapLibreAndroid/build.gradle.kts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,30 @@ configurations {
177177
}
178178
}
179179

180+
publishing {
181+
publications {
182+
create<MavenPublication>("release") {
183+
groupId = "org.mapmetrics"
184+
artifactId = "mapmetrics"
185+
version = "1.0.2"
186+
artifact("/Users/macbook/Desktop/maplibre-native/platform/android/MapLibreAndroid/build/outputs/aar/MapLibreAndroid-drawable-release.aar")
187+
}
188+
}
189+
190+
191+
repositories {
192+
maven {
193+
name = "GitHubPackages"
194+
url = uri("https://maven.pkg.github.com/MapMetrics/mapmetrics-native-sdk")
195+
credentials {
196+
// Replace this securely via CI or environment variable
197+
username = "mranawaqas"
198+
password = "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"
199+
}
200+
}
201+
}
202+
}
203+
180204
// apply<DownloadVulkanValidationPlugin>()
181205

182206
// intentionally disabled

platform/android/MapLibreAndroid/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION_NAME=11.8.6
1+
VERSION_NAME=1.0.2
22

33
# Only build native dependencies for the current ABI
44
# See https://code.google.com/p/android/issues/detail?id=221098#c20

platform/android/MapLibreAndroid/src/main/java/org/maplibre/android/module/http/HttpRequestImpl.java

Lines changed: 69 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@
2222
import java.net.ProtocolException;
2323
import java.net.SocketException;
2424
import java.net.UnknownHostException;
25+
import java.util.ArrayList;
26+
import java.util.List;
2527
import java.util.Objects;
2628

2729
import javax.net.ssl.SSLException;
2830

2931
import okhttp3.Call;
3032
import okhttp3.Callback;
33+
import okhttp3.Cookie;
34+
import okhttp3.CookieJar;
3135
import okhttp3.Dispatcher;
3236
import okhttp3.HttpUrl;
3337
import okhttp3.OkHttpClient;
@@ -40,29 +44,74 @@
4044
public class HttpRequestImpl implements HttpRequest {
4145

4246
private static final String userAgentString = toHumanReadableAscii(
43-
String.format("%s %s (%s) Android/%s (%s)",
44-
HttpIdentifier.getIdentifier(),
45-
BuildConfig.MAPLIBRE_VERSION_STRING,
46-
BuildConfig.GIT_REVISION_SHORT,
47-
Build.VERSION.SDK_INT,
48-
Build.SUPPORTED_ABIS[0])
47+
String.format("%s %s (%s) Android/%s (%s)",
48+
HttpIdentifier.getIdentifier(),
49+
BuildConfig.MAPLIBRE_VERSION_STRING,
50+
BuildConfig.GIT_REVISION_SHORT,
51+
Build.VERSION.SDK_INT,
52+
Build.SUPPORTED_ABIS[0])
4953
);
5054

55+
private static final InMemoryCookieJar cookieJar = new InMemoryCookieJar();
56+
5157
@VisibleForTesting
52-
static final OkHttpClient DEFAULT_CLIENT = new OkHttpClient.Builder().dispatcher(getDispatcher()).build();
58+
static final OkHttpClient DEFAULT_CLIENT = new OkHttpClient.Builder()
59+
.dispatcher(getDispatcher())
60+
.cookieJar(cookieJar)
61+
.build();
5362

5463
@VisibleForTesting
5564
static Call.Factory client = DEFAULT_CLIENT;
5665

5766
private Call call;
5867

68+
// Simple in-memory cookie storage implementation
69+
private static class InMemoryCookieJar implements CookieJar {
70+
private final List<Cookie> cookies = new ArrayList<>();
71+
72+
@Override
73+
public void saveFromResponse(HttpUrl url, List<Cookie> cookies) {
74+
this.cookies.addAll(cookies);
75+
}
76+
77+
@Override
78+
public List<Cookie> loadForRequest(HttpUrl url) {
79+
List<Cookie> validCookies = new ArrayList<>();
80+
for (Cookie cookie : cookies) {
81+
if (cookie.matches(url)) {
82+
validCookies.add(cookie);
83+
}
84+
}
85+
return validCookies;
86+
}
87+
88+
public List<Cookie> getAllCookies() {
89+
return new ArrayList<>(cookies);
90+
}
91+
92+
public void clearCookies() {
93+
cookies.clear();
94+
}
95+
}
96+
97+
// Method to get all stored cookies
98+
public static List<Cookie> getAllCookies() {
99+
return cookieJar.getAllCookies();
100+
}
101+
102+
// Method to clear all stored cookies
103+
public static void clearCookies() {
104+
cookieJar.clearCookies();
105+
}
106+
59107
@Override
60108
public void executeRequest(HttpResponder httpRequest, long nativePtr, @NonNull String resourceUrl,
61109
@NonNull String dataRange, @NonNull String etag, @NonNull String modified,
62110
boolean offlineUsage) {
63111
OkHttpCallback callback = new OkHttpCallback(httpRequest);
64112
try {
65113
HttpUrl httpUrl = HttpUrl.parse(resourceUrl);
114+
HttpLogger.log(Log.WARN, String.format("[HTTP] parse resourceUrl %s", resourceUrl));
66115
if (httpUrl == null) {
67116
HttpLogger.log(Log.ERROR, String.format("[HTTP] Unable to parse resourceUrl %s", resourceUrl));
68117
return;
@@ -72,9 +121,9 @@ public void executeRequest(HttpResponder httpRequest, long nativePtr, @NonNull S
72121
resourceUrl = HttpRequestUrl.buildResourceUrl(host, resourceUrl, httpUrl.querySize(), offlineUsage);
73122

74123
final Request.Builder builder = new Request.Builder()
75-
.url(resourceUrl)
76-
.tag(resourceUrl.toLowerCase(MapLibreConstants.MAPLIBRE_LOCALE))
77-
.addHeader("User-Agent", userAgentString);
124+
.url(resourceUrl)
125+
.tag(resourceUrl.toLowerCase(MapLibreConstants.MAPLIBRE_LOCALE))
126+
.addHeader("User-Agent", userAgentString);
78127

79128
if (dataRange.length() > 0) {
80129
builder.addHeader("Range", dataRange);
@@ -99,7 +148,7 @@ public void cancelRequest() {
99148
// call can be null if the constructor gets aborted (e.g, under a NoRouteToHostException).
100149
if (call != null) {
101150
HttpLogger.log(Log.DEBUG, String.format("[HTTP] This request was cancelled (%s). This is expected for tiles"
102-
+ " that were being prefetched but are no longer needed for the map to render.", call.request().url()));
151+
+ " that were being prefetched but are no longer needed for the map to render.", call.request().url()));
103152
call.cancel();
104153
}
105154
}
@@ -157,13 +206,13 @@ public void onResponse(@NonNull Call call, @NonNull Response response) {
157206
}
158207

159208
httpRequest.onResponse(response.code(),
160-
response.header("ETag"),
161-
response.header("Last-Modified"),
162-
response.header("Cache-Control"),
163-
response.header("Expires"),
164-
response.header("Retry-After"),
165-
response.header("x-rate-limit-reset"),
166-
body);
209+
response.header("ETag"),
210+
response.header("Last-Modified"),
211+
response.header("Cache-Control"),
212+
response.header("Expires"),
213+
response.header("Retry-After"),
214+
response.header("x-rate-limit-reset"),
215+
body);
167216
}
168217

169218
private void handleFailure(@Nullable Call call, Exception e) {
@@ -179,7 +228,7 @@ private void handleFailure(@Nullable Call call, Exception e) {
179228

180229
private int getFailureType(Exception e) {
181230
if ((e instanceof NoRouteToHostException) || (e instanceof UnknownHostException) || (e instanceof SocketException)
182-
|| (e instanceof ProtocolException) || (e instanceof SSLException)) {
231+
|| (e instanceof ProtocolException) || (e instanceof SSLException)) {
183232
return CONNECTION_ERROR;
184233
} else if ((e instanceof InterruptedIOException)) {
185234
return TEMPORARY_ERROR;
@@ -202,4 +251,4 @@ private static Dispatcher getDispatcher() {
202251
}
203252
return dispatcher;
204253
}
205-
}
254+
}

platform/android/MapLibreAndroidTestApp/src/main/java/org/maplibre/android/testapp/activity/maplayout/SimpleMapActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class SimpleMapActivity : AppCompatActivity() {
3030
val key = ApiKeyUtils.getApiKey(applicationContext)
3131
if (key == null || key == "YOUR_API_KEY_GOES_HERE") {
3232
it.setStyle(
33-
Style.Builder().fromUri("https://demotiles.maplibre.org/style.json")
33+
Style.Builder().fromUri("https://gateway.mapmetrics.org/styles/?fileName=facc61a1-d7f6-4ad5-9b80-580949f35509/jim.json&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJmYWNjNjFhMS1kN2Y2LTRhZDUtOWI4MC01ODA5NDlmMzU1MDkiLCJzY29wZSI6WyJtYXBzIiwic2VhcmNoIl0sImlhdCI6MTc0NDc5MDQzOX0.kIuOVdSqr6ifYnNkrt6b2I11ySlW96H9Gg_E1UpQ_ck")
3434
)
3535
} else {
3636
val styles = Style.getPredefinedStyles()
@@ -88,4 +88,4 @@ class SimpleMapActivity : AppCompatActivity() {
8888
}
8989
return super.onOptionsItemSelected(item)
9090
}
91-
}
91+
}

platform/android/build.gradle.kts

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
11
plugins {
2+
id("maven-publish") // ✅ Add this line
23
alias(libs.plugins.nexusPublishPlugin)
34
alias(libs.plugins.kotlinter) apply false
45
alias(libs.plugins.kotlinAndroid) apply false
56
id("com.jaredsburrows.license") version "0.9.8" apply false
67
id("maplibre.dependencies")
78
id("maplibre.publish-root")
89
}
9-
10-
11-
nexusPublishing {
12-
repositories {
13-
sonatype {
14-
stagingProfileId.set(extra["sonatypeStagingProfileId"] as String?)
15-
username.set(extra["ossrhUsername"] as String?)
16-
password.set(extra["ossrhPassword"] as String?)
17-
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
18-
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
19-
}
20-
}
21-
}
10+
//nexusPublishing {
11+
// repositories {
12+
// sonatype {
13+
// stagingProfileId.set(extra["sonatypeStagingProfileId"] as String?)
14+
// username.set(extra["ossrhUsername"] as String?)
15+
// password.set(extra["ossrhPassword"] as String?)
16+
// nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
17+
// snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
18+
// }
19+
// }
20+
//}
21+
//
22+
//nexusPublishing {
23+
// repositories {
24+
// sonatype {
25+
// stagingProfileId.set(extra["sonatypeStagingProfileId"] as String?)
26+
// username.set(extra["ossrhUsername"] as String?)
27+
// password.set(extra["ossrhPassword"] as String?)
28+
// nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
29+
// snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
30+
// }
31+
// }
32+
//}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
extra["mapLibreArtifactGroupId"] = "org.maplibre.gl"
1+
extra["mapLibreArtifactGroupId"] = "org.mapmetrics"
22
extra["mapLibreArtifactId"] = "android-sdk"
3-
extra["mapLibreArtifactTitle"] = "MapLibre Android"
4-
extra["mapLibreArtifactDescription"] = "MapLibre Android"
5-
extra["mapLibreDeveloperName"] = "MapLibre"
6-
extra["mapLibreDeveloperId"] = "maplibre"
7-
extra["mapLibreArtifactUrl"] = "https://github.com/maplibre/maplibre-native"
8-
extra["mapLibreArtifactScmUrl"] = "scm:git@github.com:maplibre/maplibre-native.git"
3+
extra["mapLibreArtifactTitle"] = "MapMetrics Android"
4+
extra["mapLibreArtifactDescription"] = "MapMetrics Android"
5+
extra["mapLibreDeveloperName"] = "Mapmetrics"
6+
extra["mapLibreDeveloperId"] = "mapmetrics"
7+
extra["mapLibreArtifactUrl"] = "https://github.com/MapMetrics/mapmetrics-native-sdk.git"
8+
extra["mapLibreArtifactScmUrl"] = "git@github.com:MapMetrics/mapmetrics-native-sdk.git"
99
extra["mapLibreArtifactLicenseName"] = "BSD"
1010
extra["mapLibreArtifactLicenseUrl"] = "https://opensource.org/licenses/BSD-2-Clause"
1111

@@ -14,4 +14,4 @@ extra["versionName"] = if (project.hasProperty("VERSION_NAME")) {
1414
project.property("VERSION_NAME")
1515
} else {
1616
System.getenv("VERSION_NAME")
17-
}
17+
}

platform/android/buildSrc/src/main/kotlin/maplibre.gradle-publish.gradle.kts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ fun configureMavenPublication(
9090

9191
// workaround for https://github.com/gradle/gradle/issues/26091#issuecomment-1836156762
9292
// https://github.com/gradle-nexus/publish-plugin/issues/208
93-
tasks {
94-
withType<PublishToMavenRepository> {
95-
dependsOn(withType<Sign>())
96-
}
97-
}
93+
//tasks {
94+
// withType<PublishToMavenRepository> {
95+
// dependsOn(withType<Sign>())
96+
// }
97+
//}
9898

9999
afterEvaluate {
100100
configureMavenPublication("drawable", "opengl", "", "")
@@ -114,8 +114,11 @@ afterEvaluate {
114114
}
115115
}
116116
}
117+
tasks.named("publishReleasePublicationToGitHubPackagesRepository") {
118+
dependsOn("bundleDrawableReleaseAar")
119+
}
117120
}
118121

119-
signing {
120-
sign(publishing.publications)
121-
}
122+
//signing {
123+
// sign(publishing.publications)
124+
//}
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
//extra["signing.keyId"] = "65279219"
2+
//extra["signing.password"] = "StylEbkInDycue2_"
13
extra["signing.keyId"] = System.getenv("SIGNING_KEY_ID")
24
extra["signing.password"] = System.getenv("SIGNING_PASSWORD")
3-
extra["signing.secretKeyRingFile"] = "${projectDir}/../signing-key.gpg"
5+
extra["signing.secretKeyRingFile"] = "/Users/macbook/.gnupg/secring.gpg"
46
extra["ossrhUsername"] = System.getenv("OSSRH_USERNAME")
57
extra["ossrhPassword"] = System.getenv("OSSRH_PASSWORD")
68
extra["sonatypeStagingProfileId"] = System.getenv("SONATYPE_STAGING_PROFILE_ID")
9+
//7E5538C4FFDF39F7
10+
//gpg --armor --export 7E5538C4FFDF39F7 > mypublickey.asc
11+
//gpg --armor --export-secret-keys 7E5538C4FFDF39F7 > mysecretkey.asc

0 commit comments

Comments
 (0)