From f710421ecb763373732a80337599d7a720adf58a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CsmallSohoSolo=E2=80=9D?= Date: Wed, 16 Aug 2017 17:27:34 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=B8=AAwarning=20=EF=BC=8C=20=E4=B8=80=E4=B8=AA=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E4=BC=9A=E5=9C=A8gradle=205.0=E8=A2=AB=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mcplugin/image/ImagePlugin.groovy | 55 ++++++++++--------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/src/main/groovy/com/smallsoho/mcplugin/image/ImagePlugin.groovy b/src/main/groovy/com/smallsoho/mcplugin/image/ImagePlugin.groovy index ec601c8..97e1c91 100644 --- a/src/main/groovy/com/smallsoho/mcplugin/image/ImagePlugin.groovy +++ b/src/main/groovy/com/smallsoho/mcplugin/image/ImagePlugin.groovy @@ -71,44 +71,47 @@ class ImagePlugin implements Plugin { def processResourceTask = project.tasks.findByName("process${variant.name.capitalize()}Resources") def mcPicPlugin = "McImage${variant.name.capitalize()}" - project.task(mcPicPlugin) << { + project.task(mcPicPlugin) { + doLast { + println 'Sample task' - String resPath = "${project.projectDir}/build/intermediates/res/${imgDir}/" - def dir = new File("${resPath}") + String resPath = "${project.projectDir}/build/intermediates/res/${imgDir}/" - ArrayList 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 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()) } - } //inject plugin From c9a63f70ee35302da3469abf527a2500d7e09b6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CsmallSohoSolo=E2=80=9D?= Date: Mon, 21 Aug 2017 21:56:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8DDebug=E4=BB=8D=E7=84=B6?= =?UTF-8?q?=E6=89=93=E5=8D=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/smallsoho/mcplugin/image/ImagePlugin.groovy | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/groovy/com/smallsoho/mcplugin/image/ImagePlugin.groovy b/src/main/groovy/com/smallsoho/mcplugin/image/ImagePlugin.groovy index 97e1c91..c47a166 100644 --- a/src/main/groovy/com/smallsoho/mcplugin/image/ImagePlugin.groovy +++ b/src/main/groovy/com/smallsoho/mcplugin/image/ImagePlugin.groovy @@ -36,13 +36,13 @@ class ImagePlugin implements Plugin { 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 @@ -66,6 +66,7 @@ class ImagePlugin implements Plugin { //debug enable if (isDebugTask && !mConfig.enableWhenDebug) { + println 'Debug not run !' return } @@ -73,8 +74,8 @@ class ImagePlugin implements Plugin { def mcPicPlugin = "McImage${variant.name.capitalize()}" project.task(mcPicPlugin) { doLast { - println 'Sample task' + println '---- McImage Plugin Start ----' String resPath = "${project.projectDir}/build/intermediates/res/${imgDir}/" @@ -111,6 +112,8 @@ class ImagePlugin implements Plugin { } throw new GradleException(stringBuffer.toString()) } + + println '---- McImage Plugin End ----' } } From c69f05c48f5f84f20515a974ad7c1bb66a3bb384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CsmallSohoSolo=E2=80=9D?= Date: Mon, 21 Aug 2017 22:03:31 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8F=90=E5=8D=87=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=B8=BA0.1.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README-CN.md | 2 +- README.md | 2 +- bintray.gradle | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README-CN.md b/README-CN.md index 6af73af..52f9b40 100644 --- a/README-CN.md +++ b/README-CN.md @@ -41,7 +41,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.smallsoho.mobcase:McImage:0.0.4' + classpath 'com.smallsoho.mobcase:McImage:0.1.0' } } ``` diff --git a/README.md b/README.md index ac9d2cb..e56dec2 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.smallsoho.mobcase:McImage:0.0.4' + classpath 'com.smallsoho.mobcase:McImage:0.1.0' } } ``` diff --git a/bintray.gradle b/bintray.gradle index 0d940bc..1fd78b7 100644 --- a/bintray.gradle +++ b/bintray.gradle @@ -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())