1 /* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Eclipse Public License, Version 1.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.eclipse.org/org/documents/epl-v10.php 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.ide.eclipse.adt; 18 19 import com.android.AndroidConstants; 20 import com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder; 21 import com.android.ide.eclipse.adt.internal.build.builders.PreCompilerBuilder; 22 import com.android.ide.eclipse.adt.internal.build.builders.ResourceManagerBuilder; 23 import com.android.sdklib.SdkConstants; 24 25 import java.io.File; 26 import java.util.regex.Pattern; 27 28 /** 29 * Constant definition class.<br> 30 * <br> 31 * Most constants have a prefix defining the content. 32 * <ul> 33 * <li><code>WS_</code> Workspace path constant. Those are absolute paths, 34 * from the project root.</li> 35 * <li><code>OS_</code> OS path constant. These paths are different depending on the platform.</li> 36 * <li><code>FN_</code> File name constant.</li> 37 * <li><code>FD_</code> Folder name constant.</li> 38 * <li><code>MARKER_</code> Resource Marker Ids constant.</li> 39 * <li><code>EXT_</code> File extension constant. This does NOT include a dot.</li> 40 * <li><code>DOT_</code> File extension constant. This start with a dot.</li> 41 * <li><code>RE_</code> Regexp constant.</li> 42 * <li><code>NS_</code> Namespace constant.</li> 43 * <li><code>CLASS_</code> Fully qualified class name.</li> 44 * </ul> 45 * 46 */ 47 public class AdtConstants { 48 /** 49 * The old Editors Plugin ID. It is still used in some places for compatibility. 50 * Please do not use for new features. 51 */ 52 public static final String EDITORS_NAMESPACE = "com.android.ide.eclipse.editors"; //$NON-NLS-1$ 53 54 /** Nature of default Android projects */ 55 public final static String NATURE_DEFAULT = "com.android.ide.eclipse.adt.AndroidNature"; //$NON-NLS-1$ 56 57 /** The container id for the android framework jar file */ 58 public final static String CONTAINER_FRAMEWORK = 59 "com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"; //$NON-NLS-1$ 60 61 /** The container id for the libraries */ 62 public final static String CONTAINER_LIBRARIES = "com.android.ide.eclipse.adt.LIBRARIES"; //$NON-NLS-1$ 63 64 65 /** Separator for workspace path, i.e. "/". */ 66 public final static String WS_SEP = "/"; //$NON-NLS-1$ 67 /** Separator character for workspace path, i.e. '/'. */ 68 public final static char WS_SEP_CHAR = '/'; 69 70 /** Extension of the Application package Files, i.e. "apk". */ 71 public final static String EXT_ANDROID_PACKAGE = "apk"; //$NON-NLS-1$ 72 /** Extension of java files, i.e. "java" */ 73 public final static String EXT_JAVA = "java"; //$NON-NLS-1$ 74 /** Extension of compiled java files, i.e. "class" */ 75 public final static String EXT_CLASS = "class"; //$NON-NLS-1$ 76 /** Extension of xml files, i.e. "xml" */ 77 public final static String EXT_XML = "xml"; //$NON-NLS-1$ 78 /** Extension of jar files, i.e. "jar" */ 79 public final static String EXT_JAR = "jar"; //$NON-NLS-1$ 80 /** Extension of aidl files, i.e. "aidl" */ 81 public final static String EXT_AIDL = "aidl"; //$NON-NLS-1$ 82 /** Extension of Renderscript files, i.e. "rs" */ 83 public final static String EXT_RS = "rs"; //$NON-NLS-1$ 84 /** Extension of dependency files, i.e. "d" */ 85 public final static String EXT_DEP = "d"; //$NON-NLS-1$ 86 /** Extension of native libraries, i.e. "so" */ 87 public final static String EXT_NATIVE_LIB = "so"; //$NON-NLS-1$ 88 /** Extension of dex files, i.e. "dex" */ 89 public final static String EXT_DEX = "dex"; //$NON-NLS-1$ 90 /** Extension for temporary resource files, ie "ap_ */ 91 public final static String EXT_RES = "ap_"; //$NON-NLS-1$ 92 /** Extension for pre-processable images. Right now pngs */ 93 public final static String EXT_PNG = "png"; //$NON-NLS-1$ 94 95 private final static String DOT = "."; //$NON-NLS-1$ 96 97 /** Dot-Extension of the Application package Files, i.e. ".apk". */ 98 public final static String DOT_ANDROID_PACKAGE = DOT + EXT_ANDROID_PACKAGE; 99 /** Dot-Extension of java files, i.e. ".java" */ 100 public final static String DOT_JAVA = DOT + EXT_JAVA; 101 /** Dot-Extension of compiled java files, i.e. ".class" */ 102 public final static String DOT_CLASS = DOT + EXT_CLASS; 103 /** Dot-Extension of xml files, i.e. ".xml" */ 104 public final static String DOT_XML = DOT + EXT_XML; 105 /** Dot-Extension of jar files, i.e. ".jar" */ 106 public final static String DOT_JAR = DOT + EXT_JAR; 107 /** Dot-Extension of aidl files, i.e. ".aidl" */ 108 public final static String DOT_AIDL = DOT + EXT_AIDL; 109 /** Dot-Extension of renderscript files, i.e. ".rs" */ 110 public final static String DOT_RS = DOT + EXT_RS; 111 /** Dot-Extension of dependency files, i.e. ".d" */ 112 public final static String DOT_DEP = DOT + EXT_DEP; 113 /** Dot-Extension of dex files, i.e. ".dex" */ 114 public final static String DOT_DEX = DOT + EXT_DEX; 115 /** Dot-Extension for temporary resource files, ie "ap_ */ 116 public final static String DOT_RES = DOT + EXT_RES; 117 /** Dot-Extension for PNG files, i.e. ".png" */ 118 public static final String DOT_PNG = ".png"; //$NON-NLS-1$ 119 /** Dot-Extension for 9-patch files, i.e. ".9.png" */ 120 public static final String DOT_9PNG = ".9.png"; //$NON-NLS-1$ 121 /** Dot-Extension for GIF files, i.e. ".gif" */ 122 public static final String DOT_GIF = ".gif"; //$NON-NLS-1$ 123 /** Dot-Extension for JPEG files, i.e. ".jpg" */ 124 public static final String DOT_JPG = ".jpg"; //$NON-NLS-1$ 125 /** Dot-Extension for BMP files, i.e. ".bmp" */ 126 public static final String DOT_BMP = ".bmp"; //$NON-NLS-1$ 127 /** Dot-Extension for SVG files, i.e. ".svg" */ 128 public static final String DOT_SVG = ".svg"; //$NON-NLS-1$ 129 130 /** Name of the android sources directory */ 131 public static final String FD_ANDROID_SOURCES = "sources"; //$NON-NLS-1$ 132 133 /** Resource base name for java files and classes */ 134 public final static String FN_RESOURCE_BASE = "R"; //$NON-NLS-1$ 135 /** Resource java class filename, i.e. "R.java" */ 136 public final static String FN_RESOURCE_CLASS = FN_RESOURCE_BASE + DOT_JAVA; 137 /** Resource class file filename, i.e. "R.class" */ 138 public final static String FN_COMPILED_RESOURCE_CLASS = FN_RESOURCE_BASE + DOT_CLASS; 139 /** Manifest java class filename, i.e. "Manifest.java" */ 140 public final static String FN_MANIFEST_CLASS = "Manifest.java"; //$NON-NLS-1$ 141 /** Temporary packaged resources file name, i.e. "resources.ap_" */ 142 public final static String FN_RESOURCES_AP_ = "resources.ap_"; //$NON-NLS-1$ 143 /** Temporary packaged resources file name for a specific set of configuration */ 144 public final static String FN_RESOURCES_S_AP_ = "resources-%s.ap_"; //$NON-NLS-1$ 145 public final static Pattern PATTERN_RESOURCES_S_AP_ = 146 Pattern.compile("resources-.*\\.ap_", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$ 147 148 public final static String FN_TRACEVIEW = 149 (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_WINDOWS) ? 150 "traceview.bat" : "traceview"; //$NON-NLS-1$ //$NON-NLS-2$ 151 152 public final static String FN_HPROF_CONV = 153 (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_WINDOWS) ? 154 "hprof-conv.exe" : "hprof-conv"; //$NON-NLS-1$ //$NON-NLS-2$ 155 156 /** Absolute path of the workspace root, i.e. "/" */ 157 public final static String WS_ROOT = WS_SEP; 158 159 /** Absolute path of the resource folder, e.g. "/res".<br> This is a workspace path. */ 160 public final static String WS_RESOURCES = WS_SEP + SdkConstants.FD_RESOURCES; 161 162 /** Absolute path of the crunch cache folder, e.g. "/bin/res".<br> This is a workspace path. */ 163 public final static String WS_CRUNCHCACHE = WS_SEP + SdkConstants.FD_OUTPUT 164 + WS_SEP + SdkConstants.FD_RESOURCES; 165 166 /** Absolute path of the resource folder, e.g. "/assets".<br> This is a workspace path. */ 167 public final static String WS_ASSETS = WS_SEP + SdkConstants.FD_ASSETS; 168 169 /** Absolute path of the layout folder, e.g. "/res/layout".<br> This is a workspace path. */ 170 public final static String WS_LAYOUTS = WS_RESOURCES + WS_SEP + AndroidConstants.FD_RES_LAYOUT; 171 172 /** Leaf of the javaDoc folder. Does not start with a separator. */ 173 public final static String WS_JAVADOC_FOLDER_LEAF = SdkConstants.FD_DOCS + "/" + //$NON-NLS-1$ 174 SdkConstants.FD_DOCS_REFERENCE; 175 176 /** Path of the samples directory relative to the sdk folder. 177 * This is an OS path, ending with a separator. 178 * FIXME: remove once the NPW is fixed. */ 179 public final static String OS_SDK_SAMPLES_FOLDER = SdkConstants.FD_SAMPLES + File.separator; 180 181 public final static String RE_DOT = "\\."; //$NON-NLS-1$ 182 /** Regexp for java extension, i.e. "\.java$" */ 183 public final static String RE_JAVA_EXT = "\\" + DOT_JAVA + "$"; //$NON-NLS-1$ //$NON-NLS-2$ 184 /** Regexp for aidl extension, i.e. "\.aidl$" */ 185 public final static String RE_AIDL_EXT = "\\" + DOT_AIDL + "$"; //$NON-NLS-1$ //$NON-NLS-2$ 186 /** Regexp for rs extension, i.e. "\.rs$" */ 187 public final static String RE_RS_EXT = "\\" + DOT_RS + "$"; //$NON-NLS-1$ //$NON-NLS-2$ 188 /** Regexp for .d extension, i.e. "\.d$" */ 189 public final static String RE_DEP_EXT = "\\" + DOT_DEP + "$"; //$NON-NLS-1$ //$NON-NLS-2$ 190 191 /** 192 * Namespace pattern for the custom resource XML, i.e. "http://schemas.android.com/apk/res/%s" 193 * <p/> 194 * This string contains a %s. It must be combined with the desired Java package, e.g.: 195 * <pre> 196 * String.format(AndroidConstants.NS_CUSTOM_RESOURCES, "android"); 197 * String.format(AndroidConstants.NS_CUSTOM_RESOURCES, "com.test.mycustomapp"); 198 * </pre> 199 * 200 * Note: if you need an URI specifically for the "android" namespace, consider using 201 * {@link SdkConstants#NS_RESOURCES} instead. 202 */ 203 // TODO rename NS_CUSTOM_RESOURCES to NS_CUSTOM_RESOURCES_S (denoting it takes a %s) in 204 // another CL. 205 public final static String NS_CUSTOM_RESOURCES = "http://schemas.android.com/apk/res/%1$s"; //$NON-NLS-1$ 206 207 /** The package "android" as used in resource urls etc */ 208 public static final String ANDROID_PKG = "android"; //$NON-NLS-1$ 209 210 /** The old common plug-in ID. Please do not use for new features. */ 211 private static final String LEGACY_PLUGIN_ID = "com.android.ide.eclipse.common"; //$NON-NLS-1$ 212 213 /** Generic marker for ADT errors, only to be used in the {@link ResourceManagerBuilder} */ 214 public final static String MARKER_ADT = AdtPlugin.PLUGIN_ID + ".adtProblem"; //$NON-NLS-1$ 215 216 /** Marker for Android Target errors. 217 * This is not cleared on each like other markers. Instead, it's cleared 218 * when an AndroidClasspathContainerInitializer has succeeded in creating an 219 * AndroidClasspathContainer */ 220 public final static String MARKER_TARGET = AdtPlugin.PLUGIN_ID + ".targetProblem"; //$NON-NLS-1$ 221 222 /** aapt marker error when running the compile command, only to be used 223 * in {@link PreCompilerBuilder} */ 224 public final static String MARKER_AAPT_COMPILE = LEGACY_PLUGIN_ID + ".aaptProblem"; //$NON-NLS-1$ 225 226 /** XML marker error, only to be used in {@link PreCompilerBuilder} */ 227 public final static String MARKER_XML = LEGACY_PLUGIN_ID + ".xmlProblem"; //$NON-NLS-1$ 228 229 /** aidl marker error, only to be used in {@link PreCompilerBuilder} */ 230 public final static String MARKER_AIDL = LEGACY_PLUGIN_ID + ".aidlProblem"; //$NON-NLS-1$ 231 232 /** renderscript marker error, only to be used in {@link PreCompilerBuilder} */ 233 public final static String MARKER_RENDERSCRIPT = LEGACY_PLUGIN_ID + ".rsProblem"; //$NON-NLS-1$ 234 235 /** android marker error, only to be used in the Manifest parsing 236 * from the {@link PreCompilerBuilder} */ 237 public final static String MARKER_ANDROID = LEGACY_PLUGIN_ID + ".androidProblem"; //$NON-NLS-1$ 238 239 /** aapt marker error when running the package command, only to be used in 240 * {@link PostCompilerBuilder} */ 241 public final static String MARKER_AAPT_PACKAGE = LEGACY_PLUGIN_ID + ".aapt2Problem"; //$NON-NLS-1$ 242 243 /** final packaging error marker, only to be used in {@link PostCompilerBuilder} */ 244 public final static String MARKER_PACKAGING = AdtPlugin.PLUGIN_ID + ".packagingProblem"; //$NON-NLS-1$ 245 246 247 /** Name for the "type" marker attribute */ 248 public final static String MARKER_ATTR_TYPE = "android.type"; //$NON-NLS-1$ 249 /** Name for the "class" marker attribute */ 250 public final static String MARKER_ATTR_CLASS = "android.class"; //$NON-NLS-1$ 251 /** activity value for marker attribute "type" */ 252 public final static String MARKER_ATTR_TYPE_ACTIVITY = "activity"; //$NON-NLS-1$ 253 /** service value for marker attribute "type" */ 254 public final static String MARKER_ATTR_TYPE_SERVICE = "service"; //$NON-NLS-1$ 255 /** receiver value for marker attribute "type" */ 256 public final static String MARKER_ATTR_TYPE_RECEIVER = "receiver"; //$NON-NLS-1$ 257 /** provider value for marker attribute "type" */ 258 public final static String MARKER_ATTR_TYPE_PROVIDER = "provider"; //$NON-NLS-1$ 259 260 /** 261 * Preferred compiler level, i.e. "1.5". 262 */ 263 public final static String COMPILER_COMPLIANCE_PREFERRED = "1.5"; //$NON-NLS-1$ 264 /** 265 * List of valid compiler level, i.e. "1.5" and "1.6" 266 */ 267 public final static String[] COMPILER_COMPLIANCE = { 268 "1.5", //$NON-NLS-1$ 269 "1.6", //$NON-NLS-1$ 270 }; 271 272 /** The base URL where to find the Android class & manifest documentation */ 273 public static final String CODESITE_BASE_URL = "http://code.google.com/android"; //$NON-NLS-1$ 274 275 public static final String LIBRARY_TEST_RUNNER = "android.test.runner"; //$NON-NLS-1$ 276 } 277