Search in sources :

Example 6 with AndroidFacetConfiguration

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);
}
Also used : AndroidFacetConfiguration(org.jetbrains.android.facet.AndroidFacetConfiguration) Element(org.jdom.Element) Module(com.intellij.openapi.module.Module)

Example 7 with AndroidFacetConfiguration

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) AndroidFacetConfiguration(org.jetbrains.android.facet.AndroidFacetConfiguration) Module(com.intellij.openapi.module.Module) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Aggregations

AndroidFacetConfiguration (org.jetbrains.android.facet.AndroidFacetConfiguration)7 Module (com.intellij.openapi.module.Module)3 AndroidFacet (org.jetbrains.android.facet.AndroidFacet)3 Project (com.intellij.openapi.project.Project)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 FacetManager (com.intellij.facet.FacetManager)1 ModifiableFacetModel (com.intellij.facet.ModifiableFacetModel)1 ProjectFacetManager (com.intellij.facet.ProjectFacetManager)1 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 Artifact (com.intellij.packaging.artifacts.Artifact)1 File (java.io.File)1 Element (org.jdom.Element)1 AndroidPlatform (org.jetbrains.android.sdk.AndroidPlatform)1 JpsAndroidModuleProperties (org.jetbrains.jps.android.model.impl.JpsAndroidModuleProperties)1