Skip to content

Commit

Permalink
Merge pull request #5 from Aweme/develop
Browse files Browse the repository at this point in the history
release 版本
  • Loading branch information
owenlongbo committed Aug 21, 2017
2 parents 913b285 + c69f05c commit 3115fc9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 33 deletions.
2 changes: 1 addition & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.smallsoho.mobcase:McImage:0.0.4'
classpath 'com.smallsoho.mobcase:McImage:0.1.0'
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.smallsoho.mobcase:McImage:0.0.4'
classpath 'com.smallsoho.mobcase:McImage:0.1.0'
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion bintray.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'com.jfrog.bintray'
def siteUrl = 'https://github.com/Aweme/McImage'
def gitUrl = 'https://github.com/Aweme/McImage.git'
group = "com.smallsoho.mobcase"
version = "0.0.4"
version = "0.1.0"

Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
Expand Down
66 changes: 36 additions & 30 deletions src/main/groovy/com/smallsoho/mcplugin/image/ImagePlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ class ImagePlugin implements Plugin<Project> {
for (int index = 0; index < taskNames.size(); ++index) {
def taskName = taskNames[index]
if (taskName.contains("assemble") || taskName.contains("resguard")) {
if (taskName.toLowerCase().endsWith("debug") &&
taskName.toLowerCase().contains("debug")) {
isDebugTask = true
}
isContainAssembleTask = true
break
}
if (taskName.endsWith("Debug") && taskName.contains("Debug")) {
isDebugTask = true
break
}
}

//export build clean
Expand All @@ -66,49 +66,55 @@ class ImagePlugin implements Plugin<Project> {

//debug enable
if (isDebugTask && !mConfig.enableWhenDebug) {
println 'Debug not run !'
return
}

def processResourceTask = project.tasks.findByName("process${variant.name.capitalize()}Resources")
def mcPicPlugin = "McImage${variant.name.capitalize()}"
project.task(mcPicPlugin) << {
project.task(mcPicPlugin) {
doLast {

String resPath = "${project.projectDir}/build/intermediates/res/${imgDir}/"
println '---- McImage Plugin Start ----'

def dir = new File("${resPath}")
String resPath = "${project.projectDir}/build/intermediates/res/${imgDir}/"

ArrayList<String> bigImgList = new ArrayList<>()
def dir = new File("${resPath}")

dir.eachDir() { channelDir ->
channelDir.eachDir { drawDir ->
def file = new File("${drawDir}")
if (file.name.contains('drawable') || file.name.contains('mipmap')) {
file.eachFile { imgFile ->
ArrayList<String> bigImgList = new ArrayList<>()

if (mConfig.isCheck && ImageUtil.isBigImage(imgFile, mConfig.maxSize)) {
bigImgList.add(file.getPath() + file.getName())
}
if (mConfig.isCompress) {
CompressUtil.compressImg(imgFile)
}
if (mConfig.isWebpConvert) {
WebpUtils.securityFormatWebp(imgFile, mConfig, mProject)
}
dir.eachDir() { channelDir ->
channelDir.eachDir { drawDir ->
def file = new File("${drawDir}")
if (file.name.contains('drawable') || file.name.contains('mipmap')) {
file.eachFile { imgFile ->

if (mConfig.isCheck && ImageUtil.isBigImage(imgFile, mConfig.maxSize)) {
bigImgList.add(file.getPath() + file.getName())
}
if (mConfig.isCompress) {
CompressUtil.compressImg(imgFile)
}
if (mConfig.isWebpConvert) {
WebpUtils.securityFormatWebp(imgFile, mConfig, mProject)
}

}
}
}
}
}

if (bigImgList.size() != 0) {
StringBuffer stringBuffer = new StringBuffer("You have big Img!!!! \n")
for (int i = 0; i < bigImgList.size(); i++) {
stringBuffer.append(bigImgList.get(i))
stringBuffer.append("\n")
if (bigImgList.size() != 0) {
StringBuffer stringBuffer = new StringBuffer("You have big Img!!!! \n")
for (int i = 0; i < bigImgList.size(); i++) {
stringBuffer.append(bigImgList.get(i))
stringBuffer.append("\n")
}
throw new GradleException(stringBuffer.toString())
}
throw new GradleException(stringBuffer.toString())
}

println '---- McImage Plugin End ----'
}
}

//inject plugin
Expand Down

0 comments on commit 3115fc9

Please sign in to comment.