separate option for AndroidManifest.xml in "compiler" section

This commit is contained in:
Eugene Kudelevsky
2010-11-11 17:15:16 +03:00
parent 90bc2fdbb9
commit f51283681d
9 changed files with 130 additions and 26 deletions
@@ -214,4 +214,7 @@ android.run.configuration.logcat.tab.title=Logcat
android.facet.settings.apk.path.label=APK path:
android.run.confguration.deploy.and.install.check.box=Deplo&y application
android.manifest.debuggable.attribute.not.true.warning=The manifest 'debuggable' attribute isn't set to 'true'.\nYou have to set it to true in order to debug on a device.\nWould you like to do it?
android.logcat.no.android.facets.error=There is no Android facets in the project
android.logcat.no.android.facets.error=There is no Android facets in the project
android.facet.compiler.settings.manifest.title=Manifest
android.facet.settings.compiler.manifest.from.structure=Use AndroidManifest.xml file specified at "Structure" section
android.facet.settings.compiler.manifest.use.custom=Use custom manifest file:
@@ -254,15 +254,16 @@ public class AndroidAptCompiler implements SourceGeneratingCompiler {
if (target != null) {
AndroidCompileUtil.createSourceRootIfNotExist(sourceRootPath, module);
String assetsDirPath = assetsDir != null ? assetsDir.getPath() : null;
VirtualFile manifestFile = AndroidRootUtil.getManifestFile(module);
assert manifestFile != null;
String manifestPath = manifestFile.getPath();
items.add(new AptGenerationItem(module, manifestPath, resPaths, assetsDirPath, sourceRootPath, target,
packageName, false));
for (String libPackage : AndroidUtils.getDepLibsPackages(module)) {
VirtualFile manifestFile = AndroidRootUtil.getManifestFileForCompiler(facet);
if (manifestFile != null) {
String manifestPath = manifestFile.getPath();
items.add(new AptGenerationItem(module, manifestPath, resPaths, assetsDirPath, sourceRootPath, target,
libPackage, true));
packageName, false));
for (String libPackage : AndroidUtils.getDepLibsPackages(module)) {
items.add(new AptGenerationItem(module, manifestPath, resPaths, assetsDirPath, sourceRootPath, target,
libPackage, true));
}
}
}
}
@@ -92,7 +92,7 @@ public class AndroidPackagingCompiler implements PackagingCompiler {
for (Module module : affectedModules) {
AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet != null && !facet.getConfiguration().LIBRARY_PROJECT) {
VirtualFile manifestFile = AndroidRootUtil.getManifestFile(module);
VirtualFile manifestFile = AndroidRootUtil.getManifestFileForCompiler(facet);
VirtualFile[] sourceRoots = getSourceRootsForModuleAndDependencies(module);
if (manifestFile != null) {
AndroidFacetConfiguration configuration = facet.getConfiguration();
@@ -45,7 +45,7 @@ public class AndroidResourcesPackagingCompiler implements ClassPostProcessingCom
for (Module module : affectedModules) {
AndroidFacet facet = AndroidFacet.getInstance(module);
if (facet != null && !facet.getConfiguration().LIBRARY_PROJECT) {
VirtualFile manifestFile = AndroidRootUtil.getManifestFile(module);
VirtualFile manifestFile = AndroidRootUtil.getManifestFileForCompiler(facet);
VirtualFile assetsDir = AndroidRootUtil.getAssetsDir(module);
if (manifestFile != null) {
AndroidFacetConfiguration configuration = facet.getConfiguration();
@@ -49,7 +49,7 @@ public class ResourcesValidityState implements ValidityState {
IAndroidTarget target = platform != null ? platform.getTarget() : null;
myAndroidTargetName = target != null ? target.getFullName() : "";
VirtualFile manifestFile = AndroidRootUtil.getManifestFile(module);
VirtualFile manifestFile = AndroidRootUtil.getManifestFileForCompiler(facet);
if (manifestFile != null) {
myResourceTimestamps.put(manifestFile.getPath(), manifestFile.getTimeStamp());
}
@@ -58,7 +58,7 @@ public class ResourcesValidityState implements ValidityState {
collectFiles(resourcesDir);
}
for (AndroidFacet depFacet : AndroidUtils.getAllAndroidDependencies(module, true)) {
VirtualFile depManifest = AndroidRootUtil.getManifestFile(depFacet.getModule());
VirtualFile depManifest = AndroidRootUtil.getManifestFileForCompiler(depFacet);
if (depManifest != null) {
myResourceTimestamps.put(depManifest.getPath(), depManifest.getTimeStamp());
}
@@ -57,6 +57,9 @@ public class AndroidFacetConfiguration implements FacetConfiguration {
public boolean USE_CUSTOM_APK_RESOURCE_FOLDER = false;
public String CUSTOM_APK_RESOURCE_FOLDER = "";
public boolean USE_CUSTOM_COMPILER_MANIFEST = false;
public String CUSTOM_COMPILER_MANIFEST = "";
public String APK_PATH = "";
public boolean ADD_ANDROID_LIBRARY = true;
@@ -3,7 +3,7 @@
<grid id="27dc6" binding="myContentPanel" layout-manager="GridLayoutManager" row-count="6" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="460" height="545"/>
<xy x="20" y="20" width="512" height="625"/>
</constraints>
<properties/>
<border type="none"/>
@@ -176,7 +176,7 @@
</vspacer>
</children>
</grid>
<grid id="84519" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="84519" layout-manager="GridLayoutManager" row-count="6" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="4" left="4" bottom="4" right="4"/>
<constraints>
<tabbedpane title="Compiler"/>
@@ -187,7 +187,7 @@
<grid id="1f282" binding="myAaptCompilerPanel" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="4" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="etched" title-resource-bundle="messages/AndroidBundle" title-key="android.apt.settings.title"/>
@@ -227,7 +227,7 @@
<grid id="4c810" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="4" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="etched" title-resource-bundle="messages/AndroidBundle" title-key="android.aidl.settings.title"/>
@@ -259,7 +259,7 @@
<grid id="3e085" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="4" bottom="0" right="0"/>
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="etched" title-resource-bundle="messages/AndroidBundle" title-key="android.apk.settings.title"/>
@@ -312,7 +312,7 @@
</grid>
<vspacer id="e716a">
<constraints>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="63343" class="javax.swing.JCheckBox" binding="myCopyResourcesFromArtifacts">
@@ -323,6 +323,39 @@
<text resource-bundle="messages/AndroidBundle" key="copy.resources.from.artifacts.setting"/>
</properties>
</component>
<grid id="50185" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="etched" title-resource-bundle="messages/AndroidBundle" title-key="android.facet.compiler.settings.manifest.title"/>
<children>
<component id="f22e9" class="javax.swing.JRadioButton" binding="myUseCompilerManifestFromStructureRadio">
<constraints>
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text resource-bundle="messages/AndroidBundle" key="android.facet.settings.compiler.manifest.from.structure"/>
</properties>
</component>
<component id="39195" class="javax.swing.JRadioButton" binding="myUseCustomCompilerManifestRadio">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<selected value="false"/>
<text resource-bundle="messages/AndroidBundle" key="android.facet.settings.compiler.manifest.use.custom"/>
</properties>
</component>
<component id="ec790" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="myCustomCompilerManifestPathField">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
</component>
</children>
</grid>
</children>
</grid>
</children>
@@ -342,5 +375,9 @@
<member id="d83b5"/>
<member id="df739"/>
</group>
<group name="buttonGroup2">
<member id="f22e9"/>
<member id="39195"/>
</group>
</buttonGroups>
</form>
@@ -103,6 +103,9 @@ public class AndroidFacetEditorTab extends FacetEditorTab {
private JCheckBox myGenerateUnsignedApk;
private ComboboxWithBrowseButton myApkPathCombo;
private JLabel myApkPathLabel;
private JRadioButton myUseCompilerManifestFromStructureRadio;
private JRadioButton myUseCustomCompilerManifestRadio;
private TextFieldWithBrowseButton myCustomCompilerManifestPathField;
public AndroidFacetEditorTab(FacetEditorContext context, AndroidFacetConfiguration androidFacetConfiguration) {
final Project project = context.getProject();
@@ -130,6 +133,9 @@ public class AndroidFacetEditorTab extends FacetEditorTab {
myCustomAptSourceDirField.getButton().addActionListener(new MyFolderFieldListener(myCustomAptSourceDirField,
AndroidAptCompiler.getCustomResourceDirForApt(facet),
false));
myCustomCompilerManifestPathField.getButton().addActionListener(new MyFolderFieldListener(myCustomCompilerManifestPathField,
AndroidRootUtil.getManifestFileForCompiler(facet),
true));
myPlatformChooser.addListener(new AndroidPlatformChooserListener() {
@Override
@@ -176,6 +182,15 @@ public class AndroidFacetEditorTab extends FacetEditorTab {
myUseCustomSourceDirectoryRadio.addActionListener(listener);
myUseAptResDirectoryFromPathRadio.addActionListener(listener);
listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
myCustomCompilerManifestPathField.setEnabled(myUseCustomCompilerManifestRadio.isSelected());
}
};
myUseCustomCompilerManifestRadio.addActionListener(listener);
myUseCompilerManifestFromStructureRadio.addActionListener(listener);
myIsLibraryProjectCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
@@ -329,10 +344,17 @@ public class AndroidFacetEditorTab extends FacetEditorTab {
if (myUseCustomSourceDirectoryRadio.isSelected() != myConfiguration.USE_CUSTOM_APK_RESOURCE_FOLDER) {
return true;
}
if (checkRelativePath(myConfiguration.CUSTOM_APK_RESOURCE_FOLDER, myCustomAptSourceDirField.getText())) {
return true;
}
if (myUseCustomCompilerManifestRadio.isSelected() != myConfiguration.USE_CUSTOM_COMPILER_MANIFEST) {
return true;
}
if (checkRelativePath(myConfiguration.CUSTOM_COMPILER_MANIFEST, myCustomCompilerManifestPathField.getText())) {
return true;
}
if (myCopyResourcesFromArtifacts.isSelected() != myConfiguration.COPY_RESOURCES_FROM_ARTIFACTS) {
return true;
}
@@ -495,6 +517,12 @@ public class AndroidFacetEditorTab extends FacetEditorTab {
}
myConfiguration.USE_CUSTOM_APK_RESOURCE_FOLDER = useCustomAptSrc;
boolean useCustomCompilerManifest = myUseCustomCompilerManifestRadio.isSelected();
if (myConfiguration.USE_CUSTOM_COMPILER_MANIFEST != useCustomCompilerManifest) {
runApt = true;
}
myConfiguration.USE_CUSTOM_COMPILER_MANIFEST = useCustomCompilerManifest;
if (myConfiguration.REGENERATE_R_JAVA != myGenerateRJavaWhenChanged.isSelected()) {
runApt = true;
}
@@ -526,6 +554,25 @@ public class AndroidFacetEditorTab extends FacetEditorTab {
myConfiguration.CUSTOM_APK_RESOURCE_FOLDER = relPath != null ? '/' + relPath : "";
}
String absCompilerManifestPath = myCustomCompilerManifestPathField.getText().trim();
if (useCustomCompilerManifest) {
if (absCompilerManifestPath.length() == 0) {
throw new ConfigurationException("AndroidManifest.xml path not specified in \"Compiler\" section");
}
String newCustomCompilerManifestPath = '/' + getAndCheckRelativePath(absCompilerManifestPath, false);
if (!SdkConstants.FN_ANDROID_MANIFEST_XML.equals(AndroidUtils.getSimpleNameByRelativePath(newCustomCompilerManifestPath))) {
throw new ConfigurationException("Manifest file must have name AndroidManifest.xml");
}
if (!newCustomCompilerManifestPath.equals(myConfiguration.CUSTOM_COMPILER_MANIFEST)) {
runApt = true;
}
myConfiguration.CUSTOM_COMPILER_MANIFEST = newCustomCompilerManifestPath;
}
else {
String relPath = toRelativePath(absCompilerManifestPath);
myConfiguration.CUSTOM_COMPILER_MANIFEST = relPath != null ? '/' + relPath : "";
}
final AndroidPlatform platform = myPlatformChooser.getSelectedPlatform();
myConfiguration.setAndroidPlatform(platform);
final AndroidFacet facet = myConfiguration.getFacet();
@@ -657,6 +704,14 @@ public class AndroidFacetEditorTab extends FacetEditorTab {
myCustomAptSourceDirField.setText(aptSourceAbsPath != null ? aptSourceAbsPath : "");
myCustomAptSourceDirField.setEnabled(configuration.USE_CUSTOM_APK_RESOURCE_FOLDER);
myUseCustomCompilerManifestRadio.setSelected(configuration.USE_CUSTOM_COMPILER_MANIFEST);
myUseCompilerManifestFromStructureRadio.setSelected(!configuration.USE_CUSTOM_COMPILER_MANIFEST);
String compilerManifestPath = configuration.CUSTOM_COMPILER_MANIFEST;
String compilerManifestAbsPath = compilerManifestPath.length() > 0 ? toAbsolutePath(compilerManifestPath) : "";
myCustomCompilerManifestPathField.setText(compilerManifestAbsPath != null ? compilerManifestAbsPath : "");
myCustomCompilerManifestPathField.setEnabled(configuration.USE_CUSTOM_COMPILER_MANIFEST);
String apkPath = configuration.APK_PATH;
String apkAbsPath = apkPath.length() > 0 ? toAbsolutePath(apkPath) : "";
myApkPathCombo.getComboBox().getEditor().setItem(apkAbsPath != null ? apkAbsPath : "");
@@ -47,13 +47,18 @@ public class AndroidRootUtil {
public static VirtualFile getManifestFile(@NotNull Module module) {
AndroidFacet facet = AndroidFacet.getInstance(module);
return facet == null ? null : getFileByRelativeModulePath(module, facet.getConfiguration().MANIFEST_FILE_RELATIVE_PATH, true);
}
/*VirtualFile[] files = ModuleRootManager.getInstance(module).getContentRoots();
for (VirtualFile contentRoot : files) {
VirtualFile manifest = contentRoot.findChild(SdkConstants.FN_ANDROID_MANIFEST_XML);
if (manifest != null) return manifest;
}
return null;*/
@Nullable
public static VirtualFile getCustomManifestFileForCompiler(@NotNull AndroidFacet facet) {
return getFileByRelativeModulePath(facet.getModule(), facet.getConfiguration().CUSTOM_COMPILER_MANIFEST, false);
}
@Nullable
public static VirtualFile getManifestFileForCompiler(AndroidFacet facet) {
return facet.getConfiguration().USE_CUSTOM_COMPILER_MANIFEST
? getCustomManifestFileForCompiler(facet)
: getManifestFile(facet.getModule());
}
@Nullable