Skip to content

Commit

Permalink
Migrating from AAR to JAR artifacts
Browse files Browse the repository at this point in the history
kirich1409 committed May 28, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 3a5757c commit 39cd9c5
Showing 10 changed files with 96 additions and 89 deletions.
17 changes: 14 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -7,8 +7,6 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:7.0.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
@@ -17,6 +15,8 @@ buildscript {
plugins {
id 'maven-publish'
id 'org.jetbrains.kotlin.jvm' version '1.6.20' apply false
id 'com.stepango.aar2jar' version "0.6" apply false
id 'com.stepango.androidjar' version "0.1"
}

allprojects {
@@ -36,14 +36,25 @@ ext {
minSdkVersion = 14
targetSdkVersion = 29

versionName = "1.5.6"
versionName = "1.5.7"

dependencies = [:]
dependencies.coreKtx = 'androidx.core:core-ktx:1.7.0'
dependencies.core = 'androidx.core:core:1.7.0'
dependencies.fragmentKtx = 'androidx.fragment:fragment-ktx:1.4.0'
dependencies.fragment = 'androidx.fragment:fragment:1.4.0'
dependencies.viewBinding = 'androidx.databinding:viewbinding:7.0.4'
dependencies.lifecycleCommonJava8 = 'androidx.lifecycle:lifecycle-common-java8:2.4.0'
dependencies.lifecycleCommon = 'androidx.lifecycle:lifecycle-common:2.4.0'
dependencies.lifecycleViewmodel = 'androidx.lifecycle:lifecycle-viewmodel:2.4.0'
dependencies.lifecycleRuntime = 'androidx.lifecycle:lifecycle-runtime:2.4.0'
dependencies.recyclerview = 'androidx.recyclerview:recyclerview:1.2.1'
dependencies.annotations = 'androidx.annotation:annotation:1.3.0'
dependencies.savedstate = 'androidx.savedstate:savedstate:1.1.0'
dependencies.activity = 'androidx.activity:activity:1.4.0'
dependencies.appcompat = 'androidx.appcompat:appcompat:1.4.1'

preDexEnabled = "true" != System.getenv("PRE_DEX_DISABLED")

androidJar = androidjar.find(targetSdkVersion)
}
11 changes: 3 additions & 8 deletions publishing.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

tasks.register("sourceJar", Jar) {
from android.sourceSets.main.java.srcDirs
archiveClassifier.set('sources')
}

Properties localProps = new Properties()
File localProperties = new File(rootProject.rootDir, "local.properties")
if (localProperties.exists() && localProperties.isFile()) {
@@ -19,9 +14,9 @@ project.ext["signing.password"] = localProps.getProperty("signing.password")
afterEvaluate {
publishing {
publications {
releaseAar(MavenPublication) {
from components.release
artifact sourceJar
release(MavenPublication) {
from components.kotlin
artifact(sourcesJar)

groupId = project.ext.groupId
artifactId = project.ext.artifactId
3 changes: 2 additions & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
@@ -31,8 +31,9 @@ android {

dependencies {
implementation rootProject.ext.dependencies.coreKtx
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation rootProject.ext.dependencies.appcompat
implementation rootProject.ext.dependencies.recyclerview
implementation rootProject.ext.dependencies.activity
implementation project(':vbpd:vbpd-full')
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7'
}
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ import by.kirich1409.viewbindingdelegate.viewBinding
class ProfileFragment : Fragment(R.layout.fragment_profile) {

private val viewBinding by viewBinding(FragmentProfileBinding::bind,
onViewDestroyed = { vb: FragmentProfileBinding ->
onViewDestroyed = { _: FragmentProfileBinding ->
// reset view
})

39 changes: 18 additions & 21 deletions vbpd/vbpd-core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,38 +1,35 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id "org.jetbrains.kotlin.jvm"
id 'com.stepango.aar2jar'
id 'java-library'
}

ext {
groupId = 'com.github.kirich1409'
artifactId = "viewbindingpropertydelegate-core"
}

apply from: rootProject.file('publishing.gradle')

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

// For Kotlin projects
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions {
jvmTarget = "1.8"
kotlinOptions.freeCompilerArgs +=
['-module-name', "com.github.kirich1409.ViewBindingPropertyDelegate.core"]
}
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

withSourcesJar()
}

dependencies {
compileOnly rootProject.ext.dependencies.viewBinding
implementation rootProject.ext.dependencies.lifecycleCommonJava8
compileOnlyAar rootProject.ext.dependencies.viewBinding
implementationAar rootProject.ext.dependencies.lifecycleCommonJava8
implementationAar rootProject.ext.dependencies.lifecycleCommon
compileOnly androidJar
compileOnly rootProject.ext.dependencies.annotations
}

apply from: rootProject.file('publishing.gradle')
1 change: 0 additions & 1 deletion vbpd/vbpd-core/src/main/AndroidManifest.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -4,11 +4,10 @@
package by.kirich1409.viewbindingdelegate

import androidx.annotation.MainThread
import androidx.fragment.app.Fragment
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.viewbinding.ViewBinding
import by.kirich1409.viewbindingdelegate.internal.checkMainThread
import by.kirich1409.viewbindingdelegate.internal.core.checkMainThread

/**
* Setting for ViewBindingPropertyDelegate library
55 changes: 29 additions & 26 deletions vbpd/vbpd-full/build.gradle
Original file line number Diff line number Diff line change
@@ -1,43 +1,46 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'java-library'
id "org.jetbrains.kotlin.jvm"
id 'com.stepango.aar2jar'
}

ext {
groupId = 'com.github.kirich1409'
artifactId = "viewbindingpropertydelegate"
artifactId = "viewbindingpropertydelegate-full"
}

apply from: rootProject.file('publishing.gradle')

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion

consumerProguardFiles 'proguard-rules.pro'
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
//apply from: rootProject.file('publishing.gradle')

// For Kotlin projects
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions {
jvmTarget = "1.8"
kotlinOptions.freeCompilerArgs +=
['-module-name', "com.github.kirich1409.ViewBindingPropertyDelegate"]
['-module-name', "com.github.kirich1409.ViewBindingPropertyDelegate.core"]
}
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

withSourcesJar()
}

dependencies {
implementation rootProject.ext.dependencies.coreKtx
implementation rootProject.ext.dependencies.fragmentKtx
compileOnly rootProject.ext.dependencies.viewBinding
implementation rootProject.ext.dependencies.recyclerview
implementationAar rootProject.ext.dependencies.coreKtx
implementationAar rootProject.ext.dependencies.core
implementationAar rootProject.ext.dependencies.fragmentKtx
implementationAar rootProject.ext.dependencies.fragment
compileOnlyAar rootProject.ext.dependencies.viewBinding
implementationAar rootProject.ext.dependencies.lifecycleCommon
implementationAar rootProject.ext.dependencies.recyclerview
compileOnly rootProject.ext.dependencies.annotations
compileOnlyAar rootProject.ext.dependencies.activity
compileOnlyAar rootProject.ext.dependencies.savedstate
compileOnlyAar rootProject.ext.dependencies.lifecycleViewmodel
compileOnlyAar rootProject.ext.dependencies.lifecycleRuntime
compileOnly androidJar
api project(':vbpd:vbpd-noreflection')
}

apply from: rootProject.file('publishing.gradle')
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ import by.kirich1409.viewbindingdelegate.internal.ViewBindingCache
*
* @param onViewDestroyed Called when the [ViewBinding] will be destroyed
*/
inline fun <reified VB : ViewBinding> viewBindingLazy(
inline fun <R : Any, reified VB : ViewBinding> viewBindingLazy(
layoutInflater: LayoutInflater,
parent: ViewGroup? = null,
attachToParent: Boolean = false,
52 changes: 27 additions & 25 deletions vbpd/vbpd-noreflection/build.gradle
Original file line number Diff line number Diff line change
@@ -1,42 +1,44 @@
plugins {
id 'com.android.library'
id 'kotlin-android'
id "org.jetbrains.kotlin.jvm"
id 'com.stepango.aar2jar'
id 'java-library'
}

ext {
groupId = 'com.github.kirich1409'
artifactId = "viewbindingpropertydelegate-noreflection"
}

apply from: rootProject.file('publishing.gradle')

android {
compileSdkVersion rootProject.ext.compileSdkVersion
buildToolsVersion rootProject.ext.buildToolsVersion

defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

// For Kotlin projects
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) {
kotlinOptions {
jvmTarget = "1.8"
kotlinOptions.freeCompilerArgs +=
['-module-name', "com.github.kirich1409.ViewBindingPropertyDelegate.noreflection"]
['-module-name', "com.github.kirich1409.ViewBindingPropertyDelegate.core"]
}
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

withSourcesJar()
}

dependencies {
implementation rootProject.ext.dependencies.coreKtx
implementation rootProject.ext.dependencies.fragmentKtx
compileOnly rootProject.ext.dependencies.viewBinding
implementation rootProject.ext.dependencies.lifecycleCommonJava8
implementation rootProject.ext.dependencies.recyclerview
implementationAar rootProject.ext.dependencies.coreKtx
implementationAar rootProject.ext.dependencies.core
implementationAar rootProject.ext.dependencies.fragmentKtx
implementationAar rootProject.ext.dependencies.fragment
compileOnlyAar rootProject.ext.dependencies.viewBinding
implementationAar rootProject.ext.dependencies.lifecycleCommon
implementationAar rootProject.ext.dependencies.recyclerview
compileOnly rootProject.ext.dependencies.annotations
compileOnlyAar rootProject.ext.dependencies.activity
compileOnlyAar rootProject.ext.dependencies.savedstate
compileOnlyAar rootProject.ext.dependencies.lifecycleViewmodel
compileOnlyAar rootProject.ext.dependencies.lifecycleRuntime
compileOnly androidJar
api project(':vbpd:vbpd-core')
}

apply from: rootProject.file('publishing.gradle')

0 comments on commit 39cd9c5

Please sign in to comment.