Skip to content

Commit c25d115

Browse files
author
wanjian
committed
追加、重置 压缩记录
1 parent bc30592 commit c25d115

File tree

7 files changed

+28
-10
lines changed

7 files changed

+28
-10
lines changed

app/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ tinyPng {
6464
enable true
6565
skip9Png true
6666
abortOnError true
67+
appendCompressRecord false
6768
keys = [
6869
"mT1td5Qt6JW7yy0n2pkJd6ZwBxmHsjBy",
6970
"ctW1PG2wJhpJYxDhcj4NSgQ14WFxC7gb",

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ buildscript {
1212
dependencies {
1313
classpath 'com.android.tools.build:gradle:3.0.0'
1414
// classpath "com.wanjian.plugin:tinypng:1.0.0-SNAPSHOT"
15-
classpath "com.wanjian.plugin:tinypng:0.0.2"
15+
classpath "com.wanjian.plugin:tinypng:0.0.6"
1616
classpath 'com.novoda:bintray-release:0.8.0'
1717

1818
// NOTE: Do not place your application dependencies here; they belong

gradle.properties

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ org.gradle.jvmargs=-Xmx1536m
1212
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
1313
# org.gradle.parallel=true
1414
#org.gradle.daemon=true
15-
#org.gradle.debug=true
16-
#java.net.preferIPv4Stack=true
15+
#org.gradle.debug=true

module2/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ tinyPng {
2929
enable true
3030
skip9Png true
3131
abortOnError true
32+
appendCompressRecord false
3233
keys=[
3334
"mT1td5Qt6JW7yy0n2pkJd6ZwBxmHsjBy",
3435
"ctW1PG2wJhpJYxDhcj4NSgQ14WFxC7gb",

tinypng/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def getKey() {
4747
publish {
4848
groupId = 'com.wanjian.plugin'
4949
artifactId = 'tinypng'
50-
publishVersion = '0.0.5'
50+
publishVersion = '0.0.6'
5151
desc = 'tiny png plugin 4 android'
5252
website = 'https://github.com/android-notes/TinyPngPlugin'
5353

tinypng/src/main/groovy/com/wanjian/plugin/config/TinyPng.groovy

+13-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,20 @@ public class TinyPng {
55
boolean enable;
66

77
def keys = [];
8-
//是否不压缩 9.png图片
8+
/**
9+
* 是否不压缩 9.png图片
10+
*/
911
boolean skip9Png = true
1012

11-
//压缩失败时是否停止task
13+
/**
14+
* 压缩失败时是否停止task
15+
*/
1216
boolean abortOnError;
17+
18+
/**
19+
* 是否在compressed_pictures文件中追加压缩后的图片的MD5值
20+
* true: 追加
21+
* false: 重置
22+
*/
23+
boolean appendCompressRecord = false;
1324
}

tinypng/src/main/groovy/com/wanjian/plugin/tasks/TinyPngProcessTask.groovy

+10-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import org.gradle.api.tasks.TaskAction
1010
class TinyPngProcessTask extends DefaultTask {
1111

1212
def variant
13-
String[] compressedPictureFiles
14-
String[] excludePictureFiles
13+
def compressedPictureFiles
14+
def excludePictureFiles
1515

1616
@TaskAction
1717
void process() {
@@ -116,14 +116,20 @@ class TinyPngProcessTask extends DefaultTask {
116116
File compressedPicturesFile = new File("${project.projectDir}/compressed_pictures")
117117
BufferedWriter writer = new BufferedWriter(new FileWriter(compressedPicturesFile, false))
118118
writer.write("# Do not modify this file !")
119+
120+
if (project.tinyPng.appendCompressRecord) {
121+
allImageMD5s.addAll(compressedPictureFiles)
122+
}
123+
allImageMD5s.unique()
124+
allImageMD5s.sort()
119125
allImageMD5s.each {
120126
writer.newLine()
121127
writer.write(it)
122128
}
123129
writer.close()
124130
}
125131

126-
String[] getCompressedPictureFiles() {
132+
def getCompressedPictureFiles() {
127133
File compressedPictureFiles = new File("${project.projectDir}/compressed_pictures")
128134
def compressedPicturesList = []
129135
if (compressedPictureFiles.isFile()) {
@@ -136,7 +142,7 @@ class TinyPngProcessTask extends DefaultTask {
136142
return compressedPicturesList;
137143
}
138144

139-
String[] getExcludePictureFiles() {
145+
def getExcludePictureFiles() {
140146
File excludePicturesFile = new File("${project.projectDir}/exclude_pictures.txt")
141147
def excludeList = []
142148
if (excludePicturesFile.isFile()) {

0 commit comments

Comments
 (0)