Home | History | Annotate | Download | only in adt
      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.ide.eclipse.adt.internal.build.PostCompilerBuilder;
     20 import com.android.ide.eclipse.adt.internal.build.PreCompilerBuilder;
     21 import com.android.ide.eclipse.adt.internal.build.ResourceManagerBuilder;
     22 import com.android.sdklib.SdkConstants;
     23 
     24 import java.io.File;
     25 import java.util.regex.Pattern;
     26 
     27 /**
     28  * Constant definition class.<br>
     29  * <br>
     30  * Most constants have a prefix defining the content.
     31  * <ul>
     32  * <li><code>WS_</code> Workspace path constant. Those are absolute paths,
     33  * from the project root.</li>
     34  * <li><code>OS_</code> OS path constant. These paths are different depending on the platform.</li>
     35  * <li><code>FN_</code> File name constant.</li>
     36  * <li><code>FD_</code> Folder name constant.</li>
     37  * <li><code>MARKER_</code> Resource Marker Ids constant.</li>
     38  * <li><code>EXT_</code> File extension constant. This does NOT include a dot.</li>
     39  * <li><code>DOT_</code> File extension constant. This start with a dot.</li>
     40  * <li><code>RE_</code> Regexp constant.</li>
     41  * <li><code>NS_</code> Namespace constant.</li>
     42  * <li><code>CLASS_</code> Fully qualified class name.</li>
     43  * </ul>
     44  *
     45  */
     46 public class AndroidConstants {
     47     /**
     48      * The old Editors Plugin ID. It is still used in some places for compatibility.
     49      * Please do not use for new features.
     50      */
     51     public static final String EDITORS_NAMESPACE = "com.android.ide.eclipse.editors"; // $NON-NLS-1$
     52 
     53     /** Nature of default Android projects */
     54     public final static String NATURE_DEFAULT = "com.android.ide.eclipse.adt.AndroidNature"; //$NON-NLS-1$
     55     /** Nature of Android export projects */
     56     public final static String NATURE_EXPORT = "com.android.ide.eclipse.adt.AndroidExportNature"; //$NON-NLS-1$
     57 
     58     /** Separator for workspace path, i.e. "/". */
     59     public final static String WS_SEP = "/"; //$NON-NLS-1$
     60     /** Separator character for workspace path, i.e. '/'. */
     61     public final static char WS_SEP_CHAR = '/';
     62 
     63     /** Extension of the Application package Files, i.e. "apk". */
     64     public final static String EXT_ANDROID_PACKAGE = "apk"; //$NON-NLS-1$
     65     /** Extension of java files, i.e. "java" */
     66     public final static String EXT_JAVA = "java"; //$NON-NLS-1$
     67     /** Extension of compiled java files, i.e. "class" */
     68     public final static String EXT_CLASS = "class"; //$NON-NLS-1$
     69     /** Extension of xml files, i.e. "xml" */
     70     public final static String EXT_XML = "xml"; //$NON-NLS-1$
     71     /** Extension of jar files, i.e. "jar" */
     72     public final static String EXT_JAR = "jar"; //$NON-NLS-1$
     73     /** Extension of aidl files, i.e. "aidl" */
     74     public final static String EXT_AIDL = "aidl"; //$NON-NLS-1$
     75     /** Extension of native libraries, i.e. "so" */
     76     public final static String EXT_NATIVE_LIB = "so"; //$NON-NLS-1$
     77 
     78     private final static String DOT = "."; //$NON-NLS-1$
     79 
     80     /** Dot-Extension of the Application package Files, i.e. ".apk". */
     81     public final static String DOT_ANDROID_PACKAGE = DOT + EXT_ANDROID_PACKAGE;
     82     /** Dot-Extension of java files, i.e. ".java" */
     83     public final static String DOT_JAVA = DOT + EXT_JAVA;
     84     /** Dot-Extension of compiled java files, i.e. ".class" */
     85     public final static String DOT_CLASS = DOT + EXT_CLASS;
     86     /** Dot-Extension of xml files, i.e. ".xml" */
     87     public final static String DOT_XML = DOT + EXT_XML;
     88     /** Dot-Extension of jar files, i.e. ".jar" */
     89     public final static String DOT_JAR = DOT + EXT_JAR;
     90     /** Dot-Extension of aidl files, i.e. ".aidl" */
     91     public final static String DOT_AIDL = DOT + EXT_AIDL;
     92 
     93     /** Name of the android sources directory */
     94     public static final String FD_ANDROID_SOURCES = "sources"; //$NON-NLS-1$
     95 
     96     /** Resource base name for java files and classes */
     97     public final static String FN_RESOURCE_BASE = "R"; //$NON-NLS-1$
     98     /** Resource java class  filename, i.e. "R.java" */
     99     public final static String FN_RESOURCE_CLASS = FN_RESOURCE_BASE + DOT_JAVA;
    100     /** Resource class file  filename, i.e. "R.class" */
    101     public final static String FN_COMPILED_RESOURCE_CLASS = FN_RESOURCE_BASE + DOT_CLASS;
    102     /** Manifest java class filename, i.e. "Manifest.java" */
    103     public final static String FN_MANIFEST_CLASS = "Manifest.java"; //$NON-NLS-1$
    104     /** Temporary packaged resources file name, i.e. "resources.ap_" */
    105     public final static String FN_RESOURCES_AP_ = "resources.ap_"; //$NON-NLS-1$
    106     /** Temporary packaged resources file name for a specific set of configuration */
    107     public final static String FN_RESOURCES_S_AP_ = "resources-%s.ap_"; //$NON-NLS-1$
    108     public final static Pattern PATTERN_RESOURCES_S_AP_ =
    109         Pattern.compile("resources-.*\\.ap_", Pattern.CASE_INSENSITIVE); //$NON-NLS-1$
    110 
    111     public final static String FN_TRACEVIEW =
    112         (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_WINDOWS) ?
    113             "traceview.exe" : "traceview"; //$NON-NLS-1$ //$NON-NLS-2$
    114 
    115     /** Absolute path of the workspace root, i.e. "/" */
    116     public final static String WS_ROOT = WS_SEP;
    117 
    118     /** Absolute path of the resource folder, eg "/res".<br> This is a workspace path. */
    119     public final static String WS_RESOURCES = WS_SEP + SdkConstants.FD_RESOURCES;
    120 
    121     /** Absolute path of the resource folder, eg "/assets".<br> This is a workspace path. */
    122     public final static String WS_ASSETS = WS_SEP + SdkConstants.FD_ASSETS;
    123 
    124     /** Leaf of the javaDoc folder. Does not start with a separator. */
    125     public final static String WS_JAVADOC_FOLDER_LEAF = SdkConstants.FD_DOCS + "/" + //$NON-NLS-1$
    126             SdkConstants.FD_DOCS_REFERENCE;
    127 
    128     /** Path of the samples directory relative to the sdk folder.
    129      *  This is an OS path, ending with a separator.
    130      *  FIXME: remove once the NPW is fixed. */
    131     public final static String OS_SDK_SAMPLES_FOLDER = SdkConstants.FD_SAMPLES + File.separator;
    132 
    133     public final static String RE_DOT = "\\."; //$NON-NLS-1$
    134     /** Regexp for java extension, i.e. "\.java$" */
    135     public final static String RE_JAVA_EXT = "\\.java$"; //$NON-NLS-1$
    136     /** Regexp for aidl extension, i.e. "\.aidl$" */
    137     public final static String RE_AIDL_EXT = "\\.aidl$"; //$NON-NLS-1$
    138 
    139     /**
    140      * Namespace pattern for the custom resource XML, i.e. "http://schemas.android.com/apk/res/%s"
    141      * <p/>
    142      * This string contains a %s. It must be combined with the desired Java package, e.g.:
    143      * <pre>
    144      *    String.format(AndroidConstants.NS_CUSTOM_RESOURCES, "android");
    145      *    String.format(AndroidConstants.NS_CUSTOM_RESOURCES, "com.test.mycustomapp");
    146      * </pre>
    147      *
    148      * Note: if you need an URI specifically for the "android" namespace, consider using
    149      * {@link SdkConstants#NS_RESOURCES} instead.
    150      */
    151     // TODO rename NS_CUSTOM_RESOURCES to NS_CUSTOM_RESOURCES_S (denoting it takes a %s) in
    152     // another CL.
    153     public final static String NS_CUSTOM_RESOURCES = "http://schemas.android.com/apk/res/%1$s"; //$NON-NLS-1$
    154 
    155     /** The old common plug-in ID. Please do not use for new features. */
    156     private static final String LEGACY_PLUGIN_ID = "com.android.ide.eclipse.common"; //$NON-NLS-1$
    157 
    158     /** Generic marker for ADT errors, only to be used in the {@link ResourceManagerBuilder} */
    159     public final static String MARKER_ADT = AdtPlugin.PLUGIN_ID + ".adtProblem"; //$NON-NLS-1$
    160 
    161     /** Marker for Android Target errors.
    162      * This is not cleared on each like other markers. Instead, it's cleared
    163      * when an AndroidClasspathContainerInitializer has succeeded in creating an
    164      * AndroidClasspathContainer */
    165     public final static String MARKER_TARGET = AdtPlugin.PLUGIN_ID + ".targetProblem"; //$NON-NLS-1$
    166 
    167     /** aapt marker error when running the compile command, only to be used
    168      * in {@link PreCompilerBuilder} */
    169     public final static String MARKER_AAPT_COMPILE = LEGACY_PLUGIN_ID + ".aaptProblem"; //$NON-NLS-1$
    170 
    171     /** XML marker error, only to be used in {@link PreCompilerBuilder} */
    172     public final static String MARKER_XML = LEGACY_PLUGIN_ID + ".xmlProblem"; //$NON-NLS-1$
    173 
    174     /** aidl marker error, only to be used in {@link PreCompilerBuilder} */
    175     public final static String MARKER_AIDL = LEGACY_PLUGIN_ID + ".aidlProblem"; //$NON-NLS-1$
    176 
    177     /** android marker error, only to be used in the Manifest parsing
    178      * from the {@link PreCompilerBuilder} */
    179     public final static String MARKER_ANDROID = LEGACY_PLUGIN_ID + ".androidProblem"; //$NON-NLS-1$
    180 
    181     /** aapt marker error when running the package command, only to be used in {@link PostCompilerBuilder} */
    182     public final static String MARKER_AAPT_PACKAGE = LEGACY_PLUGIN_ID + ".aapt2Problem"; //$NON-NLS-1$
    183 
    184     /** final packaging error marker, only to be used in {@link PostCompilerBuilder} */
    185     public final static String MARKER_PACKAGING = AdtPlugin.PLUGIN_ID + ".packagingProblem"; //$NON-NLS-1$
    186 
    187 
    188     /** Name for the "type" marker attribute */
    189     public final static String MARKER_ATTR_TYPE = "android.type"; //$NON-NLS-1$
    190     /** Name for the "class" marker attribute */
    191     public final static String MARKER_ATTR_CLASS = "android.class"; //$NON-NLS-1$
    192     /** activity value for marker attribute "type" */
    193     public final static String MARKER_ATTR_TYPE_ACTIVITY = "activity"; //$NON-NLS-1$
    194     /** service value for marker attribute "type" */
    195     public final static String MARKER_ATTR_TYPE_SERVICE = "service"; //$NON-NLS-1$
    196     /** receiver value for marker attribute "type" */
    197     public final static String MARKER_ATTR_TYPE_RECEIVER = "receiver"; //$NON-NLS-1$
    198     /** provider value for marker attribute "type" */
    199     public final static String MARKER_ATTR_TYPE_PROVIDER = "provider"; //$NON-NLS-1$
    200 
    201     public final static String CLASS_BRIDGE = "com.android.layoutlib.bridge.Bridge"; //$NON-NLS-1$
    202 
    203     /**
    204      * Prefered compiler level, i.e. "1.5".
    205      */
    206     public final static String COMPILER_COMPLIANCE_PREFERRED = "1.5"; //$NON-NLS-1$
    207     /**
    208      * List of valid compiler level, i.e. "1.5" and "1.6"
    209      */
    210     public final static String[] COMPILER_COMPLIANCE = {
    211         "1.5", //$NON-NLS-1$
    212         "1.6", //$NON-NLS-1$
    213     };
    214 
    215     /** The base URL where to find the Android class & manifest documentation */
    216     public static final String CODESITE_BASE_URL = "http://code.google.com/android";  //$NON-NLS-1$
    217 
    218     public static final String LIBRARY_TEST_RUNNER = "android.test.runner"; // $NON-NLS-1$
    219 }
    220