Skip to content

Commit

Permalink
加入大仓
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamgyf committed Oct 26, 2022
1 parent 4e59886 commit f2e83ce
Show file tree
Hide file tree
Showing 31 changed files with 97 additions and 77 deletions.
51 changes: 19 additions & 32 deletions FastInflate/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
id 'maven-publish'
}

def file = new File("${rootDir.parent}/module_publish.gradle")
if (file.exists()) {
apply from: file.absolutePath

publishModule {
library {
groupId = 'com.dreamgyf.android.plugin'
moduleName = 'FastInflate'
version = '0.1.0-alpha-01'
description = '编译期解析布局xml文件,提高布局加载的性能'
url = 'https://github.com/dreamgyf/FastInflate'
}
}
}

android {
namespace 'com.dreamgyf.android.plugin.fastinflate'
compileSdk 33
compileSdk configs.android.compileSdk

defaultConfig {
minSdk 21
targetSdk 33
minSdk configs.android.minSdk
targetSdk configs.android.targetSdk

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
Expand All @@ -31,33 +45,6 @@ android {
}
}

task androidSourcesJar(type: Jar) {
archiveClassifier.set('sources')
from android.sourceSets.main.java.source
}

publishing {
publications {
release(MavenPublication) {
groupId = 'com.dreamgyf.android.plugin'
artifactId = 'FastInflate'
version = '0.1'

def artifactOutputPath = "$buildDir/outputs/aar/${project.getName()}-release.aar"
artifact(artifactOutputPath)
artifact androidSourcesJar
}
}
}

dependencies {

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

implementation 'cglib:cglib:3.3.0'
implementation libs.androidx.appcompat
}
37 changes: 14 additions & 23 deletions FastInflatePlugin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,36 +1,27 @@
plugins {
id 'kotlin'
id 'java-gradle-plugin'
id 'maven-publish'
id 'groovy'
}

//publishing {
// publications {
// release(MavenPublication) {
// groupId = 'com.dreamgyf.android.plugin'
// artifactId = 'FastInflatePlugin'
// version = '0.1'
// from components.java
// }
// }
//}
def file = new File("${rootDir.parent}/module_publish.gradle")
if (file.exists()) {
apply from: file.absolutePath

gradlePlugin {
plugins {
fastInflate {
id = 'android-fastinflate'
publishModule {
plugin {
group = 'com.dreamgyf.android.plugin'
id = 'com.dreamgyf.android.fastinflate'
name = 'fastInflate'
displayName = 'Android FastInflate'
version = '0.1.0-alpha-01'
implementationClass = 'com.dreamgyf.android.plugin.fastinflate.plugin.FastInflatePlugin'
version '0.1'
description = '编译期解析布局xml文件,提高布局加载的性能'
url = 'https://github.com/dreamgyf/FastInflate'
tags = ['android', 'LayoutInflater']
}
}
}

dependencies {
//Groovy DSL
implementation gradleApi()
//Gradle DSL
implementation localGroovy()
implementation 'com.android.tools.build:gradle:7.3.0'
implementation 'com.squareup:kotlinpoet:1.12.0'
implementation libs.kotlinpoet
}
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@

编译期时解析布局xml文件,将LayoutInflater中的反射实例化转成普通的实例化,以此来提高布局加载的性能

经测试,越能提升1.5倍布局加载的速度
经测试,约能使布局加载的速度提升1.5倍

**目前不支持含有`include``merge`等标签的布局加载**
**目前不支持含有`include``merge`等标签的布局加载,多`module`项目不一定能正常使用**

**当前版本为alpha测试版,仅供学习研究使用,由此插件引发的各种损失,本人概不负责!!!**

**注:编译此项目请直接 clone 父工程 [AndroidLibraries](https://github.com/dreamgyf/AndroidLibraries)**

## 引入依赖

```groovy
plugins {
id 'com.dreamgyf.android.fastinflate' version '0.1.0-alpha-01'
}
dependencies {
implementation 'com.dreamgyf.android.fastinflate:0.1.0-alpha-01'
}
```

## 项目中使用

```kotlin
// 使用FastInflate代替LayoutInflater即可,如下
// LayoutInflater.from(this).inflate(R.layout.activity_main, null)
FastInflate.from(this).inflate(R.layout.activity_main, null)
```
File renamed without changes.
22 changes: 9 additions & 13 deletions app/build.gradle → Sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'android-fastinflate'
id 'com.dreamgyf.android.fastinflate'
}

android {
namespace 'com.dreamgyf.android.plugin.fastinflate'
compileSdk 32
compileSdk configs.android.compileSdk

defaultConfig {
applicationId "com.dreamgyf.android.plugin.fastinflate"
minSdk 21
targetSdk 32
minSdk configs.android.minSdk
targetSdk configs.android.targetSdk
versionCode 1
versionName "1.0"

Expand All @@ -34,14 +34,10 @@ android {
}

dependencies {
implementation libs.androidx.core.ktx
implementation libs.androidx.appcompat
implementation libs.android.material
implementation libs.androidx.constraintlayout

implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

implementation 'com.dreamgyf.android.plugin:FastInflate:0.1'
implementation libs.dreamgyf.FastInflate
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 14 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
id 'android-fastinflate' version '0.1' apply false
}
alias(libs.plugins.android.app) apply false
alias(libs.plugins.android.lib) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.gradle.publish) apply false
alias(libs.plugins.dreamgyf.fastinflate) apply false
}

if (!file("../configs.gradle").exists()) {
throw new GradleException(
"Could not found file \"../configs.gradle\", " +
"please clone parent project https://github.com/dreamgyf/AndroidLibraries"
)
}
apply from: "../configs.gradle"
17 changes: 15 additions & 2 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,28 @@ pluginManagement {
mavenLocal()
}
}

if (!file("../libs.toml").exists()) {
throw new GradleException(
"Could not found file \"../libs.toml\", " +
"please clone parent project https://github.com/dreamgyf/AndroidLibraries"
)
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
mavenLocal()
}
versionCatalogs {
libs {
from(files("../libs.toml"))
}
}
}
rootProject.name = "FastInflate"
include ':app'
include ':FastInflatePlugin'

include ':Sample'
include ':FastInflate'
include ':FastInflatePlugin'

0 comments on commit f2e83ce

Please sign in to comment.