use of com.android.build.gradle.AndroidConfig in project atlas by alibaba.
the class AtlasPlugin method configurePlugin.
/**
* 启动设置插件
*/
private void configurePlugin() {
creator = "Atlas Gradle PLUGIN";
extraModelInfo = new ExtraModelInfo(project, PluginTypeUtils.isLibraryProject(project));
prepareBuildTools(project, extraModelInfo, atlasExtension.getTBuildConfig().getUseCustomAapt());
tAndroidBuilder = AtlasBuildContext.androidBuilder;
sdkHandler = new SdkHandler(project, getLogger());
AndroidConfig extension = DefaultGroovyMethods.asType(DefaultGroovyMethods.getAt(project.getExtensions(), "android"), AndroidConfig.class);
sdkHandler.initTarget(extension.getCompileSdkVersion(), extension.getBuildToolsRevision(), extension.getLibraryRequests(), tAndroidBuilder, SdkHandler.useCachedSdk(project));
project.getGradle().addBuildListener(new BuildListener() {
@Override
public void buildStarted(Gradle gradle) {
}
@Override
public void settingsEvaluated(Settings settings) {
}
@Override
public void projectsLoaded(Gradle gradle) {
}
@Override
public void projectsEvaluated(Gradle gradle) {
}
@Override
public void buildFinished(BuildResult buildResult) {
sdkHandler.unload();
}
private final LibraryCache libraryCache = LibraryCache.getCache();
});
}
use of com.android.build.gradle.AndroidConfig in project atlas by alibaba.
the class MergeAwbResourceConfigAction method execute.
@Override
public void execute(MergeResources mergeResourcesTask) {
VariantScope scope = variantContext.getScope();
final BaseVariantData<? extends BaseVariantOutputData> variantData = scope.getVariantData();
final AndroidConfig extension = scope.getGlobalScope().getExtension();
//final VariantConfiguration variantConfig = variantData.getVariantConfiguration();
mergeResourcesTask.setMinSdk(variantData.getVariantConfiguration().getMinSdkVersion().getApiLevel());
mergeResourcesTask.setAndroidBuilder(scope.getGlobalScope().getAndroidBuilder());
mergeResourcesTask.setVariantName(scope.getVariantConfiguration().getFullName());
GlobalScope globalScope = scope.getGlobalScope();
mergeResourcesTask.setIncrementalFolder(scope.getIncrementalDir(getName()));
try {
FieldUtils.writeField(mergeResourcesTask, "variantScope", scope, true);
} catch (IllegalAccessException e) {
throw new GradleException("exception", e);
}
// where blame is useful, and once for packaging where it is not.
if (includeDependencies) {
mergeResourcesTask.setBlameLogFolder(scope.getResourceBlameLogDir());
} else {
// if (variantContext instanceof AppVariantContext) {
// mergeResourcesTask.setBlameLogFolder(((AppVariantContext) variantContext).getAwbBlameLogFolder(awbBundle));
// }
}
mergeResourcesTask.setProcess9Patch(process9Patch);
mergeResourcesTask.setCrunchPng(extension.getAaptOptions().getCruncherEnabled());
VectorDrawablesOptions vectorDrawablesOptions = variantData.getVariantConfiguration().getMergedFlavor().getVectorDrawables();
Set<String> generatedDensities = vectorDrawablesOptions.getGeneratedDensities();
mergeResourcesTask.setGeneratedDensities(Objects.firstNonNull(generatedDensities, Collections.<String>emptySet()));
mergeResourcesTask.setDisableVectorDrawables(vectorDrawablesOptions.getUseSupportLibrary() || mergeResourcesTask.getGeneratedDensities().isEmpty());
//mergeResourcesTask.setUseNewCruncher(extension.getAaptOptions().getUseNewCruncher());
final boolean validateEnabled = AndroidGradleOptions.isResourceValidationEnabled(scope.getGlobalScope().getProject());
mergeResourcesTask.setValidateEnabled(validateEnabled);
ConventionMappingHelper.map(mergeResourcesTask, "inputResourceSets", new Callable<List<ResourceSet>>() {
@Override
public List<ResourceSet> call() throws Exception {
List<ResourceSet> resourceSets = Lists.newArrayList();
List<? extends AndroidLibrary> bundleDeps = awbBundle.getLibraryDependencies();
// the list of dependency must be reversed to use the right overlay order.
for (int n = bundleDeps.size() - 1; n >= 0; n--) {
AndroidLibrary dependency = bundleDeps.get(n);
File resFolder = dependency.getResFolder();
if (resFolder.isDirectory()) {
ResourceSet resourceSet = new ResourceSet(dependency.getFolder().getName(), true);
resourceSet.addSource(resFolder);
resourceSets.add(resourceSet);
}
}
File awbResourceFolder = awbBundle.getResFolder();
if (awbResourceFolder.isDirectory()) {
ResourceSet resourceSet = new ResourceSet(awbBundle.getFolder().getName(), true);
resourceSet.addSource(awbResourceFolder);
resourceSets.add(resourceSet);
}
return resourceSets;
}
});
mergeResourcesTask.setOutputDir(variantContext.getMergeResources(awbBundle));
mergeResourcesTask.setGeneratedPngsOutputDir(variantContext.getPngsOutputDir(awbBundle));
// if (variantContext instanceof AppVariantContext) {
// AppVariantContext appVariantContext = (AppVariantContext) variantContext;
// appVariantContext.getAwbMergeResourceTasks().put(awbBundle.getName(), mergeResourcesTask);
// }
}
Aggregations