use of org.jetbrains.android.facet.AndroidFacetConfiguration in project android by JetBrains.
the class AndroidFacetImporterBase method configurePaths.
private void configurePaths(AndroidFacet facet, MavenProject project) {
Module module = facet.getModule();
String moduleDirPath = AndroidRootUtil.getModuleDirPath(module);
if (moduleDirPath == null) {
return;
}
AndroidFacetConfiguration configuration = facet.getConfiguration();
if (configuration.isImportedProperty(AndroidImportableProperty.RESOURCES_DIR_PATH)) {
String resFolderRelPath = getPathFromConfig(module, project, moduleDirPath, "resourceDirectory", true, true);
if (resFolderRelPath != null && isFullyResolved(resFolderRelPath)) {
configuration.getState().RES_FOLDER_RELATIVE_PATH = '/' + resFolderRelPath;
}
String resFolderForCompilerRelPath = getPathFromConfig(module, project, moduleDirPath, "resourceDirectory", false, true);
if (resFolderForCompilerRelPath != null && !resFolderForCompilerRelPath.equals(resFolderRelPath)) {
configuration.getState().USE_CUSTOM_APK_RESOURCE_FOLDER = true;
configuration.getState().CUSTOM_APK_RESOURCE_FOLDER = '/' + resFolderForCompilerRelPath;
configuration.getState().RUN_PROCESS_RESOURCES_MAVEN_TASK = true;
}
}
configuration.getState().RES_OVERLAY_FOLDERS = Arrays.asList("/res-overlay");
Element resourceOverlayDirectories = getConfig(project, "resourceOverlayDirectories");
if (resourceOverlayDirectories != null) {
List<String> dirs = new ArrayList<String>();
for (Object child : resourceOverlayDirectories.getChildren()) {
String dir = ((Element) child).getTextTrim();
if (dir != null && dir.length() > 0) {
String relativePath = getRelativePath(moduleDirPath, makePath(project, dir));
if (relativePath != null && relativePath.length() > 0) {
dirs.add('/' + relativePath);
}
}
}
if (dirs.size() > 0) {
configuration.getState().RES_OVERLAY_FOLDERS = dirs;
}
} else {
String resOverlayFolderRelPath = getPathFromConfig(module, project, moduleDirPath, "resourceOverlayDirectory", true, true);
if (resOverlayFolderRelPath != null && isFullyResolved(resOverlayFolderRelPath)) {
configuration.getState().RES_OVERLAY_FOLDERS = Arrays.asList('/' + resOverlayFolderRelPath);
}
}
if (configuration.isImportedProperty(AndroidImportableProperty.ASSETS_DIR_PATH)) {
String assetsFolderRelPath = getPathFromConfig(module, project, moduleDirPath, "assetsDirectory", false, true);
if (assetsFolderRelPath != null && isFullyResolved(assetsFolderRelPath)) {
configuration.getState().ASSETS_FOLDER_RELATIVE_PATH = '/' + assetsFolderRelPath;
}
}
if (configuration.isImportedProperty(AndroidImportableProperty.MANIFEST_FILE_PATH)) {
String manifestFileRelPath = getPathFromConfig(module, project, moduleDirPath, "androidManifestFile", true, false);
if (manifestFileRelPath != null && isFullyResolved(manifestFileRelPath)) {
configuration.getState().MANIFEST_FILE_RELATIVE_PATH = '/' + manifestFileRelPath;
}
String manifestFileForCompilerRelPath = getPathFromConfig(module, project, moduleDirPath, "androidManifestFile", false, false);
if (manifestFileForCompilerRelPath != null && !manifestFileForCompilerRelPath.equals(manifestFileRelPath) && isFullyResolved(manifestFileForCompilerRelPath)) {
configuration.getState().USE_CUSTOM_COMPILER_MANIFEST = true;
configuration.getState().CUSTOM_COMPILER_MANIFEST = '/' + manifestFileForCompilerRelPath;
configuration.getState().RUN_PROCESS_RESOURCES_MAVEN_TASK = true;
}
}
if (MavenProjectsManager.getInstance(module.getProject()).getImportingSettings().isUseMavenOutput()) {
final String buildDirectory = FileUtil.toSystemIndependentName(project.getBuildDirectory());
final String buildDirRelPath = FileUtil.getRelativePath(moduleDirPath, buildDirectory, '/');
configuration.getState().APK_PATH = '/' + buildDirRelPath + '/' + AndroidCompileUtil.getApkName(module);
} else {
configuration.getState().APK_PATH = "";
}
if (configuration.isImportedProperty(AndroidImportableProperty.NATIVE_LIBS_DIR_PATH)) {
String nativeLibsFolderRelPath = getPathFromConfig(module, project, moduleDirPath, "nativeLibrariesDirectory", false, true);
if (nativeLibsFolderRelPath != null && isFullyResolved(nativeLibsFolderRelPath)) {
configuration.getState().LIBS_FOLDER_RELATIVE_PATH = '/' + nativeLibsFolderRelPath;
}
}
importNativeDependencies(facet, project, moduleDirPath);
}
use of org.jetbrains.android.facet.AndroidFacetConfiguration in project android by JetBrains.
the class ApkStep method _init.
@Override
public void _init() {
if (myInited)
return;
final AndroidFacet facet = myWizard.getFacet();
Module module = facet.getModule();
PropertiesComponent properties = PropertiesComponent.getInstance(module.getProject());
String lastModule = properties.getValue(ChooseModuleStep.MODULE_PROPERTY);
String lastApkPath = properties.getValue(getApkPathPropertyName());
if (lastApkPath != null && module.getName().equals(lastModule)) {
myApkPathField.setText(FileUtil.toSystemDependentName(lastApkPath));
} else {
String contentRootPath = getContentRootPath(module);
if (contentRootPath != null) {
String defaultPath = FileUtil.toSystemDependentName(contentRootPath + "/" + module.getName() + ".apk");
myApkPathField.setText(defaultPath);
}
}
final String runProguardPropValue = properties.getValue(RUN_PROGUARD_PROPERTY);
boolean selected;
if (runProguardPropValue != null) {
selected = Boolean.parseBoolean(runProguardPropValue);
} else {
selected = facet.getProperties().RUN_PROGUARD;
}
myProguardCheckBox.setSelected(selected);
myProGuardConfigFilesPanel.setEnabled(selected);
final String proguardCfgPathsStr = properties.getValue(PROGUARD_CFG_PATHS_PROPERTY);
final String[] proguardCfgPaths = proguardCfgPathsStr != null ? parseAndCheckProguardCfgPaths(proguardCfgPathsStr) : null;
if (proguardCfgPaths != null && proguardCfgPaths.length > 0) {
myProGuardConfigFilesPanel.setOsPaths(Arrays.asList(proguardCfgPaths));
} else {
final AndroidFacetConfiguration configuration = facet.getConfiguration();
if (configuration.getState().RUN_PROGUARD) {
myProGuardConfigFilesPanel.setUrls(facet.getProperties().myProGuardCfgFiles);
} else {
final List<String> urls = new ArrayList<String>();
urls.add(AndroidCommonUtils.PROGUARD_SYSTEM_CFG_FILE_URL);
final Pair<VirtualFile, Boolean> pair = AndroidCompileUtil.getDefaultProguardConfigFile(facet);
if (pair != null) {
urls.add(pair.getFirst().getUrl());
}
myProGuardConfigFilesPanel.setUrls(urls);
}
}
myInited = true;
}
Aggregations