Skip to content

Commit b641f18

Browse files
authored
Merge pull request #33 from readdle/feature/migrate-to-maven-central
Migrate to Maven Central
2 parents 35ff41c + ca10127 commit b641f18

File tree

11 files changed

+147
-112
lines changed

11 files changed

+147
-112
lines changed

.github/workflows/android_x86.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Android CI x86
22

3-
on: [push]
3+
on: [pull_request]
44

55
jobs:
66
build:
@@ -20,9 +20,10 @@ jobs:
2020
run: wget https://dl.google.com/android/repository/android-ndk-r17c-darwin-x86_64.zip;
2121
unzip android-ndk-r17c-darwin-x86_64.zip
2222
- name: Install Swift Android Toolchain
23-
run: SWIFT_ANDROID=$(curl -fsSL https://api.bintray.com/packages/readdle/swift-android-toolchain/swift-android-toolchain/versions/_latest | python -c 'import json,sys;print(json.load(sys.stdin))["name"]');
24-
wget https://dl.bintray.com/readdle/swift-android-toolchain/swift-android-$SWIFT_ANDROID.zip;
23+
run: SWIFT_ANDROID=$(curl --silent "https://api.github.com/repos/readdle/swift-android-toolchain/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/');
24+
wget https://github.com/readdle/swift-android-toolchain/releases/latest/download/swift-android-$SWIFT_ANDROID.zip;
2525
unzip swift-android-$SWIFT_ANDROID.zip;
26+
rm -rf swift-android-$SWIFT_ANDROID.zip;
2627
swift-android-$SWIFT_ANDROID/bin/swift-android tools --update;
2728
ln -sfn swift-android-$SWIFT_ANDROID swift-android-current
2829
- name: Download Android Emulator

.github/workflows/android_x86_64.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Android CI x86_64
22

3-
on: [push]
3+
on: [pull_request]
44

55
jobs:
66
build:
@@ -20,9 +20,10 @@ jobs:
2020
run: wget https://dl.google.com/android/repository/android-ndk-r17c-darwin-x86_64.zip;
2121
unzip android-ndk-r17c-darwin-x86_64.zip
2222
- name: Install Swift Android Toolchain
23-
run: SWIFT_ANDROID=$(curl -fsSL https://api.bintray.com/packages/readdle/swift-android-toolchain/swift-android-toolchain/versions/_latest | python -c 'import json,sys;print(json.load(sys.stdin))["name"]');
24-
wget https://dl.bintray.com/readdle/swift-android-toolchain/swift-android-$SWIFT_ANDROID.zip;
23+
run: SWIFT_ANDROID=$(curl --silent "https://api.github.com/repos/readdle/swift-android-toolchain/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/');
24+
wget https://github.com/readdle/swift-android-toolchain/releases/latest/download/swift-android-$SWIFT_ANDROID.zip;
2525
unzip swift-android-$SWIFT_ANDROID.zip;
26+
rm -rf swift-android-$SWIFT_ANDROID.zip;
2627
swift-android-$SWIFT_ANDROID/bin/swift-android tools --update;
2728
ln -sfn swift-android-$SWIFT_ANDROID swift-android-current
2829
- name: Download Android Emulator

bintray-publish.gradle

Lines changed: 0 additions & 61 deletions
This file was deleted.

build.gradle

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
buildscript {
2-
ext.kotlin_version = '1.4.21'
2+
ext.kotlin_version = '1.4.31'
33

44
repositories {
55
google()
6-
jcenter()
7-
mavenLocal()
8-
maven { url "https://dl.bintray.com/readdle/maven" }
6+
mavenCentral()
7+
maven {
8+
url "https://plugins.gradle.org/m2/"
9+
}
910
}
1011

1112
dependencies {
12-
classpath 'com.android.tools.build:gradle:4.1.2'
13-
classpath "com.readdle.android.swift:gradle:1.3.4"
13+
classpath 'com.android.tools.build:gradle:4.2.0'
14+
classpath "com.readdle.android.swift:gradle:1.3.5"
1415
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1516
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
16-
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4"
17+
classpath 'io.github.gradle-nexus:publish-plugin:1.1.0'
1718
}
1819
}
1920

@@ -23,11 +24,18 @@ subprojects { project ->
2324

2425
repositories {
2526
google()
26-
jcenter()
27-
maven { url "https://dl.bintray.com/readdle/maven" }
27+
mavenCentral()
2828
}
2929
}
3030

3131
task clean(type: Delete) {
3232
delete rootProject.buildDir
3333
}
34+
35+
apply plugin: 'io.github.gradle-nexus.publish-plugin'
36+
apply from: "${rootDir}/publish-root.gradle"
37+
38+
ext {
39+
PUBLISH_GROUP_ID = 'com.readdle.swift.java.codegen'
40+
PUBLISH_VERSION = "0.9.2"
41+
}

compiler/build.gradle

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
1-
apply plugin: 'java'
1+
apply plugin: 'java-library'
2+
apply plugin: 'maven-publish'
23

34
archivesBaseName = "compiler"
45

56
dependencies {
6-
implementation project(':library')
7-
implementation 'com.google.code.gson:gson:2.8.6'
7+
api project(':library')
8+
api 'com.google.code.gson:gson:2.8.6'
89
}
910

10-
apply from: rootProject.file('bintray-publish.gradle')
11+
java {
12+
sourceCompatibility = JavaVersion.VERSION_1_8
13+
targetCompatibility = JavaVersion.VERSION_1_8
14+
15+
withSourcesJar()
16+
withJavadocJar()
17+
}
18+
19+
ext {
20+
PUBLISH_ARTIFACT_ID = 'compiler'
21+
}
22+
23+
apply from: "${rootProject.projectDir}/publish-module.gradle"

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip

library/build.gradle

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
apply plugin: 'java'
1+
apply plugin: 'java-library'
2+
apply plugin: 'maven-publish'
23

34
archivesBaseName = "annotations"
45

5-
apply from: rootProject.file('bintray-publish.gradle')
6+
java {
7+
sourceCompatibility = JavaVersion.VERSION_1_8
8+
targetCompatibility = JavaVersion.VERSION_1_8
9+
10+
withSourcesJar()
11+
withJavadocJar()
12+
}
13+
14+
ext {
15+
PUBLISH_ARTIFACT_ID = 'annotations'
16+
}
17+
18+
apply from: "${rootProject.projectDir}/publish-module.gradle"

publish-module.gradle

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
apply plugin: 'maven-publish'
2+
apply plugin: 'signing'
3+
4+
group = PUBLISH_GROUP_ID
5+
version = PUBLISH_VERSION
6+
7+
afterEvaluate {
8+
publishing {
9+
publications {
10+
release(MavenPublication) {
11+
from components.java
12+
13+
groupId PUBLISH_GROUP_ID
14+
artifactId PUBLISH_ARTIFACT_ID
15+
version PUBLISH_VERSION
16+
17+
pom {
18+
name = PUBLISH_ARTIFACT_ID
19+
description = 'Swift Java codegen'
20+
url = 'https://github.com/readdle/swift-java-codegen'
21+
licenses {
22+
license {
23+
name = 'MIT License'
24+
url = 'https://github.com/readdle/swift-java-codegen/blob/master/LICENSE'
25+
}
26+
}
27+
developers {
28+
developer {
29+
id = 'andriydruk'
30+
name = 'Andrew Druk'
31+
email = 'adruk@readdle.com'
32+
}
33+
}
34+
scm {
35+
connection = 'scm:git:github.com/readdle/swift-java-codegen.git'
36+
developerConnection = 'scm:git:ssh://github.com/readdle/swift-java-codegen.git'
37+
url = 'https://github.com/readdle/swift-java-codegen'
38+
}
39+
}
40+
}
41+
}
42+
}
43+
}
44+
45+
ext["signing.keyId"] = rootProject.ext["signing.keyId"]
46+
ext["signing.password"] = rootProject.ext["signing.password"]
47+
ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"]
48+
49+
signing {
50+
sign publishing.publications
51+
}

publish-root.gradle

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Create variables with empty default values
2+
ext["signing.keyId"] = ''
3+
ext["signing.password"] = ''
4+
ext["signing.secretKeyRingFile"] = ''
5+
ext["ossrhUsername"] = ''
6+
ext["ossrhPassword"] = ''
7+
ext["sonatypeStagingProfileId"] = ''
8+
9+
File secretPropsFile = project.rootProject.file('local.properties')
10+
if (secretPropsFile.exists()) {
11+
// Read local.properties file first if it exists
12+
Properties p = new Properties()
13+
new FileInputStream(secretPropsFile).withCloseable { is -> p.load(is) }
14+
p.each { name, value -> ext[name] = value }
15+
} else {
16+
// Use system environment variables
17+
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME')
18+
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD')
19+
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID')
20+
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID')
21+
ext["signing.password"] = System.getenv('SIGNING_PASSWORD')
22+
ext["signing.secretKeyRingFile"] = System.getenv('SIGNING_SECRET_KEY_RING_FILE')
23+
}
24+
25+
// Set up Sonatype repository
26+
nexusPublishing {
27+
repositories {
28+
sonatype {
29+
stagingProfileId = sonatypeStagingProfileId
30+
username = ossrhUsername
31+
password = ossrhPassword
32+
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
33+
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
34+
}
35+
}
36+
}

sample/build.gradle

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ apply plugin: 'com.android.application'
22
apply plugin: 'com.readdle.android.swift'
33

44
apply plugin: 'kotlin-android'
5-
apply plugin: 'kotlin-android-extensions'
65
apply plugin: 'kotlin-kapt'
76

87
swift {
@@ -42,48 +41,22 @@ android {
4241
jniDebuggable false
4342
minifyEnabled false
4443
shrinkResources false
45-
ndk {
46-
abiFilters = ["armeabi-v7a", "arm64-v8a", "x86", "x86_64"]
47-
}
4844
}
4945
debug {
5046
debuggable true
5147
jniDebuggable true
5248
minifyEnabled false
5349
shrinkResources false
54-
ndk {
55-
abiFilters = ["x86", "x86_64"]
56-
}
5750
}
5851
}
59-
60-
// Configure only for each module that uses Java 8
61-
// language features (either in its source code or
62-
// through dependencies).
63-
compileOptions {
64-
sourceCompatibility JavaVersion.VERSION_1_8
65-
targetCompatibility JavaVersion.VERSION_1_8
66-
}
67-
// For Kotlin projects
68-
kotlinOptions {
69-
jvmTarget = "1.8"
70-
}
71-
}
72-
73-
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
74-
kotlinOptions {
75-
jvmTarget = '1.8'
76-
freeCompilerArgs += '-Xuse-experimental=kotlin.ExperimentalUnsignedTypes'
77-
}
7852
}
7953

8054
dependencies {
8155
kapt project(':compiler')
8256
implementation project(':library')
8357

8458
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
85-
testImplementation 'junit:junit:4.13.1'
86-
androidTestImplementation 'androidx.annotation:annotation:1.1.0'
59+
testImplementation 'junit:junit:4.13.2'
8760
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
8861
androidTestImplementation 'androidx.test:rules:1.3.0'
8962
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

sample/src/main/swift/Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ let package = Package(
5555
dependencies: [
5656
.package(url: "https://github.com/readdle/java_swift.git", .upToNextMinor(from: "2.1.8")),
5757
.package(url: "https://github.com/readdle/swift-java.git", .upToNextMinor(from: "0.2.2")),
58-
.package(url: "https://github.com/readdle/swift-java-coder.git", .branch("dev/32-bit-support")),
58+
.package(url: "https://github.com/readdle/swift-java-coder.git", .branch("dev/kotlin-support")),
5959
.package(url: "https://github.com/readdle/swift-anycodable.git", .upToNextMinor(from: "1.0.3")),
6060
],
6161
targets: addGenerated([

0 commit comments

Comments
 (0)