-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #844 from hyongbai/fea-2.3.3
gradle兼容等
- Loading branch information
Showing
14 changed files
with
439 additions
and
186 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
replugin-host-gradle/src/main/groovy/com/qihoo360/replugin/gradle/compat/ScopeCompat.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,40 @@ | ||
package com.qihoo360.replugin.gradle.compat | ||
|
||
import com.android.sdklib.IAndroidTarget | ||
|
||
/** | ||
* @author hyongbai | ||
*/ | ||
class ScopeCompat { | ||
static def getAdbExecutable(def scope) { | ||
final MetaClass scopeClz = scope.metaClass | ||
if (scopeClz.hasProperty(scope, "androidBuilder")) { | ||
return scope.androidBuilder.sdkInfo.adb | ||
} | ||
if (scopeClz.hasProperty(scope, "sdkComponents")) { | ||
return scope.sdkComponents.adbExecutableProvider.get() | ||
} | ||
} | ||
|
||
// TODO: getBuilderTarget | ||
// static def getBuilderTarget(def scope, def target){ | ||
// final MetaClass scopeClz = scope.metaClass | ||
// | ||
// if (scopeClz.hasProperty(scope, "androidBuilder")) { | ||
// return scope.getAndroidBuilder().getTarget().getPath(target) //IAndroidTarget.ANDROID_JAR | ||
// } | ||
// | ||
// return globalScope.getAndroidBuilder().getTarget().getPath(IAndroidTarget.ANDROID_JAR) | ||
// } | ||
|
||
static def getAndroidJar(def scope){ | ||
final MetaClass scopeClz = scope.metaClass | ||
|
||
if (scopeClz.hasProperty(scope, "androidBuilder")) { | ||
return scope.getAndroidBuilder().getTarget().getPath(IAndroidTarget.ANDROID_JAR) | ||
} | ||
if (scopeClz.hasProperty(scope, "sdkComponents")) { | ||
return scope.sdkComponents.androidJarProvider.get().getAbsolutePath() | ||
} | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...ugin-host-gradle/src/main/groovy/com/qihoo360/replugin/gradle/compat/VariantCompat.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,38 @@ | ||
package com.qihoo360.replugin.gradle.compat | ||
|
||
import org.gradle.api.Task | ||
|
||
/** | ||
* @author hyongbai | ||
*/ | ||
class VariantCompat { | ||
static def getAssembleTask(def variant) { | ||
return compatGetTask(variant, "getAssembleProvider", "getAssemble") | ||
} | ||
|
||
static def getMergeAssetsTask(def variant) { | ||
return compatGetTask(variant, "getMergeAssetsProvider", "getMergeAssets") | ||
} | ||
|
||
static def getGenerateBuildConfigTask(def variant) { | ||
return compatGetTask(variant, "getGenerateBuildConfigProvider", "getGenerateBuildConfig") | ||
} | ||
|
||
static def getProcessManifestTask(def variant) { | ||
return compatGetTask(variant, "getProcessManifestProvider", "getProcessManifest") | ||
} | ||
|
||
static def compatGetTask(def variant, String... candidates) { | ||
candidates?.findResult { | ||
variant.metaClass.respondsTo(variant, it).with { | ||
if (!it.isEmpty()) return it | ||
} | ||
}?.find { | ||
it.getParameterTypes().length == 0 | ||
}?.invoke(variant)?.with { | ||
//TODO: check if is provider!!! | ||
Task.class.isInstance(it) ? it : it?.get() | ||
} | ||
} | ||
|
||
} |
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
Oops, something went wrong.