Skip to content

Commit

Permalink
Release version v1.0.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpdroid committed Jul 30, 2019
1 parent 3f5d0cf commit dfa3baa
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 45 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# fat-aar
[![License MIT](https://img.shields.io/github/release-pre/cpdroid/fat-aar.svg)](https://github.com/cpdroid/fat-aar/releases/tag/v0.9.1)
[![Release](https://img.shields.io/github/license/cpdroid/fat-aar.svg)](https://github.com/cpdroid/fat-aar/blob/master/LICENSE)
[![Release](https://img.shields.io/github/release/cpdroid/fat-aar.svg)](https://github.com/cpdroid/fat-aar/releases)
[![License MIT](https://img.shields.io/github/license/cpdroid/fat-aar.svg)](https://github.com/cpdroid/fat-aar/blob/master/LICENSE)
[![Android Gradle Plugin 3.0.0-3.4.2](https://img.shields.io/badge/android--gradle-3.0.0--3.4.2-blue)](https://developer.android.com/studio/releases/gradle-plugin#updating-gradle)
[![Gradle 4.6-5.1.1](https://img.shields.io/badge/gradle-4.6--5.1.1-blue)](https://developer.android.com/studio/releases/gradle-plugin#updating-gradle)

[中文文档](https://github.com/cpdroid/fat-aar/blob/master/README_CN.md)

Expand All @@ -9,6 +11,8 @@ A plugin to merge dependencies(aar/jar) into aar file.
This plugin can embed dependency(local or remote) to an aar file, when an app module includes the aar file, the aar's dependencies code and resource
can be referenced directly, no need to import once again.

**This plugin has been tested on android gradle plugin 3.0.0-3.4.2 and gradle 4.6-5.1.1.**

## Usage
Add snippet below to your root project's *build.gradle* file:
```gradle
Expand All @@ -17,7 +21,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.cpdroid:fat-aar:0.9.4'
classpath 'com.cpdroid:fat-aar:1.0.0'
}
}
```
Expand Down Expand Up @@ -60,6 +64,4 @@ If you have referenced a module's *app_name*, define an *app_name* in your libra
> Task :moduleA:addReleaseSourceSets
Found value [app_name] in [D:\workspace\fat-aar-sample\moduleA\build\aar_plugin\exploded_aar\com.gongwen\marqueelibrary\1.1.3\res\values\values.xml]
Delete 1 values...
```


```
10 changes: 7 additions & 3 deletions README_CN.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# fat-aar
[![License MIT](https://img.shields.io/github/release-pre/cpdroid/fat-aar.svg)](https://github.com/cpdroid/fat-aar/releases/tag/v0.9.1)
[![Release](https://img.shields.io/github/license/cpdroid/fat-aar.svg)](https://github.com/cpdroid/fat-aar/blob/master/LICENSE)
[![Release](https://img.shields.io/github/release/cpdroid/fat-aar.svg)](https://github.com/cpdroid/fat-aar/releases)
[![License MIT](https://img.shields.io/github/license/cpdroid/fat-aar.svg)](https://github.com/cpdroid/fat-aar/blob/master/LICENSE)
[![Android Gradle Plugin 3.0.0-3.4.2](https://img.shields.io/badge/android--gradle-3.0.0--3.4.2-blue)](https://developer.android.com/studio/releases/gradle-plugin#updating-gradle)
[![Gradle 4.6-5.1.1](https://img.shields.io/badge/gradle-4.6--5.1.1-blue)](https://developer.android.com/studio/releases/gradle-plugin#updating-gradle)

Fat-aar是一个将依赖库 *(aar/jar)* 打包进 *aar* 文件的插件.

它能将远程或者本地依赖嵌入 *aar* 文件,当 *app* 模块使用这个 *aar* 文件时,*aar* 依赖的代码跟资源可以直接被引用到,而无需在 *app* 模块里面重新引入一遍.

本插件已经在 *Android gradle plugin* 3.0.0-3.4.2 及 *Gradle* 4.6-5.1.1 版本上测试通过

## 用法
在根目录的 *build.gradle* 文件里面添加如下语句:
```gradle
Expand All @@ -14,7 +18,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.cpdroid:fat-aar:0.9.4'
classpath 'com.cpdroid:fat-aar:1.0.0'
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ apply plugin: 'java'
apply plugin: 'groovy'

ext {
versionId = '0.9.4'
versionId = '1.0.0'
groupId = 'com.cpdroid'
name = 'fat-aar'
website = 'https://github.com/cpdroid/fat-aar'
Expand Down
68 changes: 33 additions & 35 deletions src/main/groovy/com/cpdroid/fat_aar/Utils.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -46,52 +46,50 @@ class Utils {
File[] files = new File(aarPath + "/res").listFiles()
if (files == null) return

files.sort { it.name }.each {
resourceDirectory ->
if (!resourceDirectory.isDirectory()) {
throw new ResourceDirectoryParseException(
resourceDirectory.getAbsolutePath() + " is not a directory")
}
for (File resourceDirectory : files) {
if (!resourceDirectory.isDirectory()) {
throw new ResourceDirectoryParseException(
resourceDirectory.getAbsolutePath() + " is not a directory")
}

assert (resourceDirectory.isDirectory())
assert (resourceDirectory.isDirectory())

ResourceFolderType folderResourceType = ResourceFolderType.getFolderType(resourceDirectory.getName())
if (folderResourceType != ResourceFolderType.VALUES) return
ResourceFolderType folderResourceType = ResourceFolderType.getFolderType(resourceDirectory.getName())
if (folderResourceType != ResourceFolderType.VALUES) return

// Iterate all files in the resource directory and handle each one.
File[] listFiles = resourceDirectory.listFiles()
if (listFiles == null) return
// Iterate all files in the resource directory and handle each one.
File[] listFiles = resourceDirectory.listFiles()
if (listFiles == null) return

listFiles.sort { it.name }.each {
maybeResourceFile ->
if (maybeResourceFile.isDirectory()) return
for (File maybeResourceFile : listFiles) {
if (maybeResourceFile.isDirectory()) return

if (!maybeResourceFile.isFile()) {
throw new ResourceDirectoryParseException(
"${maybeResourceFile.absolutePath} is not a file nor directory")
}
if (!maybeResourceFile.isFile()) {
throw new ResourceDirectoryParseException(
"${maybeResourceFile.absolutePath} is not a file nor directory")
}

Node node = new XmlParser().parse(maybeResourceFile)
NodeList string_node = (NodeList) node.get("string")
Node node = new XmlParser().parse(maybeResourceFile)
NodeList string_node = (NodeList) node.get("string")

int removeCount = 0
int removeCount = 0

if (string_node) {
string_node.each {
Node childNode = (Node) it
if (childNode.attribute("name") == "app_name") {
logLevel2 "Found value [app_name] in [" + maybeResourceFile.getAbsolutePath() + "]"
node.remove(childNode)
removeCount++
}
}
if (string_node) {
string_node.each {
Node childNode = (Node) it
if (childNode.attribute("name") == "app_name") {
logLevel2 "Found value [app_name] in [" + maybeResourceFile.getAbsolutePath() + "]"
node.remove(childNode)
removeCount++
}
}
}

if (removeCount > 0) {
logLevel2 "Delete " + removeCount + " values..."
Files.asCharSink(maybeResourceFile, Charsets.UTF_8).write(XmlUtil.serialize(node))
}
if (removeCount > 0) {
logLevel2 "Delete " + removeCount + " values..."
Files.asCharSink(maybeResourceFile, Charsets.UTF_8).write(XmlUtil.serialize(node))
}
}
}
}

Expand Down

0 comments on commit dfa3baa

Please sign in to comment.