diff options
20 files changed, 337 insertions, 1696 deletions
diff --git a/anttasks/src/com/android/ant/AaptExecLoopTask.java b/anttasks/src/com/android/ant/AaptExecLoopTask.java index 3e24295..171e781 100644 --- a/anttasks/src/com/android/ant/AaptExecLoopTask.java +++ b/anttasks/src/com/android/ant/AaptExecLoopTask.java @@ -75,6 +75,7 @@ public final class AaptExecLoopTask extends Task { private String mExecutable; private String mCommand; private boolean mForce = true; // true due to legacy reasons + private boolean mDebug = false; private boolean mVerbose = false; private int mVersionCode = 0; private String mManifest; @@ -82,7 +83,6 @@ public final class AaptExecLoopTask extends Task { private String mAssets; private String mAndroidJar; private String mApkFolder; - @Deprecated private String mApkBaseName; private String mApkName; private String mResourceFilter; private String mRFolder; @@ -131,6 +131,10 @@ public final class AaptExecLoopTask extends Task { } } + public void setDebug(boolean value) { + mDebug = value; + } + /** * Sets the value of the "manifest" attribute. * @param manifest the value. @@ -193,28 +197,6 @@ public final class AaptExecLoopTask extends Task { } /** - * Sets the value of the "basename" attribute. - * @param baseName the value. - * @deprecated use {@link #setApkbasename(String)} - */ - @Deprecated - public void setBasename(String baseName) { - System.out.println("WARNNG: Using deprecated 'basename' attribute in AaptExecLoopTask." + - "Use 'resourcefilename' (string) instead."); - mApkBaseName = baseName; - } - - /** - * Sets the value of the "apkbasename" attribute. - * @param apkbaseName the value. - */ - public void setApkbasename(String apkbaseName) { - System.out.println("WARNNG: Using deprecated 'apkbasename' attribute in AaptExecLoopTask." + - "Use 'resourcefilename' (string) instead."); - mApkBaseName = apkbaseName; - } - - /** * Sets the value of the resourcefilename attribute * @param apkName the value */ @@ -333,6 +315,10 @@ public final class AaptExecLoopTask extends Task { task.createArg().setValue("-v"); } + if (mDebug) { + task.createArg().setValue("--debug-mode"); + } + if (generateRClass) { task.createArg().setValue("-m"); } @@ -427,8 +413,6 @@ public final class AaptExecLoopTask extends Task { String filename = null; if (mApkName != null) { filename = mApkName; - } else if (mApkBaseName != null) { - filename = mApkBaseName + ".ap_"; } if (filename != null) { diff --git a/anttasks/src/com/android/ant/ApkBuilderTask.java b/anttasks/src/com/android/ant/ApkBuilderTask.java index d7ffd9c..f7b36bc 100644 --- a/anttasks/src/com/android/ant/ApkBuilderTask.java +++ b/anttasks/src/com/android/ant/ApkBuilderTask.java @@ -22,7 +22,6 @@ import com.android.sdklib.build.DuplicateFileException; import com.android.sdklib.build.SealedApkException; import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.types.Path; @@ -37,11 +36,9 @@ public class ApkBuilderTask extends Task { Pattern.CASE_INSENSITIVE); private String mOutFolder; - @Deprecated private String mBaseName; private String mApkFilepath; private String mResourceFile; private boolean mVerbose = false; - private boolean mSigned = true; private boolean mDebug = false; private boolean mHasCode = true; private String mAbiFilter = null; @@ -64,17 +61,6 @@ public class ApkBuilderTask extends Task { } /** - * Sets the value of the "basename" attribute. - * @param baseName the value. - * @deprecated - */ - public void setBasename(String baseName) { - System.out.println("WARNING: Using deprecated 'basename' attribute in ApkBuilderTask." + - "Use 'apkfilepath' (path) instead."); - mBaseName = baseName; - } - - /** * Sets the full filepath to the apk to generate. * @param filepath */ @@ -99,14 +85,6 @@ public class ApkBuilderTask extends Task { } /** - * Sets the value of the "signed" attribute. - * @param signed the value. - */ - public void setSigned(boolean signed) { - mSigned = signed; - } - - /** * Sets the value of the "debug" attribute. * @param debug the debug mode value. */ @@ -209,26 +187,10 @@ public class ApkBuilderTask extends Task { @Override public void execute() throws BuildException { - Project antProject = getProject(); - - // get the rules revision to figure out how to build the output file. - String rulesRevStr = antProject.getProperty(TaskHelper.PROP_RULES_REV); - int rulesRev = 1; - try { - rulesRev = Integer.parseInt(rulesRevStr); - } catch (NumberFormatException e) { - // this shouldn't happen since setup task is the one setting up every time. - } File outputFile; if (mApkFilepath != null) { outputFile = new File(mApkFilepath); - } else if (rulesRev == 2) { - if (mSigned) { - outputFile = new File(mOutFolder, mBaseName + "-debug-unaligned.apk"); - } else { - outputFile = new File(mOutFolder, mBaseName + "-unsigned.apk"); - } } else { throw new BuildException("missing attribute 'apkFilepath'"); } @@ -246,7 +208,7 @@ public class ApkBuilderTask extends Task { } try { - if (mSigned) { + if (mDebug) { System.out.println(String.format( "Creating %s and signing it with a debug key...", outputFile.getName())); } else { @@ -258,7 +220,7 @@ public class ApkBuilderTask extends Task { outputFile, new File(mOutFolder, mResourceFile), dexFile, - mSigned ? ApkBuilder.getDebugKeystore() : null, + mDebug ? ApkBuilder.getDebugKeystore() : null, mVerbose ? System.out : null); apkBuilder.setDebugMode(mDebug); diff --git a/anttasks/src/com/android/ant/SetupTask.java b/anttasks/src/com/android/ant/SetupTask.java index c66b956..966956f 100644 --- a/anttasks/src/com/android/ant/SetupTask.java +++ b/anttasks/src/com/android/ant/SetupTask.java @@ -64,20 +64,12 @@ import javax.xml.xpath.XPathExpressionException; * */ public final class SetupTask extends ImportTask { - /** current max version of the Ant rules that is supported */ - private final static int ANT_RULES_MAX_VERSION = 3; - - // legacy main rules file. - private final static String RULES_LEGACY_MAIN = "android_rules.xml"; - // legacy test rules file - depends on android_rules.xml - private final static String RULES_LEGACY_TEST = "android_test_rules.xml"; - // main rules file - private final static String RULES_MAIN = "ant_rules_r%1$d.xml"; + private final static String RULES_MAIN = "main_rules.xml"; // test rules file - depends on android_rules.xml - private final static String RULES_TEST = "ant_test_rules_r%1$d.xml"; + private final static String RULES_TEST = "test_rules.xml"; // library rules file. - private final static String RULES_LIBRARY = "ant_lib_rules_r%1$d.xml"; + private final static String RULES_LIBRARY = "lib_rules.xml"; // ant property with the path to the android.jar private final static String PROPERTY_ANDROID_JAR = "android.jar"; @@ -94,24 +86,6 @@ public final class SetupTask extends ImportTask { // ref id to the <path> object containing all the boot classpaths. private final static String REF_CLASSPATH = "android.target.classpath"; - /** - * Compatibility range for the Ant rules. - * The goal is to specify range of the rules that are compatible between them. For instance if - * a range is 10-15 and a platform indicate that it supports rev 12, but the tools have rules - * revision 15, then the rev 15 will be used. - * Compatibility is broken when a new rev of the rules relies on a new option in the external - * tools contained in the platform. - * - * For instance if rules 10 uses a newly introduced aapt option, then it would be considered - * incompatible with 9, and therefore would be the start of a new compatibility range. - * A platform declaring it supports 9 would not be made to use 10, as its aapt version wouldn't - * support it. - */ - private final static int ANT_COMPATIBILITY_RANGES[][] = new int[][] { - new int[] { 1, 1 }, - new int[] { 2, ANT_RULES_MAX_VERSION }, - }; - private boolean mDoImport = true; @Override @@ -191,52 +165,6 @@ public final class SetupTask extends ImportTask { } System.out.println("API level: " + androidTarget.getVersion().getApiString()); - // check that this version of the custom Ant task can build this target - int antBuildVersion = androidTarget.getProperty(SdkConstants.PROP_SDK_ANT_BUILD_REVISION, - 1); - if (antBuildVersion > ANT_RULES_MAX_VERSION) { - antBuildVersion = ANT_RULES_MAX_VERSION; - System.out.println("\n\n\n" - + "***********************************************************\n" - + "WARNING: This platform requires Ant build rules not supported by your SDK Tools.\n" - + "WARNING: Attempting to use older build rules instead, but result may not be correct.\n" - + "WARNING: Please update to the newest revisions of the SDK Tools.\n" - + "***********************************************************\n\n\n"); - } - - if (antBuildVersion < 2) { - // these older rules are obselete, and not versioned, and therefore it's hard - // to maintain compatibility. - - // if the platform itself is obsolete, display a different warning - if (androidTarget.getVersion().getApiLevel() < 3 || - androidTarget.getVersion().getApiLevel() == 5 || - androidTarget.getVersion().getApiLevel() == 6) { - System.out.println("\n\n\n" - + "***********************************************************\n" - + "WARNING: This platform is obsolete and its Ant rules may not work properly.\n" - + "WARNING: It is recommended to develop against a newer version of Android.\n" - + "WARNING: For more information about active versions of Android see:\n" - + "WARNING: http://developer.android.com/resources/dashboard/platform-versions.html\n" - + "***********************************************************\n\n\n"); - } else { - IAndroidTarget baseTarget = - androidTarget.getParent() != null ? androidTarget.getParent() : androidTarget; - System.out.println(String.format("\n\n\n" - + "***********************************************************\n" - + "WARNING: Revision %1$d of %2$s uses obsolete Ant rules which may not work properly.\n" - + "WARNING: It is recommended that you download a newer revision if available.\n" - + "WARNING: For more information about updating your SDK, see:\n" - + "WARNING: http://developer.android.com/sdk/adding-components.html\n" - + "***********************************************************\n\n\n", - baseTarget.getRevision(), baseTarget.getFullName())); - } - } - - // set a property that contains the rules revision. This can be used by other custom - // tasks later. - antProject.setProperty(TaskHelper.PROP_RULES_REV, Integer.toString(antBuildVersion)); - // check if the project is a library boolean isLibrary = false; @@ -249,14 +177,6 @@ public final class SetupTask extends ImportTask { System.out.println("Project Type: Android Library"); } - // do a quick check to make sure the target supports library. - if (isLibrary && - androidTarget.getProperty(SdkConstants.PROP_SDK_SUPPORT_LIBRARY, false) == false) { - throw new BuildException(String.format( - "Project target '%1$s' does not support building libraries.", - androidTarget.getFullName())); - } - // look for referenced libraries. processReferencedLibraries(antProject, androidTarget); @@ -303,23 +223,10 @@ public final class SetupTask extends ImportTask { // Now the import section. This is only executed if the task actually has to import a file. if (mDoImport) { - // check if there's a more recent version of the rules in the tools folder. - int toolsRulesRev = getAntRulesFromTools(antBuildVersion); - - File rulesFolder; - if (toolsRulesRev == -1) { - // no more recent Ant rules from the tools, folder. Find them inside the platform. - // find the folder containing the file to import - int folderID = antBuildVersion == 1 ? IAndroidTarget.TEMPLATES : IAndroidTarget.ANT; - String rulesOSPath = androidTarget.getPath(folderID); - rulesFolder = new File(rulesOSPath); - } else { - // in this case we import the rules from the ant folder in the tools. - rulesFolder = new File(new File(sdkOsPath, SdkConstants.FD_TOOLS), - SdkConstants.FD_ANT); - // the new rev is: - antBuildVersion = toolsRulesRev; - } + // check the ant folder exists in the tools folder of the SDK. + File rulesFolder = new File( + new File(sdkOsPath, SdkConstants.FD_TOOLS), + SdkConstants.FD_ANT); // make sure the file exists. if (rulesFolder.isDirectory() == false) { @@ -327,15 +234,9 @@ public final class SetupTask extends ImportTask { rulesFolder.getAbsolutePath())); } - String importedRulesFileName; - if (antBuildVersion == 1) { - // legacy mode - importedRulesFileName = isTestProject ? RULES_LEGACY_TEST : RULES_LEGACY_MAIN; - } else { - importedRulesFileName = String.format( - isLibrary ? RULES_LIBRARY : isTestProject ? RULES_TEST : RULES_MAIN, - antBuildVersion); - } + // name of the rules files to import based on the type of project + String importedRulesFileName = + isLibrary ? RULES_LIBRARY : isTestProject ? RULES_TEST : RULES_MAIN; // now check the rules file exists. File rules = new File(rulesFolder, importedRulesFileName); @@ -365,21 +266,6 @@ public final class SetupTask extends ImportTask { } /** - * Returns the revision number of a newer but still compatible Ant rules available in the - * tools folder of the SDK, or -1 if none is found. - * @param rulesRev the revision of the rules file on which compatibility is based. - */ - private int getAntRulesFromTools(int rulesRev) { - for (int[] range : ANT_COMPATIBILITY_RANGES) { - if (range[0] <= rulesRev && rulesRev <= range[1]) { - return range[1]; - } - } - - return -1; - } - - /** * Sets the value of the "import" attribute. * @param value the value. */ @@ -486,66 +372,64 @@ public final class SetupTask extends ImportTask { ArrayList<File> libraries = getProjectLibraries(antProject); - final int libCount = libraries.size(); - if (libCount > 0 && androidTarget.getProperty(SdkConstants.PROP_SDK_SUPPORT_LIBRARY, - false) == false) { - throw new BuildException(String.format( - "The build system for this project target (%1$s) does not support libraries", - androidTarget.getFullName())); - } + if (libraries.size() > 0) { + System.out.println("------------------\nOrdered libraries:"); - System.out.println("------------------\nOrdered libraries:"); + for (File library : libraries) { + System.out.println(library.getAbsolutePath()); - for (File library : libraries) { - System.out.println(library.getAbsolutePath()); + // get the source path. default is src but can be overriden by the property + // "source.dir" in build.properties. + PathElement element = sourcePath.createPathElement(); + ProjectProperties prop = ProjectProperties.load(new FolderWrapper(library), + PropertyType.BUILD); - // get the source path. default is src but can be overriden by the property - // "source.dir" in build.properties. - PathElement element = sourcePath.createPathElement(); - ProjectProperties prop = ProjectProperties.load(new FolderWrapper(library), - PropertyType.BUILD); - - String sourceDir = SdkConstants.FD_SOURCES; - if (prop != null) { - String value = prop.getProperty(ProjectProperties.PROPERTY_BUILD_SOURCE_DIR); - if (value != null) { - sourceDir = value; + String sourceDir = SdkConstants.FD_SOURCES; + if (prop != null) { + String value = prop.getProperty(ProjectProperties.PROPERTY_BUILD_SOURCE_DIR); + if (value != null) { + sourceDir = value; + } } - } - String path = library.getAbsolutePath(); + String path = library.getAbsolutePath(); - element.setPath(path + "/" + sourceDir); + element.setPath(path + "/" + sourceDir); - // get the res path. Always $PROJECT/res - element = resPath.createPathElement(); - element.setPath(path + "/" + SdkConstants.FD_RESOURCES); + // get the res path. Always $PROJECT/res + element = resPath.createPathElement(); + element.setPath(path + "/" + SdkConstants.FD_RESOURCES); - // get the libs path. Always $PROJECT/libs - element = libsPath.createPathElement(); - element.setPath(path + "/" + SdkConstants.FD_NATIVE_LIBS); + // get the libs path. Always $PROJECT/libs + element = libsPath.createPathElement(); + element.setPath(path + "/" + SdkConstants.FD_NATIVE_LIBS); - // get the jars from it too - File libsFolder = new File(library, SdkConstants.FD_NATIVE_LIBS); - File[] jarFiles = libsFolder.listFiles(filter); - if (jarFiles != null) { - for (File jarFile : jarFiles) { - element = jarsPath.createPathElement(); - element.setPath(jarFile.getAbsolutePath()); + // get the jars from it too + File libsFolder = new File(library, SdkConstants.FD_NATIVE_LIBS); + File[] jarFiles = libsFolder.listFiles(filter); + if (jarFiles != null) { + for (File jarFile : jarFiles) { + element = jarsPath.createPathElement(); + element.setPath(jarFile.getAbsolutePath()); + } } - } - // get the package from the manifest. - FileWrapper manifest = new FileWrapper(library, SdkConstants.FN_ANDROID_MANIFEST_XML); - try { - String value = AndroidManifest.getPackage(manifest); - if (value != null) { // aapt will complain if it's missing. - sb.append(';'); - sb.append(value); + // get the package from the manifest. + FileWrapper manifest = new FileWrapper(library, + SdkConstants.FN_ANDROID_MANIFEST_XML); + + try { + String value = AndroidManifest.getPackage(manifest); + if (value != null) { // aapt will complain if it's missing. + sb.append(';'); + sb.append(value); + } + } catch (Exception e) { + throw new BuildException(e); } - } catch (Exception e) { - throw new BuildException(e); } + } else { + System.out.println("No library dependencies.\n"); } System.out.println("------------------\n"); diff --git a/anttasks/src/com/android/ant/TaskHelper.java b/anttasks/src/com/android/ant/TaskHelper.java index e29175b..8c50e49 100644 --- a/anttasks/src/com/android/ant/TaskHelper.java +++ b/anttasks/src/com/android/ant/TaskHelper.java @@ -31,8 +31,6 @@ import java.util.Properties; final class TaskHelper { - public final static String PROP_RULES_REV = "android.ant.rules.revision"; - static File getSdkLocation(Project antProject) { // get the SDK location String sdkOsPath = antProject.getProperty(ProjectProperties.PROPERTY_SDK); diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationComposite.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationComposite.java index ef426df..f5ad935 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationComposite.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationComposite.java @@ -823,7 +823,7 @@ public class ConfigurationComposite extends Composite { if (configIndex != -1) { String configName = mDeviceConfigCombo.getItem(configIndex); FolderConfiguration currentConfig = mState.device.getFolderConfigByName(configName); - if (mEditedConfig.isMatchFor(currentConfig)) { + if (currentConfig != null && mEditedConfig.isMatchFor(currentConfig)) { currentConfigIsCompatible = true; // current config is compatible if (needBestMatch == false || isCurrentFileBestMatchFor(currentConfig)) { needConfigChange = false; diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java index b22999e..fbac3f0 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LayoutCanvas.java @@ -19,6 +19,7 @@ package com.android.ide.eclipse.adt.internal.editors.layout.gle2; import com.android.ide.eclipse.adt.AdtPlugin; import com.android.ide.eclipse.adt.editors.layout.gscripts.IDragElement; import com.android.ide.eclipse.adt.editors.layout.gscripts.INode; +import com.android.ide.eclipse.adt.editors.layout.gscripts.IViewRule; import com.android.ide.eclipse.adt.editors.layout.gscripts.MenuAction; import com.android.ide.eclipse.adt.editors.layout.gscripts.Point; import com.android.ide.eclipse.adt.editors.layout.gscripts.Rect; @@ -1780,8 +1781,20 @@ class LayoutCanvas extends Canvas implements ISelectionProvider { action.setDisabledImageDescriptor(wa.getDisabledImageDescriptor()); } + /** + * Creates the context menu for the canvas. This is called once from the canvas' constructor. + * <p/> + * The menu has a static part with actions that are always available such as + * copy, cut, paste and show in > explorer. This is created by + * {@link #setupStaticMenuActions(IMenuManager)}. + * <p/> + * There's also a dynamic part that is populated by the groovy rules of the + * selected elements. This part is created by {@link #populateDynamicContextMenu(MenuManager)} + * when the {@link MenuManager}'s <code>menuAboutToShow</code> method is invoked. + */ private void createContextMenu() { - // Create the menu manager and fill it with the static actions. + + // This manager is the root of the context menu. mMenuManager = new MenuManager() { @Override public boolean isDynamic() { @@ -1789,44 +1802,60 @@ class LayoutCanvas extends Canvas implements ISelectionProvider { } }; - createMenuAction(mMenuManager); + // Fill the menu manager with the static actions. + setupStaticMenuActions(mMenuManager); + setupDynamicMenuActions(mMenuManager); Menu menu = mMenuManager.createContextMenu(this); setMenu(menu); + } + /** + * Setups the menu manager to receive dynamic menu contributions from the {@link IViewRule}s + * when it's about to be shown. + * <p/> + * Implementation detail: this method is package protected as it is also used by + * {@link OutlinePage2} to create the exact same dynamic context menu. This means that this + * methods and all its descendant must <em>not</em> access the local {@link #mMenuManager} + * variable. + * + * @param menuManager The menu manager to modify. + */ + /*package*/ void setupDynamicMenuActions(final MenuManager menuManager) { // Remember how many static actions we have. Then each time the menu is // shown, find dynamic contributions based on the current selection and insert // them at the beginning of the menu. - final int numStaticActions = mMenuManager.getSize(); - mMenuManager.addMenuListener(new IMenuListener() { + final int numStaticActions = menuManager.getSize(); + menuManager.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { // Remove any previous dynamic contributions to keep only the // default static items. - int n = mMenuManager.getSize() - numStaticActions; + int n = menuManager.getSize() - numStaticActions; if (n > 0) { - IContributionItem[] items = mMenuManager.getItems(); + IContributionItem[] items = menuManager.getItems(); for (int i = 0; i < n; i++) { - mMenuManager.remove(items[i]); + menuManager.remove(items[i]); } } - populateDynamicContextMenu(); + // Now add all the dynamic menu actions depending on the current selection. + populateDynamicContextMenu(menuManager); } }); } /** - * Invoked by the constructor to create our *static* context menu. + * Invoked by {@link #createContextMenu()} to create our *static* context menu once. * <p/> * The content of the menu itself does not change. However the state of the * various items is controlled by their associated actions. * <p/> - * For cut/copy/paste/delete/select-all, we explicitely reuse the actions + * For cut/copy/paste/delete/select-all, we explicitly reuse the actions * created by {@link #setupGlobalActionHandlers()}, so this method must be * invoked after that one. */ - private void createMenuAction(IMenuManager manager) { + private void setupStaticMenuActions(IMenuManager manager) { manager.removeAll(); manager.add(mCutAction); @@ -1840,24 +1869,115 @@ class LayoutCanvas extends Canvas implements ISelectionProvider { manager.add(new Separator()); + // Create a "Show In" sub-menu and automatically populate it using standard + // actions contributed by the workbench. String showInLabel = IDEWorkbenchMessages.Workbench_showIn; MenuManager showInSubMenu= new MenuManager(showInLabel); - showInSubMenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create( - mLayoutEditor.getSite().getWorkbenchWindow())); + showInSubMenu.add( + ContributionItemFactory.VIEWS_SHOW_IN.create( + mLayoutEditor.getSite().getWorkbenchWindow())); manager.add(showInSubMenu); } - - private void populateDynamicContextMenu() { - // Collect actions for current selection - + /** + * This is invoked by <code>menuAboutToShow</code> on {@link #mMenuManager}. + * All previous dynamic menu actions have been removed and this method can now insert + * any new actions that depend on the current selection. + * @param menuManager + */ + private void populateDynamicContextMenu(MenuManager menuManager) { // Map action-id => action object (one per selected view that defined it) final TreeMap<String /*id*/, ArrayList<MenuAction>> actionsMap = new TreeMap<String, ArrayList<MenuAction>>(); // Map group-id => actions to place in this group. - TreeMap<String /*id*/, MenuAction.Group> groupMap = new TreeMap<String, MenuAction.Group>(); + TreeMap<String /*id*/, MenuAction.Group> groupsMap = new TreeMap<String, MenuAction.Group>(); + + int maxMenuSelection = collectDynamicMenuActions(actionsMap, groupsMap); + + // Now create the actual menu contributions + String endId = menuManager.getItems()[0].getId(); + + Separator sep = new Separator(); + sep.setId("-dyn-gle-sep"); //$NON-NLS-1$ + menuManager.insertBefore(endId, sep); + endId = sep.getId(); + + // First create the groups + Map<String, MenuManager> menuGroups = new HashMap<String, MenuManager>(); + for (MenuAction.Group group : groupsMap.values()) { + String id = group.getId(); + MenuManager submenu = new MenuManager(group.getTitle(), id); + menuGroups.put(id, submenu); + menuManager.insertBefore(endId, submenu); + endId = id; + } + + boolean needGroupSep = !menuGroups.isEmpty(); + + // Now fill in the actions + for (ArrayList<MenuAction> actions : actionsMap.values()) { + // Filter actions... if we have a multiple selection, only accept actions + // which are common to *all* the selection which actually returned at least + // one menu action. + if (actions == null || + actions.isEmpty() || + actions.size() != maxMenuSelection) { + continue; + } + if (!(actions.get(0) instanceof MenuAction.Action)) { + continue; + } + + final MenuAction.Action action = (MenuAction.Action) actions.get(0); + + IContributionItem contrib = null; + + if (action instanceof MenuAction.Toggle) { + contrib = createDynamicMenuToggle((MenuAction.Toggle) action, actionsMap); + + } else if (action instanceof MenuAction.Choices) { + Map<String, String> choiceMap = ((MenuAction.Choices) action).getChoices(); + if (choiceMap != null && !choiceMap.isEmpty()) { + contrib = createDynamicChoices( + (MenuAction.Choices)action, choiceMap, actionsMap); + } + } + + if (contrib != null) { + MenuManager groupMenu = menuGroups.get(action.getGroupId()); + if (groupMenu != null) { + groupMenu.add(contrib); + } else { + if (needGroupSep) { + needGroupSep = false; + + sep = new Separator(); + sep.setId("-dyn-gle-sep2"); //$NON-NLS-1$ + menuManager.insertBefore(endId, sep); + endId = sep.getId(); + } + menuManager.insertBefore(endId, contrib); + } + } + } + } + + /** + * Collects all the {@link MenuAction} contributed by the {@link IViewRule} of the + * current selection. + * This is the first step of {@link #populateDynamicContextMenu(MenuManager)}. + * + * @param outActionsMap Map that collects all the contributed actions. + * @param outGroupsMap Map that collects all the contributed groups (sub-menus). + * @return The max number of selected items that contributed the same action ID. + * This is used later to filter on multiple selections so that we can display only + * actions that are common to all selected items that contributed at least one action. + */ + private int collectDynamicMenuActions( + final TreeMap<String, ArrayList<MenuAction>> outActionsMap, + final TreeMap<String, MenuAction.Group> outGroupsMap) { int maxMenuSelection = 0; for (CanvasSelection selection : mSelections) { List<MenuAction> viewActions = null; @@ -1874,29 +1994,29 @@ class LayoutCanvas extends Canvas implements ISelectionProvider { boolean foundAction = false; for (MenuAction action : viewActions) { if (action.getId() == null || action.getTitle() == null) { - // TODO invalid action. Log verbose error. + // TODO Log verbose error for invalid action. continue; } String id = action.getId(); if (action instanceof MenuAction.Group) { - if (!groupMap.containsKey(id)) { - groupMap.put(id, (MenuAction.Group) action); + if (!outGroupsMap.containsKey(id)) { + outGroupsMap.put(id, (MenuAction.Group) action); } continue; } - ArrayList<MenuAction> actions = actionsMap.get(id); + ArrayList<MenuAction> actions = outActionsMap.get(id); if (actions == null) { actions = new ArrayList<MenuAction>(); - actionsMap.put(id, actions); + outActionsMap.put(id, actions); } // All the actions for the same id should have be equal if (!actions.isEmpty()) { if (action.equals(actions.get(0))) { - // TODO invalid type mismatch. Log verbose error. + // TODO Log verbose error for invalid type mismatch. continue; } } @@ -1909,152 +2029,117 @@ class LayoutCanvas extends Canvas implements ISelectionProvider { maxMenuSelection++; } } + return maxMenuSelection; + } - // Now create the actual menu contributions - String endId = mMenuManager.getItems()[0].getId(); + /** + * Invoked by {@link #populateDynamicContextMenu(MenuManager)} to create a new menu item + * for a {@link MenuAction.Toggle}. + * <p/> + * Toggles are represented by a checked menu item. + * + * @param action The toggle action to convert to a menu item. + * @param actionsMap Map of all contributed actions. + * @return a new {@link IContributionItem} to add to the context menu + */ + private IContributionItem createDynamicMenuToggle( + final MenuAction.Toggle action, + final TreeMap<String, ArrayList<MenuAction>> actionsMap) { + final boolean isChecked = action.isChecked(); + Action a = new Action(action.getTitle(), IAction.AS_CHECK_BOX) { + @Override + public void run() { + // Invoke the closures of all the actions using the same action-id + for (MenuAction a2 : actionsMap.get(action.getId())) { + if (a2 instanceof MenuAction.Action) { + Closure c = ((MenuAction.Action) a2).getAction(); + if (c != null) { + mRulesEngine.callClosure( + ((MenuAction.Action) a2).getAction(), + // Closure parameters are action, valueId, newValue + action, + null, // no valueId for a toggle + !isChecked); + } + } + } + } + }; + a.setId(action.getId()); + a.setChecked(isChecked); - Separator sep = new Separator(); - sep.setId("-dyn-gle-sep"); //$NON-NLS-1$ - mMenuManager.insertBefore(endId, sep); - endId = sep.getId(); + return new ActionContributionItem(a); + } - // First create the groups - Map<String, MenuManager> menuGroups = new HashMap<String, MenuManager>(); - for (MenuAction.Group group : groupMap.values()) { - String id = group.getId(); - MenuManager submenu = new MenuManager(group.getTitle(), id); - menuGroups.put(id, submenu); - mMenuManager.insertBefore(endId, submenu); - endId = id; + /** + * Invoked by {@link #populateDynamicContextMenu(MenuManager)} to create a new menu item + * for a {@link MenuAction.Choices}. + * <p/> + * Multiple-choices are represented by a sub-menu containing checked items. + * + * @param action The choices action to convert to a menu item. + * @param actionsMap Map of all contributed actions. + * @return a new {@link IContributionItem} to add to the context menu + */ + private IContributionItem createDynamicChoices( + final MenuAction.Choices action, + Map<String, String> choiceMap, + final TreeMap<String, ArrayList<MenuAction>> actionsMap) { + MenuManager submenu = new MenuManager(action.getTitle(), action.getId()); + + // Convert to a tree map as needed so that keys be naturally ordered. + if (!(choiceMap instanceof TreeMap<?, ?>)) { + choiceMap = new TreeMap<String, String>(choiceMap); } - boolean needGroupSep = !menuGroups.isEmpty(); + String current = action.getCurrent(); + Set<String> currents = null; + if (current.indexOf(MenuAction.Choices.CHOICE_SEP) >= 0) { + currents = new HashSet<String>( + Arrays.asList(current.split( + Pattern.quote(MenuAction.Choices.CHOICE_SEP)))); + current = null; + } - // Now fill in the actions - for (ArrayList<MenuAction> actions : actionsMap.values()) { - // Filter actions... if we have a multiple selection, only accept actions - // which are common to *all* the selection which actually returned at least - // one menu action. - if (actions == null || - actions.isEmpty() || - actions.size() != maxMenuSelection) { + for (Entry<String, String> entry : choiceMap.entrySet() ) { + final String key = entry.getKey(); + String title = entry.getValue(); + + if (key == null || title == null) { continue; } - if (!(actions.get(0) instanceof MenuAction.Action)) { + if (MenuAction.Choices.SEPARATOR.equals(title)) { + submenu.add(new Separator()); continue; } - final MenuAction.Action action = (MenuAction.Action) actions.get(0); - - IContributionItem contrib = null; - - if (action instanceof MenuAction.Toggle) { - - final boolean isChecked = ((MenuAction.Toggle) action).isChecked(); - Action a = new Action(action.getTitle(), IAction.AS_CHECK_BOX) { - @Override - public void run() { - // Invoke the closures of all the actions using the same action-id - for (MenuAction a2 : actionsMap.get(action.getId())) { - if (a2 instanceof MenuAction.Action) { - Closure c = ((MenuAction.Action) a2).getAction(); - if (c != null) { - mRulesEngine.callClosure( - ((MenuAction.Action) a2).getAction(), - // Closure parameters are action, valueId, newValue - action, - null, // no valueId for a toggle - !isChecked); - } - } - } - } - }; - a.setId(action.getId()); - a.setChecked(isChecked); - - contrib = new ActionContributionItem(a); - - } else if (action instanceof MenuAction.Choices) { - - Map<String, String> choiceMap = ((MenuAction.Choices) action).getChoices(); - if (choiceMap != null && !choiceMap.isEmpty()) { - MenuManager submenu = new MenuManager(action.getTitle(), action.getId()); - - // Convert to a tree map as needed so that keys be naturally ordered. - if (!(choiceMap instanceof TreeMap<?, ?>)) { - choiceMap = new TreeMap<String, String>(choiceMap); - } + final boolean isChecked = + (currents != null && currents.contains(key)) || + key.equals(current); - String current = ((MenuAction.Choices) action).getCurrent(); - Set<String> currents = null; - if (current.indexOf(MenuAction.Choices.CHOICE_SEP) >= 0) { - currents = new HashSet<String>( - Arrays.asList(current.split( - Pattern.quote(MenuAction.Choices.CHOICE_SEP)))); - current = null; - } - - for (Entry<String, String> entry : choiceMap.entrySet() ) { - final String key = entry.getKey(); - String title = entry.getValue(); - - if (key == null || title == null) { - continue; - } - - if (MenuAction.Choices.SEPARATOR.equals(title)) { - submenu.add(new Separator()); - continue; + Action a = new Action(title, IAction.AS_CHECK_BOX) { + @Override + public void run() { + // Invoke the closures of all the actions using the same action-id + for (MenuAction a2 : actionsMap.get(action.getId())) { + if (a2 instanceof MenuAction.Action) { + mRulesEngine.callClosure( + ((MenuAction.Action) a2).getAction(), + // Closure parameters are action, valueId, newValue + action, + key, + !isChecked); } - - final boolean isChecked = - (currents != null && currents.contains(key)) || - key.equals(current); - - Action a = new Action(title, IAction.AS_CHECK_BOX) { - @Override - public void run() { - // Invoke the closures of all the actions using the same action-id - for (MenuAction a2 : actionsMap.get(action.getId())) { - if (a2 instanceof MenuAction.Action) { - mRulesEngine.callClosure( - ((MenuAction.Action) a2).getAction(), - // Closure parameters are action, valueId, newValue - action, - key, - !isChecked); - } - } - } - }; - a.setId(String.format("%s_%s", action.getId(), key)); //$NON-NLS-1$ - a.setChecked(isChecked); - submenu.add(a); } - - contrib = submenu; } - } - - if (contrib != null) { - MenuManager groupMenu = menuGroups.get(action.getGroupId()); - if (groupMenu != null) { - groupMenu.add(contrib); - } else { - if (needGroupSep) { - needGroupSep = false; - - sep = new Separator(); - sep.setId("-dyn-gle-sep2"); //$NON-NLS-1$ - mMenuManager.insertBefore(endId, sep); - endId = sep.getId(); - } - mMenuManager.insertBefore(endId, contrib); - } - } + }; + a.setId(String.format("%s_%s", action.getId(), key)); //$NON-NLS-1$ + a.setChecked(isChecked); + submenu.add(a); } + + return submenu; } /** diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/OutlinePage2.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/OutlinePage2.java index ec945b6..01decfd 100755 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/OutlinePage2.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/OutlinePage2.java @@ -417,12 +417,10 @@ public class OutlinePage2 extends ContentOutlinePage mMenuManager.add(new DelegateAction(prefix + ActionFactory.DELETE.getId())); mMenuManager.add(new DelegateAction(prefix + ActionFactory.SELECT_ALL.getId())); - getControl().setMenu(mMenuManager.createContextMenu(getControl())); - mMenuManager.addMenuListener(new IMenuListener() { public void menuAboutToShow(IMenuManager manager) { // Update all actions to match their LayoutCanvas counterparts - for (IContributionItem contrib : mMenuManager.getItems()) { + for (IContributionItem contrib : manager.getItems()) { if (contrib instanceof ActionContributionItem) { IAction action = ((ActionContributionItem) contrib).getAction(); if (action instanceof DelegateAction) { @@ -432,6 +430,10 @@ public class OutlinePage2 extends ContentOutlinePage } } }); + + mGraphicalEditorPart.getCanvasControl().setupDynamicMenuActions(mMenuManager); + + getControl().setMenu(mMenuManager.createContextMenu(getControl())); } /** @@ -445,6 +447,7 @@ public class OutlinePage2 extends ContentOutlinePage public DelegateAction(String canvasActionId) { super(canvasActionId); + setId(canvasActionId); mCanvasActionId = canvasActionId; } diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/AndroidClasspathContainerInitializer.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/AndroidClasspathContainerInitializer.java index 9c5fd1e..402e24a 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/AndroidClasspathContainerInitializer.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/AndroidClasspathContainerInitializer.java @@ -22,7 +22,6 @@ import com.android.ide.eclipse.adt.internal.sdk.LoadStatus; import com.android.ide.eclipse.adt.internal.sdk.ProjectState; import com.android.ide.eclipse.adt.internal.sdk.Sdk; import com.android.sdklib.IAndroidTarget; -import com.android.sdklib.SdkConstants; import com.android.sdklib.IAndroidTarget.IOptionalLibrary; import org.eclipse.core.resources.IMarker; @@ -179,16 +178,6 @@ public class AndroidClasspathContainerInitializer extends ClasspathContainerInit // first make sure the target has loaded its data Sdk.getCurrent().checkAndLoadTargetData(target, null /*project*/); - // now do a quick check to make sure the project's target is compatible - // with library (if applicable). - if (state.hasLibraries() && - target.getProperty( - SdkConstants.PROP_SDK_SUPPORT_LIBRARY, false) == false) { - AdtPlugin.printErrorToConsole(iProject, String.format( - "Target '%1$s' does not support building project with libraries.", - target.getFullName())); - } - String targetName = target.getClasspathName(); return new AndroidClasspathContainer( diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/FolderConfiguration.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/FolderConfiguration.java index aa0dc25..3a37634 100644 --- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/FolderConfiguration.java +++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/resources/configurations/FolderConfiguration.java @@ -518,6 +518,10 @@ public final class FolderConfiguration implements Comparable<FolderConfiguration * @return true if the configuration matches. */ public boolean isMatchFor(FolderConfiguration referenceConfig) { + if (referenceConfig == null) { + return false; + } + for (int i = 0 ; i < INDEX_COUNT ; i++) { ResourceQualifier testQualifier = mQualifiers[i]; ResourceQualifier referenceQualifier = referenceConfig.mQualifiers[i]; diff --git a/files/ant/ant_lib_rules_r2.xml b/files/ant/ant_lib_rules_r2.xml deleted file mode 100644 index c207308..0000000 --- a/files/ant/ant_lib_rules_r2.xml +++ /dev/null @@ -1,141 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project name="android_rules" default="debug"> - - <!-- - This rules file is meant to be imported by the custom Ant task: - com.android.ant.SetupTask - - The following properties are put in place by the importing task: - android.jar, android.aidl, aapt, aidl, and dx - - Additionnaly, the task sets up the following classpath reference: - android.target.classpath - This is used by the compiler task as the boot classpath. - --> - - <!-- Custom tasks --> - <taskdef name="aaptexec" - classname="com.android.ant.AaptExecLoopTask" - classpathref="android.antlibs" /> - - <taskdef name="xpath" - classname="com.android.ant.XPathTask" - classpathref="android.antlibs" /> - - <!-- Properties --> - - <!-- Tells adb which device to target. You can change this from the command line - by invoking "ant -Dadb.device.arg=-d" for device "ant -Dadb.device.arg=-e" for - the emulator. --> - <property name="adb.device.arg" value="" /> - - <property name="android.tools.dir" location="${sdk.dir}/tools" /> - <!-- Name of the application package extracted from manifest file --> - <xpath input="AndroidManifest.xml" expression="/manifest/@package" - output="manifest.package" /> - - <!-- Input directories --> - <property name="source.dir" value="src" /> - <property name="source.absolute.dir" location="${source.dir}" /> - <property name="gen.dir" value="gen" /> - <property name="gen.absolute.dir" location="${gen.dir}" /> - <property name="resource.dir" value="res" /> - <property name="resource.absolute.dir" location="${resource.dir}" /> - <property name="asset.dir" value="assets" /> - <property name="asset.absolute.dir" location="${asset.dir}" /> - - <!-- Directory for the third party java libraries --> - <property name="external.libs.dir" value="libs" /> - <property name="external.libs.absolute.dir" location="${external.libs.dir}" /> - - <!-- Directory for the native libraries --> - <property name="native.libs.dir" value="libs" /> - <property name="native.libs.absolute.dir" location="${native.libs.dir}" /> - - <!-- Output directories --> - <property name="out.dir" value="bin" /> - <property name="out.absolute.dir" location="${out.dir}" /> - <property name="out.classes.dir" value="${out.absolute.dir}/classes" /> - <property name="out.classes.absolute.dir" location="${out.classes.dir}" /> - - <!-- Verbosity --> - <property name="verbose" value="false" /> - <!-- This is needed by emma as it uses multilevel verbosity instead of simple 'true' or 'false' - The property 'verbosity' is not user configurable and depends exclusively on 'verbose' - value.--> - <condition property="verbosity" value="verbose" else="quiet"> - <istrue value="${verbose}" /> - </condition> - - <!-- Tools --> - <condition property="exe" value=".exe" else=""><os family="windows" /></condition> - - <!-- Emma configuration --> - <property name="emma.dir" value="${sdk.dir}/tools/lib" /> - <path id="emma.lib"> - <pathelement location="${emma.dir}/emma.jar" /> - <pathelement location="${emma.dir}/emma_ant.jar" /> - </path> - <taskdef resource="emma_ant.properties" classpathref="emma.lib" /> - <!-- End of emma configuration --> - - <!-- Rules --> - - <!-- Creates the output directories if they don't exist yet. --> - <target name="-dirs"> - <echo>Creating output directories if needed...</echo> - <mkdir dir="${resource.absolute.dir}" /> - <mkdir dir="${external.libs.absolute.dir}" /> - <mkdir dir="${gen.absolute.dir}" /> - <mkdir dir="${out.absolute.dir}" /> - <mkdir dir="${out.classes.absolute.dir}" /> - </target> - - <!-- Generates the R.java file for this project's resources. --> - <target name="-resource-src" depends="-dirs"> - <echo>Generating R.java / Manifest.java from the resources...</echo> - <aaptexec executable="${aapt}" - command="package" - verbose="${verbose}" - manifest="AndroidManifest.xml" - androidjar="${android.jar}" - rfolder="${gen.absolute.dir}"> - <res path="${resource.absolute.dir}" /> - </aaptexec> - </target> - - <!-- Compiles this project's .java files into .class files. --> - <target name="compile" depends="-resource-src" - description="Compiles project's .java files into .class files"> - <!-- If android rules are used for a test project, its classpath should include - tested project's location --> - <condition property="extensible.classpath" - value="${tested.project.absolute.dir}/bin/classes" else="."> - <isset property="tested.project.absolute.dir" /> - </condition> - <javac encoding="ascii" target="1.5" debug="true" extdirs="" - destdir="${out.classes.absolute.dir}" - bootclasspathref="android.target.classpath" - verbose="${verbose}" classpath="${extensible.classpath}"> - <src path="${source.absolute.dir}" /> - <src path="${gen.absolute.dir}" /> - <classpath> - <fileset dir="${external.libs.absolute.dir}" includes="*.jar" /> - </classpath> - </javac> - </target> - - <target name="clean" description="Removes output files created by other targets."> - <delete dir="${out.absolute.dir}" verbose="${verbose}" /> - <delete dir="${gen.absolute.dir}" verbose="${verbose}" /> - </target> - - <target name="help"> - <!-- displays starts at col 13 - |13 80| --> - <echo>Android Ant Build. Available targets:</echo> - <echo> help: Displays this help.</echo> - <echo> clean: Removes output files created by other targets.</echo> - <echo> compile: Compiles project's .java files into .class files.</echo> - </target> -</project> diff --git a/files/ant/ant_rules_r1.xml b/files/ant/ant_rules_r1.xml deleted file mode 100644 index 9ff30f3..0000000 --- a/files/ant/ant_rules_r1.xml +++ /dev/null @@ -1,452 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project name="android_rules" default="debug"> - - <!-- - This rules file is meant to be imported by the custom Ant task: - com.android.ant.AndroidInitTask - - The following properties are put in place by the importing task: - android.jar, android.aidl, aapt, aidl, and dx - - Additionnaly, the task sets up the following classpath reference: - android.target.classpath - This is used by the compiler task as the boot classpath. - --> - - <!-- Custom tasks --> - <taskdef name="aaptexec" - classname="com.android.ant.AaptExecLoopTask" - classpathref="android.antlibs" /> - - <taskdef name="apkbuilder" - classname="com.android.ant.ApkBuilderTask" - classpathref="android.antlibs" /> - - <taskdef name="xpath" - classname="com.android.ant.XPathTask" - classpathref="android.antlibs" /> - - <!-- Properties --> - - <!-- Tells adb which device to target. You can change this from the command line - by invoking "ant -Dadb.device.arg=-d" for device "ant -Dadb.device.arg=-e" for - the emulator. --> - <property name="adb.device.arg" value="" /> - - <property name="android.tools.dir" location="${sdk.dir}/tools" /> - <!-- Name of the application package extracted from manifest file --> - <xpath input="AndroidManifest.xml" expression="/manifest/@package" - output="manifest.package" /> - - <!-- Input directories --> - <property name="source.dir" value="src" /> - <property name="source.absolute.dir" location="${source.dir}" /> - <property name="gen.dir" value="gen" /> - <property name="gen.absolute.dir" location="${gen.dir}" /> - <property name="resource.dir" value="res" /> - <property name="resource.absolute.dir" location="${resource.dir}" /> - <property name="asset.dir" value="assets" /> - <property name="asset.absolute.dir" location="${asset.dir}" /> - - <!-- Directory for the third party java libraries --> - <property name="external.libs.dir" value="libs" /> - <property name="external.libs.absolute.dir" location="${external.libs.dir}" /> - - <!-- Directory for the native libraries --> - <property name="native.libs.dir" value="libs" /> - <property name="native.libs.absolute.dir" location="${native.libs.dir}" /> - - <!-- Output directories --> - <property name="out.dir" value="bin" /> - <property name="out.absolute.dir" location="${out.dir}" /> - <property name="out.classes.dir" value="${out.absolute.dir}/classes" /> - <property name="out.classes.absolute.dir" location="${out.classes.dir}" /> - - <!-- Intermediate files --> - <property name="dex.file.name" value="classes.dex" /> - <property name="intermediate.dex.file" location="${out.absolute.dir}/${dex.file.name}" /> - - <!-- The final package file to generate --> - <property name="out.debug.unaligned.package" - location="${out.absolute.dir}/${ant.project.name}-debug-unaligned.apk" /> - <property name="out.debug.package" - location="${out.absolute.dir}/${ant.project.name}-debug.apk" /> - <property name="out.unsigned.package" - location="${out.absolute.dir}/${ant.project.name}-unsigned.apk" /> - <property name="out.unaligned.package" - location="${out.absolute.dir}/${ant.project.name}-unaligned.apk" /> - <property name="out.release.package" - location="${out.absolute.dir}/${ant.project.name}-release.apk" /> - - <!-- Verbosity --> - <property name="verbose" value="false" /> - <!-- This is needed by emma as it uses multilevel verbosity instead of simple 'true' or 'false' - The property 'verbosity' is not user configurable and depends exclusively on 'verbose' - value.--> - <condition property="verbosity" value="verbose" else="quiet"> - <istrue value="${verbose}" /> - </condition> - <!-- This is needed to switch verbosity of zipalign and aapt. Depends exclusively on 'verbose' - --> - <condition property="v.option" value="-v" else=""> - <istrue value="${verbose}" /> - </condition> - <!-- This is needed to switch verbosity of dx. Depends exclusively on 'verbose' --> - <condition property="verbose.option" value="--verbose" else=""> - <istrue value="${verbose}" /> - </condition> - - <!-- Tools --> - <condition property="exe" value=".exe" else=""><os family="windows" /></condition> - <property name="adb" location="${android.tools.dir}/adb${exe}" /> - <property name="zipalign" location="${android.tools.dir}/zipalign${exe}" /> - - <!-- Emma configuration --> - <property name="emma.dir" value="${sdk.dir}/tools/lib" /> - <path id="emma.lib"> - <pathelement location="${emma.dir}/emma.jar" /> - <pathelement location="${emma.dir}/emma_ant.jar" /> - </path> - <taskdef resource="emma_ant.properties" classpathref="emma.lib" /> - <!-- End of emma configuration --> - - <!-- Macros --> - - <!-- Configurable macro, which allows to pass as parameters output directory, - output dex filename and external libraries to dex (optional) --> - <macrodef name="dex-helper"> - <element name="external-libs" optional="yes" /> - <element name="extra-parameters" optional="yes" /> - <sequential> - <echo>Converting compiled files and external libraries into ${intermediate.dex.file}... - </echo> - <apply executable="${dx}" failonerror="true" parallel="true"> - <arg value="--dex" /> - <arg value="--output=${intermediate.dex.file}" /> - <extra-parameters /> - <arg line="${verbose.option}" /> - <arg path="${out.classes.absolute.dir}" /> - <fileset dir="${external.libs.absolute.dir}" includes="*.jar" /> - <external-libs /> - </apply> - </sequential> - </macrodef> - - <!-- This is macro that enable passing variable list of external jar files to ApkBuilder - Example of use: - <package-helper> - <extra-jars> - <jarfolder path="my_jars" /> - <jarfile path="foo/bar.jar" /> - <jarfolder path="your_jars" /> - </extra-jars> - </package-helper> --> - <macrodef name="package-helper"> - <attribute name="sign.package" /> - <element name="extra-jars" optional="yes" /> - <sequential> - <apkbuilder - outfolder="${out.absolute.dir}" - basename="${ant.project.name}" - signed="@{sign.package}" - verbose="${verbose}"> - <file path="${intermediate.dex.file}" /> - <sourcefolder path="${source.absolute.dir}" /> - <nativefolder path="${native.libs.absolute.dir}" /> - <jarfolder path="${external.libs.absolute.dir}" /> - <extra-jars/> - </apkbuilder> - </sequential> - </macrodef> - - <!-- This is macro which zipaligns in.package and outputs it to out.package. Used by targets - debug, -debug-with-emma and release.--> - <macrodef name="zipalign-helper"> - <attribute name="in.package" /> - <attribute name="out.package" /> - <sequential> - <echo>Running zip align on final apk...</echo> - <exec executable="${zipalign}" failonerror="true"> - <arg line="${v.option}" /> - <arg value="-f" /> - <arg value="4" /> - <arg path="@{in.package}" /> - <arg path="@{out.package}" /> - </exec> - </sequential> - </macrodef> - - <!-- This is macro used only for sharing code among two targets, -install and - -install-with-emma which do exactly the same but differ in dependencies --> - <macrodef name="install-helper"> - <sequential> - <echo>Installing ${out.debug.package} onto default emulator or device...</echo> - <exec executable="${adb}" failonerror="true"> - <arg line="${adb.device.arg}" /> - <arg value="install" /> - <arg value="-r" /> - <arg path="${out.debug.package}" /> - </exec> - </sequential> - </macrodef> - - <!-- Rules --> - - <!-- Creates the output directories if they don't exist yet. --> - <target name="-dirs"> - <echo>Creating output directories if needed...</echo> - <mkdir dir="${resource.absolute.dir}" /> - <mkdir dir="${external.libs.absolute.dir}" /> - <mkdir dir="${gen.absolute.dir}" /> - <mkdir dir="${out.absolute.dir}" /> - <mkdir dir="${out.classes.absolute.dir}" /> - </target> - - <!-- Generates the R.java file for this project's resources. --> - <target name="-resource-src" depends="-dirs"> - <echo>Generating R.java / Manifest.java from the resources...</echo> - <exec executable="${aapt}" failonerror="true"> - <arg value="package" /> - <arg line="${v.option}" /> - <arg value="-m" /> - <arg value="-J" /> - <arg path="${gen.absolute.dir}" /> - <arg value="-M" /> - <arg path="AndroidManifest.xml" /> - <arg value="-S" /> - <arg path="${resource.absolute.dir}" /> - <arg value="-I" /> - <arg path="${android.jar}" /> - </exec> - </target> - - <!-- Generates java classes from .aidl files. --> - <target name="-aidl" depends="-dirs"> - <echo>Compiling aidl files into Java classes...</echo> - <apply executable="${aidl}" failonerror="true"> - <arg value="-p${android.aidl}" /> - <arg value="-I${source.absolute.dir}" /> - <arg value="-o${gen.absolute.dir}" /> - <fileset dir="${source.absolute.dir}"> - <include name="**/*.aidl" /> - </fileset> - </apply> - </target> - - <!-- Compiles this project's .java files into .class files. --> - <target name="compile" depends="-resource-src, -aidl" - description="Compiles project's .java files into .class files"> - <!-- If android rules are used for a test project, its classpath should include - tested project's location --> - <condition property="extensible.classpath" - value="${tested.project.absolute.dir}/bin/classes" else="."> - <isset property="tested.project.absolute.dir" /> - </condition> - <condition property="extensible.libs.classpath" - value="${tested.project.absolute.dir}/libs" else="./libs"> - <isset property="tested.project.absolute.dir" /> - </condition> - <javac encoding="ascii" target="1.5" debug="true" extdirs="" - destdir="${out.classes.absolute.dir}" - bootclasspathref="android.target.classpath" - verbose="${verbose}" classpath="${extensible.classpath}"> - <src path="${source.absolute.dir}" /> - <src path="${gen.absolute.dir}" /> - <classpath> - <fileset dir="${external.libs.absolute.dir}" includes="*.jar" /> - <fileset dir="${extensible.libs.classpath}" includes="*.jar" /> - </classpath> - </javac> - </target> - - <!-- Converts this project's .class files into .dex files --> - <target name="-dex" depends="compile"> - <dex-helper /> - </target> - - <!-- Puts the project's resources into the output package file - This actually can create multiple resource package in case - Some custom apk with specific configuration have been - declared in default.properties. - --> - <target name="-package-resources"> - <echo>Packaging resources</echo> - <aaptexec executable="${aapt}" - command="package" - manifest="AndroidManifest.xml" - resources="${resource.absolute.dir}" - assets="${asset.absolute.dir}" - androidjar="${android.jar}" - outfolder="${out.absolute.dir}" - basename="${ant.project.name}" /> - </target> - - <!-- Packages the application and sign it with a debug key. --> - <target name="-package-debug-sign" depends="-dex, -package-resources"> - <package-helper sign.package="true" /> - </target> - - <!-- Packages the application without signing it. --> - <target name="-package-no-sign" depends="-dex, -package-resources"> - <package-helper sign.package="false" /> - </target> - - <target name="-compile-tested-if-test" if="tested.project.dir" unless="do.not.compile.again"> - <subant target="compile"> - <fileset dir="${tested.project.absolute.dir}" includes="build.xml" /> - </subant> - </target> - - <!-- Builds debug output package, provided all the necessary files are already dexed --> - <target name="debug" depends="-compile-tested-if-test, -package-debug-sign" - description="Builds the application and signs it with a debug key."> - <zipalign-helper in.package="${out.debug.unaligned.package}" - out.package="${out.debug.package}" /> - <echo>Debug Package: ${out.debug.package}</echo> - </target> - - <target name="-release-check"> - <condition property="release.sign"> - <and> - <isset property="key.store" /> - <isset property="key.alias" /> - </and> - </condition> - </target> - - <target name="-release-nosign" depends="-release-check" unless="release.sign"> - <echo>No key.store and key.alias properties found in build.properties.</echo> - <echo>Please sign ${out.unsigned.package} manually</echo> - <echo>and run zipalign from the Android SDK tools.</echo> - </target> - - <target name="release" depends="-package-no-sign, -release-nosign" if="release.sign" - description="Builds the application. The generated apk file must be signed before - it is published."> - <!-- Gets passwords --> - <input - message="Please enter keystore password (store:${key.store}):" - addproperty="key.store.password" /> - <input - message="Please enter password for alias '${key.alias}':" - addproperty="key.alias.password" /> - - <!-- Signs the APK --> - <echo>Signing final apk...</echo> - <signjar - jar="${out.unsigned.package}" - signedjar="${out.unaligned.package}" - keystore="${key.store}" - storepass="${key.store.password}" - alias="${key.alias}" - keypass="${key.alias.password}" - verbose="${verbose}" /> - - <!-- Zip aligns the APK --> - <zipalign-helper in.package="${out.unaligned.package}" - out.package="${out.release.package}" /> - <echo>Release Package: ${out.release.package}</echo> - </target> - - <target name="install" depends="debug" - description="Installs/reinstalls the debug package onto a running - emulator or device. If the application was previously installed, - the signatures must match." > - <install-helper /> - </target> - - <target name="-uninstall-check"> - <condition property="uninstall.run"> - <isset property="manifest.package" /> - </condition> - </target> - - <target name="-uninstall-error" depends="-uninstall-check" unless="uninstall.run"> - <echo>Unable to run 'ant uninstall', manifest.package property is not defined. - </echo> - </target> - - <!-- Uninstalls the package from the default emulator/device --> - <target name="uninstall" depends="-uninstall-error" if="uninstall.run" - description="Uninstalls the application from a running emulator or device."> - <echo>Uninstalling ${manifest.package} from the default emulator or device...</echo> - <exec executable="${adb}" failonerror="true"> - <arg line="${adb.device.arg}" /> - <arg value="uninstall" /> - <arg value="${manifest.package}" /> - </exec> - </target> - - <target name="clean" description="Removes output files created by other targets."> - <delete dir="${out.absolute.dir}" verbose="${verbose}" /> - <delete dir="${gen.absolute.dir}" verbose="${verbose}" /> - </target> - - <!-- Targets for code-coverage measurement purposes, invoked from external file --> - - <!-- Emma-instruments tested project classes (compiles the tested project if necessary) - and writes instrumented classes to ${instrumentation.absolute.dir}/classes --> - <target name="-emma-instrument" depends="compile"> - <echo>Instrumenting classes from ${out.absolute.dir}/classes...</echo> - <!-- It only instruments class files, not any external libs --> - <emma enabled="true"> - <instr verbosity="${verbosity}" - mode="overwrite" - instrpath="${out.absolute.dir}/classes" - outdir="${out.absolute.dir}/classes"> - </instr> - <!-- TODO: exclusion filters on R*.class and allowing custom exclusion from - user defined file --> - </emma> - </target> - - <target name="-dex-instrumented" depends="-emma-instrument"> - <dex-helper> - <extra-parameters> - <arg value="--no-locals" /> - </extra-parameters> - <external-libs> - <fileset file="${emma.dir}/emma_device.jar" /> - </external-libs> - </dex-helper> - </target> - - <!-- Invoked from external files for code coverage purposes --> - <target name="-package-with-emma" depends="-dex-instrumented, -package-resources"> - <package-helper sign.package="true"> - <extra-jars> - <!-- Injected from external file --> - <jarfile path="${emma.dir}/emma_device.jar" /> - </extra-jars> - </package-helper> - </target> - - <target name="-debug-with-emma" depends="-package-with-emma"> - <zipalign-helper in.package="${out.debug.unaligned.package}" - out.package="${out.debug.package}" /> - </target> - - <target name="-install-with-emma" depends="-debug-with-emma"> - <install-helper /> - </target> - - <!-- End of targets for code-coverage measurement purposes --> - - <target name="help"> - <!-- displays starts at col 13 - |13 80| --> - <echo>Android Ant Build. Available targets:</echo> - <echo> help: Displays this help.</echo> - <echo> clean: Removes output files created by other targets.</echo> - <echo> compile: Compiles project's .java files into .class files.</echo> - <echo> debug: Builds the application and signs it with a debug key.</echo> - <echo> release: Builds the application. The generated apk file must be</echo> - <echo> signed before it is published.</echo> - <echo> install: Installs/reinstalls the debug package onto a running</echo> - <echo> emulator or device.</echo> - <echo> If the application was previously installed, the</echo> - <echo> signatures must match.</echo> - <echo> uninstall: Uninstalls the application from a running emulator or</echo> - <echo> device.</echo> - </target> -</project> diff --git a/files/ant/ant_rules_r2.xml b/files/ant/ant_rules_r2.xml deleted file mode 100644 index ffd7c41..0000000 --- a/files/ant/ant_rules_r2.xml +++ /dev/null @@ -1,459 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project name="android_rules" default="debug"> - - <!-- - This rules file is meant to be imported by the custom Ant task: - com.android.ant.SetupTask - - The following properties are put in place by the importing task: - android.jar, android.aidl, aapt, aidl, and dx - - Additionnaly, the task sets up the following classpath reference: - android.target.classpath - This is used by the compiler task as the boot classpath. - --> - - <!-- Custom tasks --> - <taskdef name="aaptexec" - classname="com.android.ant.AaptExecLoopTask" - classpathref="android.antlibs" /> - - <taskdef name="apkbuilder" - classname="com.android.ant.ApkBuilderTask" - classpathref="android.antlibs" /> - - <taskdef name="xpath" - classname="com.android.ant.XPathTask" - classpathref="android.antlibs" /> - - <!-- Properties --> - - <!-- Tells adb which device to target. You can change this from the command line - by invoking "ant -Dadb.device.arg=-d" for device "ant -Dadb.device.arg=-e" for - the emulator. --> - <property name="adb.device.arg" value="" /> - - <property name="android.tools.dir" location="${sdk.dir}/tools" /> - <!-- Name of the application package extracted from manifest file --> - <xpath input="AndroidManifest.xml" expression="/manifest/@package" - output="manifest.package" /> - <!-- Value of the debuggable attribute (Application node) extracted from manifest file --> - <xpath input="AndroidManifest.xml" expression="/manifest/application/@android:debuggable" - output="manifest.debuggable" default="false"/> - - <!-- Input directories --> - <property name="source.dir" value="src" /> - <property name="source.absolute.dir" location="${source.dir}" /> - <property name="gen.dir" value="gen" /> - <property name="gen.absolute.dir" location="${gen.dir}" /> - <property name="resource.dir" value="res" /> - <property name="resource.absolute.dir" location="${resource.dir}" /> - <property name="asset.dir" value="assets" /> - <property name="asset.absolute.dir" location="${asset.dir}" /> - - <!-- Directory for the third party java libraries --> - <property name="external.libs.dir" value="libs" /> - <property name="external.libs.absolute.dir" location="${external.libs.dir}" /> - - <!-- Directory for the native libraries --> - <property name="native.libs.dir" value="libs" /> - <property name="native.libs.absolute.dir" location="${native.libs.dir}" /> - - <!-- Output directories --> - <property name="out.dir" value="bin" /> - <property name="out.absolute.dir" location="${out.dir}" /> - <property name="out.classes.dir" value="${out.absolute.dir}/classes" /> - <property name="out.classes.absolute.dir" location="${out.classes.dir}" /> - - <!-- Intermediate files --> - <property name="dex.file.name" value="classes.dex" /> - <property name="intermediate.dex.file" location="${out.absolute.dir}/${dex.file.name}" /> - - <!-- The final package file to generate --> - <property name="out.debug.unaligned.package" - location="${out.absolute.dir}/${ant.project.name}-debug-unaligned.apk" /> - <property name="out.debug.package" - location="${out.absolute.dir}/${ant.project.name}-debug.apk" /> - <property name="out.unsigned.package" - location="${out.absolute.dir}/${ant.project.name}-unsigned.apk" /> - <property name="out.unaligned.package" - location="${out.absolute.dir}/${ant.project.name}-unaligned.apk" /> - <property name="out.release.package" - location="${out.absolute.dir}/${ant.project.name}-release.apk" /> - - <!-- Verbosity --> - <property name="verbose" value="false" /> - <!-- This is needed by emma as it uses multilevel verbosity instead of simple 'true' or 'false' - The property 'verbosity' is not user configurable and depends exclusively on 'verbose' - value.--> - <condition property="verbosity" value="verbose" else="quiet"> - <istrue value="${verbose}" /> - </condition> - <!-- This is needed to switch verbosity of zipalign. Depends exclusively on 'verbose' - --> - <condition property="v.option" value="-v" else=""> - <istrue value="${verbose}" /> - </condition> - <!-- This is needed to switch verbosity of dx. Depends exclusively on 'verbose' --> - <condition property="verbose.option" value="--verbose" else=""> - <istrue value="${verbose}" /> - </condition> - - <!-- Tools --> - <condition property="exe" value=".exe" else=""><os family="windows" /></condition> - <property name="adb" location="${android.tools.dir}/adb${exe}" /> - <property name="zipalign" location="${android.tools.dir}/zipalign${exe}" /> - - <!-- Emma configuration --> - <property name="emma.dir" value="${sdk.dir}/tools/lib" /> - <path id="emma.lib"> - <pathelement location="${emma.dir}/emma.jar" /> - <pathelement location="${emma.dir}/emma_ant.jar" /> - </path> - <taskdef resource="emma_ant.properties" classpathref="emma.lib" /> - <!-- End of emma configuration --> - - <!-- Macros --> - - <!-- Configurable macro, which allows to pass as parameters output directory, - output dex filename and external libraries to dex (optional) --> - <macrodef name="dex-helper"> - <element name="external-libs" optional="yes" /> - <element name="extra-parameters" optional="yes" /> - <sequential> - <echo>Converting compiled files and external libraries into ${intermediate.dex.file}...</echo> - <apply executable="${dx}" failonerror="true" parallel="true"> - <arg value="--dex" /> - <arg value="--output=${intermediate.dex.file}" /> - <extra-parameters /> - <arg line="${verbose.option}" /> - <arg path="${out.classes.absolute.dir}" /> - <fileset dir="${external.libs.absolute.dir}" includes="*.jar" /> - <path refid="android.libraries.jars" /> - <external-libs /> - </apply> - </sequential> - </macrodef> - - <!-- This is macro that enable passing variable list of external jar files to ApkBuilder - Example of use: - <package-helper sign.package="true"> - <extra-jars> - <jarfolder path="my_jars" /> - <jarfile path="foo/bar.jar" /> - <jarfolder path="your_jars" /> - </extra-jars> - </package-helper> --> - <macrodef name="package-helper"> - <attribute name="sign.package" /> - <element name="extra-jars" optional="yes" /> - <sequential> - <apkbuilder - outfolder="${out.absolute.dir}" - basename="${ant.project.name}" - signed="@{sign.package}" - debug="${manifest.debuggable}" - verbose="${verbose}"> - <file path="${intermediate.dex.file}" /> - <sourcefolder path="${source.absolute.dir}" /> - <sourcefolder refid="android.libraries.src" /> - <jarfolder path="${external.libs.absolute.dir}" /> - <jarfolder refid="android.libraries.libs" /> - <nativefolder path="${native.libs.absolute.dir}" /> - <nativefolder refid="android.libraries.libs" /> - <extra-jars/> - </apkbuilder> - </sequential> - </macrodef> - - <!-- This is macro which zipaligns in.package and outputs it to out.package. Used by targets - debug, -debug-with-emma and release.--> - <macrodef name="zipalign-helper"> - <attribute name="in.package" /> - <attribute name="out.package" /> - <sequential> - <echo>Running zip align on final apk...</echo> - <exec executable="${zipalign}" failonerror="true"> - <arg line="${v.option}" /> - <arg value="-f" /> - <arg value="4" /> - <arg path="@{in.package}" /> - <arg path="@{out.package}" /> - </exec> - </sequential> - </macrodef> - - <!-- This is macro used only for sharing code among two targets, -install and - -install-with-emma which do exactly the same but differ in dependencies --> - <macrodef name="install-helper"> - <sequential> - <echo>Installing ${out.debug.package} onto default emulator or device...</echo> - <exec executable="${adb}" failonerror="true"> - <arg line="${adb.device.arg}" /> - <arg value="install" /> - <arg value="-r" /> - <arg path="${out.debug.package}" /> - </exec> - </sequential> - </macrodef> - - <!-- Rules --> - - <!-- Creates the output directories if they don't exist yet. --> - <target name="-dirs"> - <echo>Creating output directories if needed...</echo> - <mkdir dir="${resource.absolute.dir}" /> - <mkdir dir="${external.libs.absolute.dir}" /> - <mkdir dir="${gen.absolute.dir}" /> - <mkdir dir="${out.absolute.dir}" /> - <mkdir dir="${out.classes.absolute.dir}" /> - </target> - - <!-- Generates the R.java file for this project's resources. --> - <target name="-resource-src" depends="-dirs"> - <echo>Generating R.java / Manifest.java from the resources...</echo> - <aaptexec executable="${aapt}" - command="package" - verbose="${verbose}" - manifest="AndroidManifest.xml" - androidjar="${android.jar}" - rfolder="${gen.absolute.dir}"> - <res path="${resource.absolute.dir}" /> - </aaptexec> - </target> - - <!-- Generates java classes from .aidl files. --> - <target name="-aidl" depends="-dirs"> - <echo>Compiling aidl files into Java classes...</echo> - <apply executable="${aidl}" failonerror="true"> - <arg value="-p${android.aidl}" /> - <arg value="-I${source.absolute.dir}" /> - <arg value="-o${gen.absolute.dir}" /> - <fileset dir="${source.absolute.dir}"> - <include name="**/*.aidl" /> - </fileset> - </apply> - </target> - - <!-- Compiles this project's .java files into .class files. --> - <target name="compile" depends="-resource-src, -aidl" - description="Compiles project's .java files into .class files"> - <!-- If android rules are used for a test project, its classpath should include - tested project's location --> - <condition property="extensible.classpath" - value="${tested.project.absolute.dir}/bin/classes" else="."> - <isset property="tested.project.absolute.dir" /> - </condition> - <condition property="extensible.libs.classpath" - value="${tested.project.absolute.dir}/libs" else="./libs"> - <isset property="tested.project.absolute.dir" /> - </condition> - <javac encoding="ascii" target="1.5" debug="true" extdirs="" - destdir="${out.classes.absolute.dir}" - bootclasspathref="android.target.classpath" - verbose="${verbose}" classpath="${extensible.classpath}" - classpathref="android.libraries.jars"> - <src path="${source.absolute.dir}" /> - <src path="${gen.absolute.dir}" /> - <src refid="android.libraries.src" /> - <classpath> - <fileset dir="${external.libs.absolute.dir}" includes="*.jar" /> - <fileset dir="${extensible.libs.classpath}" includes="*.jar" /> - </classpath> - </javac> - </target> - - <!-- Converts this project's .class files into .dex files --> - <target name="-dex" depends="compile"> - <dex-helper /> - </target> - - <!-- Puts the project's resources into the output package file - This actually can create multiple resource package in case - Some custom apk with specific configuration have been - declared in default.properties. - --> - <target name="-package-resources"> - <echo>Packaging resources</echo> - <aaptexec executable="${aapt}" - command="package" - manifest="AndroidManifest.xml" - assets="${asset.absolute.dir}" - androidjar="${android.jar}" - apkfolder="${out.absolute.dir}" - apkbasename="${ant.project.name}"> - <res path="${resource.absolute.dir}" /> - <!-- <nocompress /> forces no compression on any files in assets or res/raw --> - <!-- <nocompress extension="xml" /> forces no compression on specific file extensions in assets and res/raw --> - </aaptexec> - </target> - - <!-- Packages the application and sign it with a debug key. --> - <target name="-package-debug-sign" depends="-dex, -package-resources"> - <package-helper sign.package="true" /> - </target> - - <!-- Packages the application without signing it. --> - <target name="-package-release" depends="-dex, -package-resources"> - <package-helper sign.package="false" /> - </target> - - <target name="-compile-tested-if-test" if="tested.project.dir" unless="do.not.compile.again"> - <subant target="compile"> - <fileset dir="${tested.project.absolute.dir}" includes="build.xml" /> - </subant> - </target> - - <!-- Builds debug output package, provided all the necessary files are already dexed --> - <target name="debug" depends="-compile-tested-if-test, -package-debug-sign" - description="Builds the application and signs it with a debug key."> - <zipalign-helper in.package="${out.debug.unaligned.package}" - out.package="${out.debug.package}" /> - <echo>Debug Package: ${out.debug.package}</echo> - </target> - - <target name="-release-check"> - <condition property="release.sign"> - <and> - <isset property="key.store" /> - <isset property="key.alias" /> - </and> - </condition> - </target> - - <target name="-release-nosign" depends="-release-check" unless="release.sign"> - <echo>No key.store and key.alias properties found in build.properties.</echo> - <echo>Please sign ${out.unsigned.package} manually</echo> - <echo>and run zipalign from the Android SDK tools.</echo> - </target> - - <target name="release" depends="-package-release, -release-nosign" if="release.sign" - description="Builds the application. The generated apk file must be signed before - it is published."> - <!-- Gets passwords --> - <input - message="Please enter keystore password (store:${key.store}):" - addproperty="key.store.password" /> - <input - message="Please enter password for alias '${key.alias}':" - addproperty="key.alias.password" /> - - <!-- Signs the APK --> - <echo>Signing final apk...</echo> - <signjar - jar="${out.unsigned.package}" - signedjar="${out.unaligned.package}" - keystore="${key.store}" - storepass="${key.store.password}" - alias="${key.alias}" - keypass="${key.alias.password}" - verbose="${verbose}" /> - - <!-- Zip aligns the APK --> - <zipalign-helper in.package="${out.unaligned.package}" - out.package="${out.release.package}" /> - <echo>Release Package: ${out.release.package}</echo> - </target> - - <target name="install" depends="debug" - description="Installs/reinstalls the debug package onto a running - emulator or device. If the application was previously installed, - the signatures must match." > - <install-helper /> - </target> - - <target name="-uninstall-check"> - <condition property="uninstall.run"> - <isset property="manifest.package" /> - </condition> - </target> - - <target name="-uninstall-error" depends="-uninstall-check" unless="uninstall.run"> - <echo>Unable to run 'ant uninstall', manifest.package property is not defined. - </echo> - </target> - - <!-- Uninstalls the package from the default emulator/device --> - <target name="uninstall" depends="-uninstall-error" if="uninstall.run" - description="Uninstalls the application from a running emulator or device."> - <echo>Uninstalling ${manifest.package} from the default emulator or device...</echo> - <exec executable="${adb}" failonerror="true"> - <arg line="${adb.device.arg}" /> - <arg value="uninstall" /> - <arg value="${manifest.package}" /> - </exec> - </target> - - <target name="clean" description="Removes output files created by other targets."> - <delete dir="${out.absolute.dir}" verbose="${verbose}" /> - <delete dir="${gen.absolute.dir}" verbose="${verbose}" /> - </target> - - <!-- Targets for code-coverage measurement purposes, invoked from external file --> - - <!-- Emma-instruments tested project classes (compiles the tested project if necessary) - and writes instrumented classes to ${instrumentation.absolute.dir}/classes --> - <target name="-emma-instrument" depends="compile"> - <echo>Instrumenting classes from ${out.absolute.dir}/classes...</echo> - <!-- It only instruments class files, not any external libs --> - <emma enabled="true"> - <instr verbosity="${verbosity}" - mode="overwrite" - instrpath="${out.absolute.dir}/classes" - outdir="${out.absolute.dir}/classes"> - </instr> - <!-- TODO: exclusion filters on R*.class and allowing custom exclusion from - user defined file --> - </emma> - </target> - - <target name="-dex-instrumented" depends="-emma-instrument"> - <dex-helper> - <extra-parameters> - <arg value="--no-locals" /> - </extra-parameters> - <external-libs> - <fileset file="${emma.dir}/emma_device.jar" /> - </external-libs> - </dex-helper> - </target> - - <!-- Invoked from external files for code coverage purposes --> - <target name="-package-with-emma" depends="-dex-instrumented, -package-resources"> - <package-helper sign.package="true"> - <extra-jars> - <!-- Injected from external file --> - <jarfile path="${emma.dir}/emma_device.jar" /> - </extra-jars> - </package-helper> - </target> - - <target name="-debug-with-emma" depends="-package-with-emma"> - <zipalign-helper in.package="${out.debug.unaligned.package}" - out.package="${out.debug.package}" /> - </target> - - <target name="-install-with-emma" depends="-debug-with-emma"> - <install-helper /> - </target> - - <!-- End of targets for code-coverage measurement purposes --> - - <target name="help"> - <!-- displays starts at col 13 - |13 80| --> - <echo>Android Ant Build. Available targets:</echo> - <echo> help: Displays this help.</echo> - <echo> clean: Removes output files created by other targets.</echo> - <echo> compile: Compiles project's .java files into .class files.</echo> - <echo> debug: Builds the application and signs it with a debug key.</echo> - <echo> release: Builds the application. The generated apk file must be</echo> - <echo> signed before it is published.</echo> - <echo> install: Installs/reinstalls the debug package onto a running</echo> - <echo> emulator or device.</echo> - <echo> If the application was previously installed, the</echo> - <echo> signatures must match.</echo> - <echo> uninstall: Uninstalls the application from a running emulator or</echo> - <echo> device.</echo> - </target> -</project> diff --git a/files/ant/ant_test_rules_r1.xml b/files/ant/ant_test_rules_r1.xml deleted file mode 100644 index 78503ae..0000000 --- a/files/ant/ant_test_rules_r1.xml +++ /dev/null @@ -1,104 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project name="android_test_rules" default="run-tests"> - - <import file="android_rules.xml" /> - - <property name="tested.project.absolute.dir" location="${tested.project.dir}" /> - <property name="instrumentation.dir" value="instrumented" /> - <property name="instrumentation.absolute.dir" location="${instrumentation.dir}" /> - - <property name="test.runner" value="android.test.InstrumentationTestRunner" /> - <!-- Application package of the tested project extracted from its manifest file --> - <xpath input="${tested.project.absolute.dir}/AndroidManifest.xml" - expression="/manifest/@package" output="tested.manifest.package" /> - - <!-- TODO: make it more configurable in the next CL's - now it is default for auto-generated - project --> - <property name="emma.dump.file" - value="/data/data/${tested.manifest.package}/files/coverage.ec" /> - - <macrodef name="run-tests-helper"> - <attribute name="emma.enabled" default="false" /> - <element name="extra-instrument-args" optional="yes" /> - <sequential> - <echo>Running tests ...</echo> - <exec executable="${adb}" failonerror="true"> - <arg value="shell" /> - <arg value="am" /> - <arg value="instrument" /> - <arg value="-w" /> - <arg value="-e" /> - <arg value="coverage" /> - <arg value="@{emma.enabled}" /> - <extra-instrument-args /> - <arg value="${manifest.package}/${test.runner}" /> - </exec> - </sequential> - </macrodef> - - <!-- Invoking this target sets the value of extensible.classpath, which is being added to javac - classpath in target 'compile' (android_rules.xml) --> - <target name="-set-coverage-classpath"> - <property name="extensible.classpath" - location="${instrumentation.absolute.dir}/classes" /> - </target> - - <!-- Ensures that tested project is installed on the device before we run the tests. - Used for ordinary tests, without coverage measurement --> - <target name="-install-tested-project"> - <property name="do.not.compile.again" value="true" /> - <subant target="install"> - <fileset dir="${tested.project.absolute.dir}" includes="build.xml" /> - </subant> - </target> - - <target name="run-tests" depends="-install-tested-project, install" - description="Runs tests from the package defined in test.package property"> - <run-tests-helper /> - </target> - - <target name="-install-instrumented"> - <property name="do.not.compile.again" value="true" /> - <subant target="-install-with-emma"> - <property name="out.absolute.dir" value="${instrumentation.absolute.dir}" /> - <fileset dir="${tested.project.absolute.dir}" includes="build.xml" /> - </subant> - </target> - - <target name="coverage" depends="-set-coverage-classpath, -install-instrumented, install" - description="Runs the tests against the instrumented code and generates - code coverage report"> - <run-tests-helper emma.enabled="true"> - <extra-instrument-args> - <arg value="-e" /> - <arg value="coverageFile" /> - <arg value="${emma.dump.file}" /> - </extra-instrument-args> - </run-tests-helper> - <echo>Downloading coverage file into project directory...</echo> - <exec executable="${adb}" failonerror="true"> - <arg value="pull" /> - <arg value="${emma.dump.file}" /> - <arg value="coverage.ec" /> - </exec> - <echo>Extracting coverage report...</echo> - <emma> - <report sourcepath="${tested.project.absolute.dir}/${source.dir}" - verbosity="${verbosity}"> - <!-- TODO: report.dir or something like should be introduced if necessary --> - <infileset dir="."> - <include name="coverage.ec" /> - <include name="coverage.em" /> - </infileset> - <!-- TODO: reports in other, indicated by user formats --> - <html outfile="coverage.html" /> - </report> - </emma> - <echo>Cleaning up temporary files...</echo> - <delete dir="${instrumentation.absolute.dir}" /> - <delete file="coverage.ec" /> - <delete file="coverage.em" /> - <echo>Saving the report file in ${basedir}/coverage/coverage.html</echo> - </target> - -</project> diff --git a/files/ant/ant_test_rules_r2.xml b/files/ant/ant_test_rules_r2.xml deleted file mode 100644 index 00ebfea..0000000 --- a/files/ant/ant_test_rules_r2.xml +++ /dev/null @@ -1,104 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project name="android_test_rules" default="run-tests"> - - <import file="ant_rules_r2.xml" /> - - <property name="tested.project.absolute.dir" location="${tested.project.dir}" /> - <property name="instrumentation.dir" value="instrumented" /> - <property name="instrumentation.absolute.dir" location="${instrumentation.dir}" /> - - <property name="test.runner" value="android.test.InstrumentationTestRunner" /> - <!-- Application package of the tested project extracted from its manifest file --> - <xpath input="${tested.project.absolute.dir}/AndroidManifest.xml" - expression="/manifest/@package" output="tested.manifest.package" /> - - <!-- TODO: make it more configurable in the next CL's - now it is default for auto-generated - project --> - <property name="emma.dump.file" - value="/data/data/${tested.manifest.package}/files/coverage.ec" /> - - <macrodef name="run-tests-helper"> - <attribute name="emma.enabled" default="false" /> - <element name="extra-instrument-args" optional="yes" /> - <sequential> - <echo>Running tests ...</echo> - <exec executable="${adb}" failonerror="true"> - <arg value="shell" /> - <arg value="am" /> - <arg value="instrument" /> - <arg value="-w" /> - <arg value="-e" /> - <arg value="coverage" /> - <arg value="@{emma.enabled}" /> - <extra-instrument-args /> - <arg value="${manifest.package}/${test.runner}" /> - </exec> - </sequential> - </macrodef> - - <!-- Invoking this target sets the value of extensible.classpath, which is being added to javac - classpath in target 'compile' (android_rules.xml) --> - <target name="-set-coverage-classpath"> - <property name="extensible.classpath" - location="${instrumentation.absolute.dir}/classes" /> - </target> - - <!-- Ensures that tested project is installed on the device before we run the tests. - Used for ordinary tests, without coverage measurement --> - <target name="-install-tested-project"> - <property name="do.not.compile.again" value="true" /> - <subant target="install"> - <fileset dir="${tested.project.absolute.dir}" includes="build.xml" /> - </subant> - </target> - - <target name="run-tests" depends="-install-tested-project, install" - description="Runs tests from the package defined in test.package property"> - <run-tests-helper /> - </target> - - <target name="-install-instrumented"> - <property name="do.not.compile.again" value="true" /> - <subant target="-install-with-emma"> - <property name="out.absolute.dir" value="${instrumentation.absolute.dir}" /> - <fileset dir="${tested.project.absolute.dir}" includes="build.xml" /> - </subant> - </target> - - <target name="coverage" depends="-set-coverage-classpath, -install-instrumented, install" - description="Runs the tests against the instrumented code and generates - code coverage report"> - <run-tests-helper emma.enabled="true"> - <extra-instrument-args> - <arg value="-e" /> - <arg value="coverageFile" /> - <arg value="${emma.dump.file}" /> - </extra-instrument-args> - </run-tests-helper> - <echo>Downloading coverage file into project directory...</echo> - <exec executable="${adb}" failonerror="true"> - <arg value="pull" /> - <arg value="${emma.dump.file}" /> - <arg value="coverage.ec" /> - </exec> - <echo>Extracting coverage report...</echo> - <emma> - <report sourcepath="${tested.project.absolute.dir}/${source.dir}" - verbosity="${verbosity}"> - <!-- TODO: report.dir or something like should be introduced if necessary --> - <infileset dir="."> - <include name="coverage.ec" /> - <include name="coverage.em" /> - </infileset> - <!-- TODO: reports in other, indicated by user formats --> - <html outfile="coverage.html" /> - </report> - </emma> - <echo>Cleaning up temporary files...</echo> - <delete dir="${instrumentation.absolute.dir}" /> - <delete file="coverage.ec" /> - <delete file="coverage.em" /> - <echo>Saving the report file in ${basedir}/coverage/coverage.html</echo> - </target> - -</project> diff --git a/files/ant/ant_lib_rules_r3.xml b/files/ant/lib_rules.xml index a1b2217..a1b2217 100644 --- a/files/ant/ant_lib_rules_r3.xml +++ b/files/ant/lib_rules.xml diff --git a/files/ant/ant_rules_r3.xml b/files/ant/main_rules.xml index 2ac5742..96fb0ef 100644 --- a/files/ant/ant_rules_r3.xml +++ b/files/ant/main_rules.xml @@ -45,10 +45,7 @@ <!-- Name of the application package extracted from manifest file --> <xpath input="AndroidManifest.xml" expression="/manifest/@package" output="manifest.package" /> - <!-- Value of the debuggable attribute (Application node) extracted from manifest file --> - <xpath input="AndroidManifest.xml" expression="/manifest/application/@android:debuggable" - output="manifest.debuggable" default="false"/> - <!-- Value of the debuggable attribute (Application node) extracted from manifest file --> + <!-- Value of the hasCode attribute (Application node) extracted from manifest file --> <xpath input="AndroidManifest.xml" expression="/manifest/application/@android:hasCode" output="manifest.hasCode" default="true"/> @@ -186,7 +183,7 @@ <!-- This is macro that enable passing variable list of external jar files to ApkBuilder Example of use: - <package-helper sign.package="true" output.filepath="/path/to/foo.apk"> + <package-helper output.filepath="/path/to/foo.apk"> <extra-jars> <jarfolder path="my_jars" /> <jarfile path="foo/bar.jar" /> @@ -194,7 +191,6 @@ </extra-jars> </package-helper> --> <macrodef name="package-helper"> - <attribute name="sign.package" /> <attribute name="output.filepath" /> <element name="extra-jars" optional="yes" /> <sequential> @@ -202,8 +198,7 @@ outfolder="${out.absolute.dir}" resourcefile="${resource.package.file.name}" apkfilepath="@{output.filepath}" - signed="@{sign.package}" - debug="${manifest.debuggable}" + debug="${build.debug}" abifilter="${filter.abi}" verbose="${verbose}" hascode="${manifest.hasCode}"> @@ -376,6 +371,7 @@ <aapt executable="${aapt}" command="package" versioncode="${version.code}" + debug="${build.debug}" manifest="AndroidManifest.xml" assets="${asset.absolute.dir}" androidjar="${android.jar}" @@ -391,14 +387,12 @@ <!-- Packages the application and sign it with a debug key. --> <target name="-package-debug-sign" depends="-dex, -package-resources"> <package-helper - sign.package="true" output.filepath="${out.debug.unaligned.file}" /> </target> <!-- Packages the application without signing it. --> <target name="-package-release" depends="-dex, -package-resources"> <package-helper - sign.package="false" output.filepath="${out.unsigned.file}"/> </target> @@ -408,8 +402,18 @@ </subant> </target> + <target name="-set-debug-mode"> + <!-- property only set in debug mode. + Useful for if/unless attributes in target node + when using Ant before 1.8 --> + <property name="build.mode.debug" value="true"/> + + <!-- whether the build is a debug build. always set. --> + <property name="build.debug" value="true" /> + </target> + <!-- Builds debug output package, provided all the necessary files are already dexed --> - <target name="debug" depends="-compile-tested-if-test, -package-debug-sign" + <target name="debug" depends="-set-debug-mode, -compile-tested-if-test, -package-debug-sign" description="Builds the application and signs it with a debug key."> <zipalign-helper in.package="${out.debug.unaligned.file}" out.package="${out.debug.file}" /> @@ -437,7 +441,13 @@ </target> <target name="-set-release-mode"> + <!-- property only set in release mode. + Useful for if/unless attributes in target node + when using Ant before 1.8 --> <property name="build.mode.release" value="true"/> + + <!-- whether the build is a debug build. always set. --> + <property name="build.debug" value="false" /> </target> <!-- This runs -package-release and -release-nosign first and then runs @@ -531,7 +541,6 @@ <!-- Invoked from external files for code coverage purposes --> <target name="-package-with-emma" depends="-dex-instrumented, -package-resources"> <package-helper - sign.package="true" output.filepath="${out.debug.unaligned.file}"> <extra-jars> <!-- Injected from external file --> @@ -540,7 +549,7 @@ </package-helper> </target> - <target name="-debug-with-emma" depends="-package-with-emma"> + <target name="-debug-with-emma" depends="-set-debug-mode, -package-with-emma"> <zipalign-helper in.package="${out.debug.unaligned.file}" out.package="${out.debug.file}" /> </target> diff --git a/files/ant/ant_test_rules_r3.xml b/files/ant/test_rules.xml index 62fc77d..62fc77d 100644 --- a/files/ant/ant_test_rules_r3.xml +++ b/files/ant/test_rules.xml diff --git a/files/sdk.properties b/files/sdk.properties index cf62029..efa50d9 100644 --- a/files/sdk.properties +++ b/files/sdk.properties @@ -1,6 +1,4 @@ # SDK properties # This file is copied in the root folder of each platform component. # If it used by various tools to figure out what the platform can do. -sdk.build.support.library=true -sdk.ant.build.revision=3 sdk.ant.templates.revision=1
\ No newline at end of file diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkConstants.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkConstants.java index 86eff4d..eae636d 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkConstants.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/SdkConstants.java @@ -309,10 +309,6 @@ public final class SdkConstants { /** Skin default **/ public final static String SKIN_DEFAULT = "default"; - /** SDK property: support for library */ - public final static String PROP_SDK_SUPPORT_LIBRARY = "sdk.build.support.library"; //$NON-NLS-1$ - /** SDK property: ant build revision */ - public final static String PROP_SDK_ANT_BUILD_REVISION = "sdk.ant.build.revision"; //$NON-NLS-1$ /** SDK property: ant templates revision */ public final static String PROP_SDK_ANT_TEMPLATES_REVISION = "sdk.ant.templates.revision"; //$NON-NLS-1$ diff --git a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectCreator.java b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectCreator.java index df58290..783b0fe 100644 --- a/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectCreator.java +++ b/sdkmanager/libs/sdklib/src/com/android/sdklib/internal/project/ProjectCreator.java @@ -492,17 +492,6 @@ public class ProjectCreator { return false; } - // before doing anything, make sure library (if present) can be applied. - if (libraryPath != null) { - IAndroidTarget finalTarget = target != null ? target : originalTarget; - if (finalTarget.getProperty(SdkConstants.PROP_SDK_SUPPORT_LIBRARY, false) == false) { - mLog.error(null, - "The build system for this project target (%1$s) does not support libraries", - finalTarget.getFullName()); - return false; - } - } - boolean saveDefaultProps = false; ProjectPropertiesWorkingCopy propsWC = null; |