Skip to content

Commit b21e2e5

Browse files
committed
Fix comment.
1 parent d7cdb1c commit b21e2e5

16 files changed

Lines changed: 116 additions & 371 deletions

.github/workflows/publish_library.yml

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: "Publish library to GitHub Packages"
22
on:
33
push:
44
tags:
5-
- 'v*'
5+
- '*.*.*'
66
jobs:
77
build:
88
name: create release
@@ -14,23 +14,17 @@ jobs:
1414
uses: actions/setup-java@v1
1515
with:
1616
java-version: 11
17-
- name: copy pgp
18-
id: write_file
19-
uses: timheuer/base64-to-file@v1
20-
with:
21-
fileName: ${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}'
22-
encodedString: ${{ secrets.SORROW_BLUE_XXXXXXXX_SECRET }}
2317
- name: Build with Gradle
2418
env:
25-
GITHUB_USERNAME: ${{ github.actor }}
26-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27-
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }}
28-
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
29-
SIGNING_SECRET_KEY_RING_FILE: ${{ steps.write_file.outputs.filePath }}
30-
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
31-
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
32-
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
33-
run: ./gradlew binding-ktx:assembleRelease binding-ktx:publishReleasePublicationToSonatypeRepository binding-ktx:publishReleasePublicationToGitHubPackagesRepository binding-ktx:closeAndReleaseRepository
19+
ORG_GRADLE_PROJECT_githubPackagesUsername: ${{ github.actor }}
20+
ORG_GRADLE_PROJECT_githubPackagesPassword: ${{ secrets.GITHUB_TOKEN }}
21+
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.OSSRH_USERNAME }}
22+
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.OSSRH_PASSWORD }}
23+
ORG_GRADLE_PROJECT_sonatypeStagingProfileId: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }}
24+
ORG_GRADLE_PROJECT_signingKeyId: ${{ secrets.SIGNING_KEY_ID }}
25+
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }}
26+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }}
27+
run: ./gradlew :binding-ktx:publishToSonatype closeAndReleaseSonatypeStagingRepository
3428

3529
- name: Get the version
3630
id: get_version

.idea/compiler.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/gradle.xml

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

binding-ktx/build.gradle.kts

Lines changed: 75 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,21 @@
33
*/
44

55
plugins {
6-
ComAndroidPluginGroup(this).library
7-
`kotlin-android`
6+
id("com.android.library")
7+
id("kotlin-android")
8+
id("kotlin-kapt")
9+
`maven-publish`
10+
signing
11+
id("org.jetbrains.dokka") version "1.5.30"
812
}
13+
group = "com.sorrowblue.jetpack"
14+
15+
version = grgit.describe {
16+
longDescr = false
17+
isTags = true
18+
}?.toVersion() ?: "0.0.1-SNAPSHOT"
19+
20+
fun String.toVersion() = this + if (matches(".*-[0-9]+-g[0-9a-f]{7}".toRegex())) "-SNAPSHOT" else ""
921

1022
android {
1123
compileSdk = 31
@@ -42,12 +54,68 @@ dependencies {
4254
androidTestImplementation("androidx.test.ext:junit:1.1.3")
4355
androidTestImplementation("androidx.test.espresso:espresso-core:3.4.0")
4456
}
57+
val androidSourcesJar: TaskProvider<Jar> by tasks.registering(Jar::class) {
58+
archiveClassifier.set("sources")
59+
from(android.sourceSets.getByName("main").java.srcDirs)
60+
from((android.sourceSets.getByName("main").kotlin.srcDirs() as com.android.build.gradle.internal.api.DefaultAndroidSourceDirectorySet).srcDirs)
61+
}
62+
artifacts {
63+
archives(androidSourcesJar)
64+
}
65+
val javadocJar: TaskProvider<Jar> by tasks.registering(Jar::class) {
66+
val dokkaHtml by tasks.getting(org.jetbrains.dokka.gradle.DokkaTask::class)
67+
dependsOn(dokkaHtml)
68+
archiveClassifier.set("javadoc")
69+
from(dokkaHtml.outputDirectory)
70+
}
4571

46-
ext["PUBLISH_GROUP_ID"] = project.property("PUBLISH_GROUP_ID")
47-
ext["PUBLISH_ARTIFACT_ID"] = project.property("PUBLISH_ARTIFACT_ID")
48-
ext["PUBLISH_VERSION"] = project.property("PUBLISH_VERSION")
4972

5073
afterEvaluate {
51-
apply<MavenCentralRepository>()
52-
apply<GithubPackagesRepository>()
74+
publishing {
75+
publications {
76+
val release by creating(MavenPublication::class) {
77+
artifactId = "binding-ktx"
78+
logger.lifecycle("Publish Library : $group:$artifactId:$version")
79+
if (project.plugins.findPlugin("com.android.library") != null) {
80+
from(components.getByName("release"))
81+
} else {
82+
from(components.getByName("java"))
83+
}
84+
artifact(androidSourcesJar)
85+
artifact(javadocJar)
86+
pom {
87+
name.set(artifactId)
88+
description.set("Jetpack")
89+
url.set("https://github.com/SorrowBlue/AndroidJetpack")
90+
licenses {
91+
license {
92+
name.set("The Apache License, Version 2.0")
93+
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
94+
}
95+
}
96+
developers {
97+
developer {
98+
id.set("sorrowblue_sb")
99+
name.set("Sorrow Blue")
100+
email.set("sorrowblue.sb@gmail.com")
101+
}
102+
}
103+
scm {
104+
connection.set("scm:git:github.com/SorrowBlue/AndroidJetpack.git")
105+
developerConnection.set("scm:git:ssh://github.com/SorrowBlue/AndroidJetpack.git")
106+
url.set("https://github.com/SorrowBlue/AndroidJetpack/tree/main")
107+
}
108+
}
109+
}
110+
}
111+
}
112+
signing {
113+
if (!hasProperty("signing.secretKeyRingFile")) {
114+
val signingKeyId: String? by project
115+
val signingKey: String? by project
116+
val signingPassword: String? by project
117+
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
118+
}
119+
sign(publishing.publications)
120+
}
53121
}

binding-ktx/gradle.properties

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

binding-ktx/publish-mavencentral.gradle

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

binding-ktx/src/main/java/com/sorrowblue/jetpack/binding/ActivityViewBinding.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP
1414
import androidx.core.view.get
1515
import androidx.viewbinding.ViewBinding
1616

17-
17+
/**
18+
* Set the activity content from a ViewBinding.
19+
*/
1820
@Suppress("unused")
1921
inline fun <reified V : ViewBinding> ComponentActivity.viewBinding() =
2022
object : AndroidLifecycleViewBindingProperty<ComponentActivity, V>() {

binding-ktx/src/main/java/com/sorrowblue/jetpack/binding/FragmentViewBinding.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import android.view.LayoutInflater
99
import androidx.fragment.app.Fragment
1010
import androidx.viewbinding.ViewBinding
1111

12+
/**
13+
* Set the activity content from a ViewBinding.
14+
*/
1215
inline fun <reified V : ViewBinding> Fragment.viewBinding() =
1316
object : AndroidLifecycleViewBindingProperty<Fragment, V>() {
1417

binding-ktx/src/main/java/com/sorrowblue/jetpack/binding/ViewBindingUtil.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,21 @@ import android.view.LayoutInflater
88
import android.view.View
99
import androidx.viewbinding.ViewBinding
1010

11+
/**
12+
* Provides extension functions for ViewBinding.
13+
*/
1114
object ViewBindingUtil {
1215

16+
/**
17+
* Wrap the ViewBinding.bind(view: View).
18+
*/
1319
inline fun <reified V : ViewBinding> bind(view: View): V {
1420
return V::class.java.getMethod("bind", View::class.java).invoke(null, view) as V
1521
}
1622

23+
/**
24+
* Wrap the ViewBinding.inflate(inflater: LayoutInflater).
25+
*/
1726
inline fun <reified V : ViewBinding> inflate(inflater: LayoutInflater): V {
1827
return V::class.java.getMethod("inflate", LayoutInflater::class.java)
1928
.invoke(null, inflater) as V

build.gradle.kts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
*/
44

55
plugins {
6-
id("com.github.ben-manes.versions").version("0.39.0")
6+
id("com.github.ben-manes.versions") version "0.39.0"
7+
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
8+
id("org.ajoberstar.grgit") version "4.1.0"
79
}
810

911
buildscript {
@@ -13,8 +15,15 @@ buildscript {
1315
}
1416
dependencies {
1517
classpath("com.android.tools.build:gradle:7.0.3")
16-
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.31")
17-
classpath("io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.22.0")
18+
classpath(kotlin("gradle-plugin", "1.5.31"))
19+
}
20+
}
21+
22+
nexusPublishing {
23+
repositories {
24+
sonatype {
25+
stagingProfileId.set(findProperty("sonatypeStagingProfileId") as? String)
26+
}
1827
}
1928
}
2029

0 commit comments

Comments
 (0)