Skip to content

Commit 36f1103

Browse files
authored
Set up Maven publishing rules. (#706)
Setting up to do a new release, this adds build system rules so we can release the following libraries - `identity` - `identity-mdoc` - `identity-doctypes` - `identity-android` - `identity-android-legacy` - `processor-annotations` This change also ports `identity-doctypes` to Kotlin Multiplatform. Test: ./gradlew check Test: ./gradlew connectedCheck Test: Manully tested with artifacts from "./gradlew publishToMavenLocal" in out-of-tree version of samples/simple-verifier. Signed-off-by: David Zeuthen <zeuthen@google.com>
1 parent d8222f5 commit 36f1103

File tree

14 files changed

+278
-140
lines changed

14 files changed

+278
-140
lines changed

identity-android-legacy/build.gradle.kts

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
plugins {
22
alias(libs.plugins.androidLibrary)
33
id("kotlin-android")
4+
id("maven-publish")
45
}
56

7+
val projectVersionCode: Int by rootProject.extra
8+
val projectVersionName: String by rootProject.extra
9+
610
kotlin {
711
jvmToolchain(17)
812
}
@@ -13,8 +17,6 @@ android {
1317

1418
defaultConfig {
1519
minSdk = libs.versions.android.minSdk.get().toInt()
16-
targetSdk = libs.versions.android.targetSdk.get().toInt()
17-
1820
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
1921
}
2022

@@ -29,6 +31,12 @@ android {
2931
excludes += listOf("/META-INF/versions/9/OSGI-INF/MANIFEST.MF")
3032
}
3133
}
34+
35+
publishing {
36+
singleVariant("release") {
37+
withSourcesJar()
38+
}
39+
}
3240
}
3341

3442
dependencies {
@@ -48,3 +56,31 @@ dependencies {
4856
androidTestImplementation(libs.androidx.test.junit)
4957
androidTestImplementation(libs.androidx.espresso.core)
5058
}
59+
60+
group = "com.android.identity"
61+
version = projectVersionName
62+
63+
publishing {
64+
repositories {
65+
maven {
66+
url = uri("${rootProject.rootDir}/repo")
67+
}
68+
}
69+
publications {
70+
create<MavenPublication>("release") {
71+
afterEvaluate {
72+
from(components["release"])
73+
}
74+
}
75+
}
76+
publications.withType(MavenPublication::class) {
77+
pom {
78+
licenses {
79+
license {
80+
name = "Apache 2.0"
81+
url = "https://opensource.org/licenses/Apache-2.0"
82+
}
83+
}
84+
}
85+
}
86+
}

identity-android/build.gradle.kts

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
plugins {
22
alias(libs.plugins.androidLibrary)
33
id("kotlin-android")
4+
id("maven-publish")
45
}
56

7+
val projectVersionCode: Int by rootProject.extra
8+
val projectVersionName: String by rootProject.extra
9+
610
kotlin {
711
jvmToolchain(17)
812
}
@@ -13,8 +17,6 @@ android {
1317

1418
defaultConfig {
1519
minSdk = libs.versions.android.minSdk.get().toInt()
16-
targetSdk = libs.versions.android.targetSdk.get().toInt()
17-
1820
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
1921
}
2022

@@ -29,6 +31,12 @@ android {
2931
excludes += listOf("/META-INF/versions/9/OSGI-INF/MANIFEST.MF")
3032
}
3133
}
34+
35+
publishing {
36+
singleVariant("release") {
37+
withSourcesJar()
38+
}
39+
}
3240
}
3341

3442
dependencies {
@@ -46,3 +54,31 @@ dependencies {
4654
androidTestImplementation(libs.androidx.test.junit)
4755
androidTestImplementation(libs.androidx.espresso.core)
4856
}
57+
58+
group = "com.android.identity"
59+
version = projectVersionName
60+
61+
publishing {
62+
repositories {
63+
maven {
64+
url = uri("${rootProject.rootDir}/repo")
65+
}
66+
}
67+
publications {
68+
create<MavenPublication>("release") {
69+
afterEvaluate {
70+
from(components["release"])
71+
}
72+
}
73+
}
74+
publications.withType(MavenPublication::class) {
75+
pom {
76+
licenses {
77+
license {
78+
name = "Apache 2.0"
79+
url = "https://opensource.org/licenses/Apache-2.0"
80+
}
81+
}
82+
}
83+
}
84+
}

identity-doctypes/build.gradle.kts

Lines changed: 75 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,84 @@
11
plugins {
2-
id("java-library")
3-
id("org.jetbrains.kotlin.jvm")
2+
alias(libs.plugins.kotlinMultiplatform)
3+
id("maven-publish")
44
}
55

6+
val projectVersionCode: Int by rootProject.extra
7+
val projectVersionName: String by rootProject.extra
8+
69
kotlin {
710
jvmToolchain(17)
8-
}
911

10-
java {
11-
sourceCompatibility = JavaVersion.VERSION_17
12-
targetCompatibility = JavaVersion.VERSION_17
12+
jvm()
13+
14+
listOf(
15+
iosX64(),
16+
iosArm64(),
17+
iosSimulatorArm64()
18+
).forEach {
19+
val platform = when (it.name) {
20+
"iosX64" -> "iphonesimulator"
21+
"iosArm64" -> "iphoneos"
22+
"iosSimulatorArm64" -> "iphonesimulator"
23+
else -> error("Unsupported target ${it.name}")
24+
}
25+
it.binaries.all {
26+
linkerOpts(
27+
"-L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/${platform}/",
28+
)
29+
}
30+
}
31+
32+
sourceSets {
33+
val commonMain by getting {
34+
dependencies {
35+
implementation(project(":identity"))
36+
implementation(libs.kotlinx.datetime)
37+
implementation(libs.kotlinx.io.bytestring)
38+
}
39+
}
40+
41+
val commonTest by getting {
42+
dependencies {
43+
implementation(libs.kotlin.test)
44+
implementation(libs.kotlinx.coroutine.test)
45+
}
46+
}
47+
48+
val jvmMain by getting {
49+
dependencies {
50+
implementation(libs.bouncy.castle.bcprov)
51+
implementation(libs.bouncy.castle.bcpkix)
52+
implementation(libs.tink)
53+
}
54+
}
55+
56+
val jvmTest by getting {
57+
dependencies {
58+
implementation(libs.bouncy.castle.bcprov)
59+
implementation(libs.bouncy.castle.bcpkix)
60+
}
61+
}
62+
}
1363
}
1464

15-
dependencies {
16-
implementation(project(":identity"))
17-
implementation(libs.kotlinx.datetime)
18-
testImplementation(libs.junit)
65+
group = "com.android.identity"
66+
version = projectVersionName
67+
68+
publishing {
69+
repositories {
70+
maven {
71+
url = uri("${rootProject.rootDir}/repo")
72+
}
73+
}
74+
publications.withType(MavenPublication::class) {
75+
pom {
76+
licenses {
77+
license {
78+
name = "Apache 2.0"
79+
url = "https://opensource.org/licenses/Apache-2.0"
80+
}
81+
}
82+
}
83+
}
1984
}

0 commit comments

Comments
 (0)