Skip to content

Commit

Permalink
update 0.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
mainlxl committed Oct 10, 2022
1 parent c7cd725 commit a6c3a3a
Show file tree
Hide file tree
Showing 210 changed files with 374 additions and 204 deletions.
10 changes: 8 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ task clean(type: Delete) {

subprojects { pro ->
def name = pro.name
if (name == 'app' || name == 'testLibrary') {
if (name == 'app' || name == 'testLibrary' || name == 'p7z') {
return
}
apply plugin: 'maven-publish'
Expand All @@ -44,7 +44,7 @@ subprojects { pro ->
publishing {
publications {
release(MavenPublication) {
groupId 'com.imf.so'
groupId GROUP_ID
artifactId pro.name
version SO_PLUGIN_VERSION
if (isJavaProject) {
Expand Down Expand Up @@ -79,3 +79,9 @@ subprojects { pro ->
}
}
}

task aaa {
doLast {
println org.gradle.internal.os.OperatingSystem.current()
}
}
5 changes: 2 additions & 3 deletions file-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ plugins {
repositories {
maven { url "https://maven.aliyun.com/repository/jcenter" }
maven { url "https://maven.aliyun.com/repository/google" }
mavenCentral()
}


Expand All @@ -16,5 +15,5 @@ dependencies {
implementation "com.google.code.gson:gson:2.8.0"
compileOnly "com.android.tools.build:gradle:$ANDROID_GRADLE_VERSION"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}

implementation 'com.google.gradle:osdetector-gradle-plugin:1.6.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ open class ApkSoLibStreamlineTask @Inject constructor(
return outputFile
}

fun log(msg: Any) {
// project.logger.info("[ApkSoLibStreamlineTask]: ${msg}")
println("[ApkSoLibStreamlineTask]: ${msg}")
}

open fun streamlineApkSoFile(apk: File?): File? {
if (apk == null || !apk.exists()) {
return null
Expand Down
58 changes: 52 additions & 6 deletions file-plugin/src/main/kotlin/com/imf/plugin/so/Plugin.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package com.imf.plugin.so

import com.android.build.gradle.AppExtension
import com.google.gradle.osdetector.OsDetector
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import java.io.*
import java.util.Collections
import java.util.stream.Collectors

fun log(msg: Any) {
// project.logger.info("[ApkSoLibStreamlineTask]: ${msg}")
println("[SoFilePlugin]: ${msg}")
}

abstract class SoFilePlugin : Plugin<Project> {
lateinit var intermediatesDir: File;
lateinit var android: AppExtension;
Expand All @@ -14,18 +22,56 @@ abstract class SoFilePlugin : Plugin<Project> {
pluginConfig = project.extensions.create("SoFileConfig", SoFileExtensions::class.java)
android = project.extensions.getByType(AppExtension::class.java)
intermediatesDir = File(project.buildDir, "intermediates")
if (pluginConfig.exe7zName.isEmpty()) {
project.apply(mapOf("plugin" to "com.google.osdetector"))
}
project.afterEvaluate {
afterProjectEvaluate(it)
log("enable: ${pluginConfig.enable}")
if (pluginConfig.enable == true) {
if (pluginConfig.exe7zName.isEmpty()) {
pluginConfig.exe7zName = find7zPath(project)
}
log("p7z path: ${pluginConfig.exe7zName}")
afterProjectEvaluate(it)
}
}
}

protected open fun afterProjectEvaluate(project: Project) {
val defaultConfig = android.defaultConfig
pluginConfig.abiFilters = defaultConfig.ndk.abiFilters
private fun find7zPath(project: Project): String {
val p7zConfig = project.configurations.create("ApkSoFileAdjustLocatorP7z") {
it.isVisible = false
it.isTransitive = false
it.setExtendsFrom(Collections.emptyList())
}
val osdetector = project.extensions.getByType(OsDetector::class.java)
val dep = project.dependencies.add(
p7zConfig.name, mapOf<String, String>(
"group" to "com.mainli",
"name" to "p7z",
"classifier" to osdetector.classifier,
"version" to "1.0.0",
"ext" to "exe"
)
)
try {
val file = p7zConfig.fileCollection(dep).singleFile
if (!file.canExecute() && !file.setExecutable(true)) {
throw GradleException("Cannot set ${file} as executable")
}
return file.absolutePath
} catch (e: Exception) {
}
val os = System.getenv("OS")?.lowercase()
if (os != null && os.contains("windows")) {
pluginConfig.exe7zName = "7z.exe"
return "7z.exe"
}
return "7z"
}


protected open fun afterProjectEvaluate(project: Project) {
val defaultConfig = android.defaultConfig
pluginConfig.abiFilters = defaultConfig.ndk.abiFilters
val minSdkVersion: Int = defaultConfig.minSdkVersion?.apiLevel ?: 0
pluginConfig.neededRetainAllDependencies =
pluginConfig.forceNeededRetainAllDependencies ?: (minSdkVersion <= 23)
Expand Down Expand Up @@ -120,7 +166,7 @@ class ApkSoFileAdjustPlugin : SoFilePlugin() {
)
task.group = "Build"
task.description = "进行so共享库处理"
task.dependsOn.add("package${capitalizeVariantName}")
task.setMustRunAfter(setOf(project.tasks.findByPath("package${capitalizeVariantName}")))
project.tasks.findByPath("assemble${capitalizeVariantName}")?.dependsOn?.add(task)

}
Expand Down
14 changes: 11 additions & 3 deletions file-plugin/src/main/kotlin/com/imf/plugin/so/SoFileExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@ package com.imf.plugin.so

//必须open 否则project.extensions.create无法创建SoFileExtensions的代理子类
open class SoFileExtensions {
var exe7zName: String = "7z"
//是否使用追加Action方式执行so压缩
var useAppendActionMethod = true;
//是否开启插件
var enable: Boolean? = null
get() {
if (field == null) {
return !(deleteSoLibs.isNullOrEmpty() && compressSo2AssetsLibs.isNullOrEmpty())
}
return field
}

//7z
var exe7zName: String = ""
var abiFilters: Set<String>? = null

//要移除的so库
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,7 @@ android.useAndroidX=true
android.enableJetifier=true
ANDROID_GRADLE_VERSION=7.3.0
#SO_PLUGIN_VERSION=0.0.4-SNAPSHOT
SO_PLUGIN_VERSION=0.0.8
SO_PLUGIN_VERSION=0.0.9
userPlugin=true

GROUP_ID=com.imf.so

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"component": {
"group": "com.imf.so",
"module": "android-un7z",
"version": "0.0.8",
"version": "0.0.9",
"attributes": {
"org.gradle.status": "release"
}
Expand All @@ -24,8 +24,8 @@
},
"files": [
{
"name": "android-un7z-0.0.8.aar",
"url": "android-un7z-0.0.8.aar",
"name": "android-un7z-0.0.9.aar",
"url": "android-un7z-0.0.9.aar",
"size": 161771,
"sha512": "1288ca3b5fc8f362b3b4c14751cd1f3154edde97cc31597ef44c3f5b04c3ec6c5b9a5aa9c5246c2a530b8cf1c2e9f7a9f347bb134e90ce0b6142085a904342d2",
"sha256": "1c3ed5f612f47b61a6d27181295f5df8f2b937b790376d834b6f4a2fe0a03a16",
Expand All @@ -44,8 +44,8 @@
},
"files": [
{
"name": "android-un7z-0.0.8.aar",
"url": "android-un7z-0.0.8.aar",
"name": "android-un7z-0.0.9.aar",
"url": "android-un7z-0.0.9.aar",
"size": 161771,
"sha512": "1288ca3b5fc8f362b3b4c14751cd1f3154edde97cc31597ef44c3f5b04c3ec6c5b9a5aa9c5246c2a530b8cf1c2e9f7a9f347bb134e90ce0b6142085a904342d2",
"sha256": "1c3ed5f612f47b61a6d27181295f5df8f2b937b790376d834b6f4a2fe0a03a16",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
62b7e8ed77c2d236f294c961fcd15b23
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
9551e475d36cc109b5dc3853c6c74717e75c4184
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
50f5e6024e450b626109b0421a518404417c3dbdb0eb4bd1425c3e4bbe8add9b
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a5422af587ca0e595bd6adb37e7d1a1bbe93cbd1a4676dd941f07a8eb861dc5781d8460236cf9c88dd32b763a14dfa5a67923356ce64414a1a71ac8c635e3803
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.imf.so</groupId>
<artifactId>android-un7z</artifactId>
<version>0.0.8</version>
<version>0.0.9</version>
<packaging>aar</packaging>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f62110cd4d55b16d72d9f152655b3117
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
317c7be40f61e44187ea7c621d623f83f6467531
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4d56b1b6506e6e9d78416388e07191f9e13a3ad048a6cac343d102c56a10cdfa
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f08fb57e031c308b42651b48193b2e1355874ad5fcafae4b73b1250e539aa3c3c411f29a5b8d7538d2708f0845a3b5179c4e8f15590dc70478e7f96b9cda9761
8 changes: 4 additions & 4 deletions maven/com/imf/so/android-un7z/maven-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
<groupId>com.imf.so</groupId>
<artifactId>android-un7z</artifactId>
<versioning>
<latest>0.0.8</latest>
<release>0.0.8</release>
<latest>0.0.9</latest>
<release>0.0.9</release>
<versions>
<version>0.0.8</version>
<version>0.0.9</version>
</versions>
<lastUpdated>20221009142806</lastUpdated>
<lastUpdated>20221010150939</lastUpdated>
</versioning>
</metadata>
2 changes: 1 addition & 1 deletion maven/com/imf/so/android-un7z/maven-metadata.xml.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
59fd4e85c5a0462210930f9c7e4c5be8
ce08195abd285bf1a8260ebfc8c99ada
2 changes: 1 addition & 1 deletion maven/com/imf/so/android-un7z/maven-metadata.xml.sha1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2d9c17a00494d28952e432012f8438cf5d768dd3
57cd49cc58555ab6f77af8489e4845be58ded452
2 changes: 1 addition & 1 deletion maven/com/imf/so/android-un7z/maven-metadata.xml.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
03deb2e4c1e5b19c25174677e27f57688e6208180cf0d8368125eb0bdc23c19a
99779baf5d995f065ef37e6e1a4a6dce6dc515831f9adf7a606e26eb36eb8edb
2 changes: 1 addition & 1 deletion maven/com/imf/so/android-un7z/maven-metadata.xml.sha512
Original file line number Diff line number Diff line change
@@ -1 +1 @@
57b62d8d134b14d6a0b8f4a80deacd0421c0811c2cad63f36a05c68e3118fb41a02b926ec692942d21bac374bad870caaf6090cbb0794657d216b9af3f40b1bc
f1bb57ea23b0cdafa4bb90252f1efcdf5efee1e7c5cab8549805c3ab825d82af9f19fd54bf81e686357e71767479f7183cff45a032e01b943117635943e75db5

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
98e9fc7a9033f82fc63375c808af5821
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bd9a81684837c08d0dae42053c5aac95136cd700
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
f592026a3c335318e6a85b1f1e09a8c0ebf4905c14d23d6899a10375255ccbc4
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
eb992ba3e78a59b2cdb879e4e6f75b2c3ce8976501bd83b341a55e15feb758537de25c91c9b83504c20fbab477088d60119e0b19226571cb77ebebaf577fdd47
Loading

0 comments on commit a6c3a3a

Please sign in to comment.