-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix package and publish to MavenCentral
- Loading branch information
Showing
17 changed files
with
247 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export OSSRH_USERNAME= | ||
export OSSRH_PASSWORD= | ||
export SONATYPE_STAGING_PROFILE_ID= | ||
export SIGNING_KEY_ID= | ||
export SIGNING_PASSWORD= | ||
export SIGNING_KEY= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Publish to MavenCentral | ||
|
||
on: | ||
release: | ||
types: [ released ] | ||
|
||
jobs: | ||
publish: | ||
name: Publish to MavenCentral | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v2 | ||
with: | ||
distribution: adopt | ||
java-version: 11 | ||
|
||
- name: Publish to MavenCentral | ||
run: ./gradlew --max-workers 1 publishReleasePublicationToMavenLocal publishReleasePublicationToSonatypeRepository closeAndReleaseSonatypeStagingRepository | ||
env: | ||
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} | ||
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} | ||
SONATYPE_STAGING_PROFILE_ID: ${{ secrets.SONATYPE_STAGING_PROFILE_ID }} | ||
SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} | ||
SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} | ||
SIGNING_KEY: ${{ secrets.SIGNING_KEY }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
DataBinding-ktx/src/main/java/com/wada811/databindingktx/ActivityDataBinding.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
@file:JvmName("ActivityDataBinding") | ||
|
||
package com.wada811.databindingktx | ||
|
||
import android.view.View | ||
import android.view.ViewGroup | ||
import androidx.databinding.DataBindingUtil | ||
import androidx.databinding.ViewDataBinding | ||
import androidx.fragment.app.FragmentActivity | ||
|
||
fun <T : ViewDataBinding> FragmentActivity.dataBinding(): Lazy<T> = lazy(LazyThreadSafetyMode.NONE) { | ||
bind<T>(getContentView()).also { | ||
it.lifecycleOwner = this@dataBinding | ||
} | ||
} | ||
|
||
fun <T : ViewDataBinding> FragmentActivity.withBinding(withBinding: (binding: T) -> Unit) { | ||
val binding = bind<T>(getContentView()).also { | ||
it.lifecycleOwner = this@withBinding | ||
} | ||
withBinding(binding) | ||
} | ||
|
||
private fun <T : ViewDataBinding> bind(view: View): T = DataBindingUtil.bind(view)!! | ||
private fun FragmentActivity.getContentView(): View { | ||
return checkNotNull(findViewById<ViewGroup>(android.R.id.content).getChildAt(0)) { | ||
"Call setContentView or Use Activity's secondary constructor passing layout res id." | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
DataBinding-ktx/src/main/java/com/wada811/databindingktx/FragmentDataBinding.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
@file:JvmName("FragmentDataBinding") | ||
|
||
package com.wada811.databindingktx | ||
|
||
import android.view.View | ||
import androidx.databinding.DataBindingUtil | ||
import androidx.databinding.ViewDataBinding | ||
import androidx.fragment.app.Fragment | ||
import com.wada811.databindingktx.R | ||
import kotlin.properties.ReadOnlyProperty | ||
import kotlin.reflect.KProperty | ||
|
||
fun <T : ViewDataBinding> Fragment.dataBinding(): ReadOnlyProperty<Fragment, T> { | ||
return object : ReadOnlyProperty<Fragment, T> { | ||
@Suppress("UNCHECKED_CAST") | ||
override fun getValue(thisRef: Fragment, property: KProperty<*>): T { | ||
(requireView().getTag(R.id.data_binding_tag) as? T)?.let { return it } | ||
return bind<T>(requireView()).also { | ||
it.lifecycleOwner = thisRef.viewLifecycleOwner | ||
it.root.setTag(R.id.data_binding_tag, it) | ||
} | ||
} | ||
|
||
private fun <T : ViewDataBinding> bind(view: View): T = DataBindingUtil.bind(view)!! | ||
} | ||
} | ||
|
||
fun <T : ViewDataBinding> Fragment.withBinding(withBinding: (binding: T) -> Unit) { | ||
view?.let { view -> | ||
val binding = DataBindingUtil.bind<T>(view)!!.also { | ||
it.lifecycleOwner = viewLifecycleOwner | ||
} | ||
withBinding(binding) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
apply plugin: 'maven-publish' | ||
apply plugin: 'signing' | ||
|
||
ext { | ||
PUBLISH_GROUP_ID = 'com.wada811.databindingktx' | ||
PUBLISH_ARTIFACT_ID = 'databindingktx' | ||
PUBLISH_VERSION = '7.0.0' | ||
} | ||
|
||
android { | ||
publishing { | ||
singleVariant('release') { | ||
withSourcesJar() | ||
} | ||
} | ||
} | ||
|
||
signing { | ||
useInMemoryPgpKeys( | ||
rootProject.ext["signing.keyId"], | ||
rootProject.ext["signing.key"], | ||
rootProject.ext["signing.password"], | ||
) | ||
sign publishing.publications | ||
} | ||
|
||
group = PUBLISH_GROUP_ID | ||
version = PUBLISH_VERSION | ||
|
||
afterEvaluate { | ||
publishing { | ||
publications { | ||
release(MavenPublication) { | ||
groupId PUBLISH_GROUP_ID | ||
artifactId PUBLISH_ARTIFACT_ID | ||
version PUBLISH_VERSION | ||
|
||
// Two artifacts, the `aar` (or `jar`) and the sources | ||
if (project.plugins.findPlugin("com.android.library")) { | ||
from components.release | ||
} else { | ||
from components.java | ||
} | ||
|
||
pom { | ||
name = PUBLISH_ARTIFACT_ID | ||
description = 'DataBinding-ktx make easy to use DataBinding.' | ||
url = 'https://github.com/wada811/DataBinding-ktx' | ||
|
||
licenses { | ||
license { | ||
name = 'The Apache License, Version 2.0' | ||
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' | ||
} | ||
} | ||
developers { | ||
developer { | ||
id = 'wada811' | ||
name = 'WADA Takumi' | ||
email = '[email protected]' | ||
} | ||
} | ||
scm { | ||
connection = 'scm:git:github.com/wada811/DataBinding-ktx.git' | ||
developerConnection = 'scm:git:ssh://github.com/wada811/DataBinding-ktx.git' | ||
url = 'https://github.com/wada811/DataBinding-ktx/tree/master' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
ext["ossrhUsername"] = System.getenv('OSSRH_USERNAME') | ||
ext["ossrhPassword"] = System.getenv('OSSRH_PASSWORD') | ||
ext["sonatypeStagingProfileId"] = System.getenv('SONATYPE_STAGING_PROFILE_ID') | ||
ext["signing.keyId"] = System.getenv('SIGNING_KEY_ID') | ||
ext["signing.password"] = System.getenv('SIGNING_PASSWORD') | ||
ext["signing.key"] = System.getenv('SIGNING_KEY') | ||
|
||
nexusPublishing { | ||
repositories { | ||
sonatype { | ||
stagingProfileId = sonatypeStagingProfileId | ||
username = ossrhUsername | ||
password = ossrhPassword | ||
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/")) | ||
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")) | ||
} | ||
} | ||
} |
Oops, something went wrong.