-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add jcenter,add extended parameters for plugin
- Loading branch information
1 parent
59d4878
commit ba3fe05
Showing
60 changed files
with
317 additions
and
358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
buildscript { | ||
repositories { | ||
mavenLocal() | ||
jcenter() | ||
} | ||
|
||
dependencies { | ||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4' | ||
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' | ||
} | ||
} | ||
|
||
apply plugin: 'groovy' | ||
apply plugin: 'com.jfrog.bintray' | ||
|
||
configurations { | ||
provided { | ||
dependencies.all { dep -> | ||
configurations.default.exclude group: dep.group, module: dep.name | ||
} | ||
} | ||
compile.extendsFrom provided | ||
} | ||
|
||
dependencies { | ||
compile gradleApi() | ||
compile localGroovy() | ||
provided 'com.android.tools.build:builder:2.1.3' | ||
provided 'com.android.tools.build:gradle-core:2.1.3' | ||
} | ||
|
||
tasks.withType(Javadoc) { | ||
// enabled = false //禁用生成javadoc的任务 | ||
options.encoding = "UTF-8" | ||
} | ||
|
||
ext { | ||
bintrayRepo = 'maven' | ||
bintrayName = "$LIBRARY_NAME" //maven 仓库中的包名 | ||
|
||
publishedGroupId = "$GROUP_ID" | ||
libraryName = "$LIBRARY_NAME" | ||
artifact = "$LIBRARY_NAME"//必须跟Model名一样 | ||
|
||
libraryDescription = 'android multidex plugin' | ||
|
||
siteUrl = 'https://github.com/TangXiaoLv/Android-Easy-MultiDex' | ||
gitUrl = 'https://github.com/TangXiaoLv/Android-Easy-MultiDex.git' | ||
|
||
libraryVersion = "$PUBLIC_VERSION" | ||
|
||
developerId = 'tangxiaolv' | ||
developerName = 'XiaoLv Tang' | ||
developerEmail = '[email protected]' | ||
|
||
licenseName = 'The Apache Software License, Version 2.0' | ||
licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' | ||
allLicenses = ["Apache-2.0"] | ||
} | ||
|
||
// Place it at the end of the file | ||
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle' | ||
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle' | ||
|
||
uploadArchives { | ||
repositories { | ||
mavenDeployer { | ||
repository(url: uri('../repo')) | ||
pom.groupId = "$GROUP_ID" | ||
pom.artifactId = "$LIBRARY_NAME" | ||
pom.version = "$LOCAL_VERSION" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#Gradle:groupId:libraryName:publicVersion | ||
LOCAL_VERSION=0.0.5 | ||
PUBLIC_VERSION=1.0.1 | ||
GROUP_ID=com.library.tangxiaolv | ||
#±ØÐë¸úModelÃûÒ»Ñù | ||
LIBRARY_NAME=dexknife-plus |
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
DexKnifePlugin/dexknife-plus/src/main/groovy/com/ceabie/dexknife/DexKnifeExtension.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.ceabie.dexknife | ||
|
||
class DexKnifeExtension { | ||
boolean enabled = false | ||
String productFlavor = "" | ||
String buildType = "" | ||
} |
121 changes: 121 additions & 0 deletions
121
DexKnifePlugin/dexknife-plus/src/main/groovy/com/ceabie/dexknife/DexKnifePlugin.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
* Copyright (C) 2016 ceabie (https://github.com/ceabie/) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package com.ceabie.dexknife | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
|
||
/** | ||
* the spilt tools plugin. | ||
*/ | ||
public class DexKnifePlugin implements Plugin<Project> { | ||
|
||
@Override | ||
void apply(Project project) { | ||
|
||
DexKnifeExtension dexKnifeExtension = project.extensions.create('dexKnife', DexKnifeExtension) | ||
project.afterEvaluate { | ||
boolean hasApp = project.plugins.hasPlugin("com.android.application") | ||
print("-hasApp = ${hasApp}\n") | ||
if (!hasApp) { | ||
throw new IllegalStateException("'android' plugin required.") | ||
} | ||
|
||
final def variants = project.android.applicationVariants | ||
variants.each{variant -> | ||
if (dexKnifeExtension.enabled) { | ||
boolean checkProductFlavor = dexKnifeExtension.productFlavor == "" || dexKnifeExtension.productFlavor.equalsIgnoreCase(variant.flavorName) | ||
boolean checkBuildType = dexKnifeExtension.buildType == "" || dexKnifeExtension.buildType.equalsIgnoreCase(variant.buildType.name) | ||
if (checkProductFlavor && checkBuildType) { | ||
printf "-DexKnifePlugin Enable = true\n"; | ||
printf "-DexKnifePlugin checkProductFlavor = ${checkProductFlavor}\n"; | ||
printf "-DexKnifePlugin checkBuildType = ${checkBuildType}\n"; | ||
printf "-DexKnifePlugin buildType.name = ${variant.buildType.name}\n"; | ||
printf "-DexKnifePlugin flavorName = ${variant.flavorName}\n"; | ||
|
||
filterActivity(project); | ||
|
||
if (isMultiDexEnabled(variant)) { | ||
if (SplitToolsFor130.isCompat(variant)) { | ||
System.err.println("DexKnife: Compat 1.3.0."); | ||
SplitToolsFor130.processSplitDex(project, variant) | ||
} else if (SplitToolsFor150.isCompat()) { | ||
SplitToolsFor150.processSplitDex(project, variant) | ||
} else { | ||
System.err.println("DexKnife Error: DexKnife is not compatible your Android gradle plugin."); | ||
} | ||
} else { | ||
System.err.println("DexKnife : MultiDexEnabled is false, it's not work."); | ||
} | ||
} | ||
} | ||
printf "-DexKnifePlugin Enable = false\n"; | ||
} | ||
} | ||
} | ||
|
||
//filter Activity | ||
private static void filterActivity(Project project) { | ||
File file = project.file(DexSplitTools.DEX_KNIFE_CFG_TXT) | ||
if (file != null) { | ||
def justActivitys = []; | ||
file.eachLine { line -> | ||
//printf "read line ${line}\n"; | ||
if (line.startsWith('-just activity')) { | ||
line = line.replaceAll('-just activity', '').trim(); | ||
justActivitys.add(line) | ||
} | ||
} | ||
printf "-just activity size = ${justActivitys.size()}\n"; | ||
if (justActivitys.size() != 0) { | ||
project.tasks.each { task -> | ||
if (task.name.startsWith('collect') && task.name.endsWith('MultiDexComponents')) { | ||
println "main-dex-filter: found task $task.name" | ||
task.filter { name, attrs -> | ||
String componentName = attrs.get('android:name') | ||
if ('activity'.equals(name)) { | ||
def result = justActivitys.find { | ||
componentName.endsWith("${it}") | ||
} | ||
def bool = result != null; | ||
if (bool) { | ||
printf "main-dex-filter: keep ${componentName}\n" | ||
} | ||
return bool | ||
} | ||
return true | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private static boolean isMultiDexEnabled(variant) { | ||
def is = variant.buildType.multiDexEnabled | ||
if (is != null) { | ||
return is; | ||
} | ||
|
||
is = variant.mergedFlavor.multiDexEnabled | ||
if (is != null) { | ||
return is; | ||
} | ||
|
||
return false | ||
} | ||
|
||
} |
Oops, something went wrong.