use of com.android.builder.model.SourceProvider in project atlas by alibaba.
the class ModuleInfoWriter method write.
public void write() {
//生成项目的基本信息
try {
ModuleInfo moduleInfo = new ModuleInfo();
moduleInfo.group = project.getGroup().toString();
moduleInfo.name = project.getName();
moduleInfo.version = project.getVersion().toString();
moduleInfo.path = project.getProjectDir().getAbsolutePath().replace(project.getRootDir().getAbsolutePath(), "").substring(1);
//获取android manifst
moduleInfo.packageName = libraryVariant.getApplicationId();
List<SourceProvider> sourceProviders = libraryVariant.getSourceSets();
for (SourceProvider sourceProvider : sourceProviders) {
for (File java : sourceProvider.getJavaDirectories()) {
if (java.exists()) {
moduleInfo.java_SrcDirs.add(java.getAbsolutePath());
}
}
for (File res : sourceProvider.getResDirectories()) {
if (res.exists()) {
moduleInfo.res_srcDirs.add(res.getAbsolutePath());
}
}
for (File assets : sourceProvider.getAssetsDirectories()) {
if (assets.exists()) {
moduleInfo.assets_srcDirs.add(assets.getAbsolutePath());
}
}
}
File moduleInfoFile = new File(project.getRootDir(), ".awo/" + moduleInfo.name + ".mi");
moduleInfoFile.getParentFile().mkdirs();
FileUtils.write(moduleInfoFile, JSON.toJSONString(moduleInfo, true));
} catch (Throwable e) {
e.printStackTrace();
}
}
use of com.android.builder.model.SourceProvider in project kotlin by JetBrains.
the class IntellijLintUtils method getResourceDirectories.
/** Returns the resource directories to use for the given module */
@NotNull
public static List<File> getResourceDirectories(@NotNull AndroidFacet facet) {
if (facet.requiresAndroidModel()) {
AndroidModel androidModel = facet.getAndroidModel();
if (androidModel != null) {
List<File> resDirectories = new ArrayList<File>();
List<SourceProvider> sourceProviders = androidModel.getActiveSourceProviders();
for (SourceProvider provider : sourceProviders) {
for (File file : provider.getResDirectories()) {
if (file.isDirectory()) {
resDirectories.add(file);
}
}
}
return resDirectories;
}
}
return new ArrayList<File>(facet.getMainSourceProvider().getResDirectories());
}
use of com.android.builder.model.SourceProvider in project android by JetBrains.
the class AndroidFacetModuleSetupStep method configureFacet.
private static void configureFacet(@NotNull AndroidFacet facet, @NotNull AndroidModuleModel androidModel) {
JpsAndroidModuleProperties facetProperties = facet.getProperties();
facetProperties.ALLOW_USER_CONFIGURATION = false;
facetProperties.PROJECT_TYPE = androidModel.getProjectType();
File modulePath = androidModel.getRootDirPath();
SourceProvider sourceProvider = androidModel.getDefaultSourceProvider();
facetProperties.MANIFEST_FILE_RELATIVE_PATH = relativePath(modulePath, sourceProvider.getManifestFile());
facetProperties.RES_FOLDER_RELATIVE_PATH = relativePath(modulePath, sourceProvider.getResDirectories());
facetProperties.ASSETS_FOLDER_RELATIVE_PATH = relativePath(modulePath, sourceProvider.getAssetsDirectories());
syncSelectedVariant(facetProperties, androidModel);
facet.setAndroidModel(androidModel);
androidModel.syncSelectedVariantAndTestArtifact(facet);
}
use of com.android.builder.model.SourceProvider in project android by JetBrains.
the class IconStep method getResourceFolders.
private List<File> getResourceFolders() {
SourceProvider provider = myState.get(mySourceProviderKey);
if (provider == null) {
return Collections.emptyList();
}
List<File> dirs = Lists.newLinkedList();
dirs.addAll(provider.getResDirectories());
return dirs;
}
use of com.android.builder.model.SourceProvider in project android by JetBrains.
the class AddAndroidActivityPath method getInitialPackageName.
/**
* Initial package name is either a package user selected when invoking the wizard or default package for the module.
*/
private String getInitialPackageName(Module module, AndroidFacet facet) {
if (myTargetFolder != null) {
List<SourceProvider> sourceProviders = IdeaSourceProvider.getSourceProvidersForFile(facet, myTargetFolder, facet.getMainSourceProvider());
File targetDirectoryFile = VfsUtilCore.virtualToIoFile(myTargetFolder);
if (sourceProviders.size() > 0 && IdeaSourceProvider.containsFile(sourceProviders.get(0), targetDirectoryFile)) {
File srcDirectory = findSrcDirectory(sourceProviders.get(0));
if (srcDirectory != null) {
String packageName = ProjectRootManager.getInstance(module.getProject()).getFileIndex().getPackageNameByDirectory(myTargetFolder);
if (packageName != null) {
return packageName;
}
}
}
}
return getApplicationPackageName();
}
Aggregations