本文整理汇总了Java中com.android.sdklib.IAndroidTarget.getPath方法的典型用法代码示例。如果您正苦于以下问题:Java IAndroidTarget.getPath方法的具体用法?Java IAndroidTarget.getPath怎么用?Java IAndroidTarget.getPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.android.sdklib.IAndroidTarget
的用法示例。
在下文中一共展示了IAndroidTarget.getPath方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installIcons
import com.android.sdklib.IAndroidTarget; //导入方法依赖的package包/类
/**
* Installs the project icons.
* @param resourceFolder the resource folder
* @param target the target of the project.
* @return true if any icon was installed.
*/
private boolean installIcons(File resourceFolder, IAndroidTarget target)
throws ProjectCreateException {
// query the target for its template directory
String templateFolder = target.getPath(IAndroidTarget.TEMPLATES);
boolean installedIcon = false;
installedIcon |= installIcon(templateFolder, "ic_launcher_xhdpi.png", resourceFolder,
"drawable-xhdpi");
installedIcon |= installIcon(templateFolder, "ic_launcher_hdpi.png", resourceFolder,
"drawable-hdpi");
installedIcon |= installIcon(templateFolder, "ic_launcher_mdpi.png", resourceFolder,
"drawable-mdpi");
installedIcon |= installIcon(templateFolder, "ic_launcher_ldpi.png", resourceFolder,
"drawable-ldpi");
return installedIcon;
}
示例2: SamplePackage
import com.android.sdklib.IAndroidTarget; //导入方法依赖的package包/类
private SamplePackage(IAndroidTarget target, Properties props) {
super( null, //source
props, //properties
0, //revision will be taken from props
null, //license
null, //description
null, //descUrl
target.getPath(IAndroidTarget.SAMPLES) //archiveOsPath
);
mVersion = target.getVersion();
mMinApiLevel = getPropertyInt(props, PkgProps.SAMPLE_MIN_API_LEVEL,
MIN_API_LEVEL_NOT_SPECIFIED);
mPkgDesc = PkgDesc.Builder
.newSample(mVersion,
(MajorRevision) getRevision(),
getMinToolsRevision())
.setDescriptions(this)
.create();
}
示例3: SamplePackage
import com.android.sdklib.IAndroidTarget; //导入方法依赖的package包/类
private SamplePackage(IAndroidTarget target, Properties props) {
super( null, //source
props, //properties
0, //revision will be taken from props
null, //license
null, //description
null, //descUrl
target.getPath(IAndroidTarget.SAMPLES) //archiveOsPath
);
mVersion = target.getVersion();
mMinApiLevel = getPropertyInt(props, PkgProps.SAMPLE_MIN_API_LEVEL,
MIN_API_LEVEL_NOT_SPECIFIED);
mPkgDesc = setDescriptions(PkgDesc.Builder
.newSample(mVersion, (MajorRevision) getRevision(), getMinToolsRevision()))
.create();
}
示例4: getTestTarget
import com.android.sdklib.IAndroidTarget; //导入方法依赖的package包/类
@Nullable
private IAndroidTarget getTestTarget(@NotNull ConfigurationManager configurationManager) {
String platformDir = getPlatformDir();
for (IAndroidTarget target : configurationManager.getTargets()) {
if (!ConfigurationManager.isLayoutLibTarget(target)) {
continue;
}
String path = target.getPath(IAndroidTarget.ANDROID_JAR);
if (path == null) {
continue;
}
File f = new File(path);
if (f.getParentFile() != null && f.getParentFile().getName().equals(platformDir)) {
return target;
}
}
return null;
}
示例5: execute
import com.android.sdklib.IAndroidTarget; //导入方法依赖的package包/类
@NotNull
public static Map<AndroidCompilerMessageKind, List<String>> execute(@NotNull IAndroidTarget target,
@NotNull String file,
@NotNull String outFile,
@NotNull String[] sourceRootPaths) throws IOException {
BuildToolInfo buildToolInfo = target.getBuildToolInfo();
if (buildToolInfo == null) {
return Collections.singletonMap(AndroidCompilerMessageKind.ERROR, Collections.singletonList("No Build Tools in the Android SDK."));
}
final List<String> commands = new ArrayList<String>();
final String frameworkAidlPath = target.getPath(IAndroidTarget.ANDROID_AIDL);
commands.add(buildToolInfo.getPath(BuildToolInfo.PathId.AIDL));
commands.add("-p" + frameworkAidlPath);
for (String path : sourceRootPaths) {
commands.add("-I" + path);
}
commands.add(file);
commands.add(outFile);
LOG.info(AndroidCommonUtils.command2string(commands));
return AndroidExecutionUtil.doExecute(ArrayUtil.toStringArray(commands));
}
示例6: getInstallFolder
import com.android.sdklib.IAndroidTarget; //导入方法依赖的package包/类
/**
* Computes a potential installation folder if an archive of this package were
* to be installed right away in the given SDK root.
* <p/>
* A sample package is typically installed in SDK/samples/android-"version".
* However if we can find a different directory that already has this sample
* version installed, we'll use that one.
*
* @param osSdkRoot The OS path of the SDK root folder.
* @param sdkManager An existing SDK manager to list current platforms and addons.
* @return A new {@link File} corresponding to the directory to use to install this package.
*/
@Override
public File getInstallFolder(String osSdkRoot, SdkManager sdkManager) {
// The /samples dir at the root of the SDK
File samplesRoot = new File(osSdkRoot, SdkConstants.FD_SAMPLES);
// First find if this sample is already installed. If so, reuse the same directory.
for (IAndroidTarget target : sdkManager.getTargets()) {
if (target.isPlatform() &&
target.getVersion().equals(mVersion)) {
String p = target.getPath(IAndroidTarget.SAMPLES);
File f = new File(p);
if (f.isDirectory()) {
// We *only* use this directory if it's using the "new" location
// under SDK/samples. We explicitly do not reuse the "old" location
// under SDK/platform/android-N/samples.
if (f.getParentFile().equals(samplesRoot)) {
return f;
}
}
}
}
// Otherwise, get a suitable default
File folder = new File(samplesRoot,
String.format("android-%s", getAndroidVersion().getApiString())); //$NON-NLS-1$
for (int n = 1; folder.exists(); n++) {
// Keep trying till we find an unused directory.
folder = new File(samplesRoot,
String.format("android-%s_%d", getAndroidVersion().getApiString(), n)); //$NON-NLS-1$
}
return folder;
}
示例7: getSkinFolder
import com.android.sdklib.IAndroidTarget; //导入方法依赖的package包/类
/**
* Returns the full absolute OS path to a skin specified by name for a given target.
* @param skinName The name of the skin to find. Case-sensitive.
* @param target The target where to find the skin.
* @return a {@link File} that may or may not actually exist.
*/
private File getSkinFolder(@NonNull String skinName, @NonNull IAndroidTarget target) {
String path = target.getPath(IAndroidTarget.SKINS);
File skin = new File(path, skinName);
if (skin.exists() == false && target.isPlatform() == false) {
target = target.getParent();
path = target.getPath(IAndroidTarget.SKINS);
skin = new File(path, skinName);
}
return skin;
}
示例8: compileAidlFile
import com.android.sdklib.IAndroidTarget; //导入方法依赖的package包/类
/**
* Compiles the given aidl file.
*
* @param aidlFile the AIDL file to compile
* @param sourceOutputDir the output dir in which to generate the source code
* @param importFolders all the import folders, including the source folders.
* @param dependencyFileProcessor the dependencyFileProcessor to record the dependencies
* of the compilation.
* @throws IOException
* @throws InterruptedException
* @throws LoggedErrorException
*/
public void compileAidlFile(@NonNull File sourceFolder,
@NonNull File aidlFile,
@NonNull File sourceOutputDir,
@Nullable File parcelableOutputDir,
@NonNull List<File> importFolders,
@Nullable DependencyFileProcessor dependencyFileProcessor)
throws IOException, InterruptedException, LoggedErrorException, ProcessException {
checkNotNull(aidlFile, "aidlFile cannot be null.");
checkNotNull(sourceOutputDir, "sourceOutputDir cannot be null.");
checkNotNull(importFolders, "importFolders cannot be null.");
checkState(mTargetInfo != null,
"Cannot call compileAidlFile() before setTargetInfo() is called.");
IAndroidTarget target = mTargetInfo.getTarget();
BuildToolInfo buildToolInfo = mTargetInfo.getBuildTools();
String aidl = buildToolInfo.getPath(BuildToolInfo.PathId.AIDL);
if (aidl == null || !new File(aidl).isFile()) {
throw new IllegalStateException("aidl is missing");
}
AidlProcessor processor = new AidlProcessor(
aidl,
target.getPath(IAndroidTarget.ANDROID_AIDL),
importFolders,
sourceOutputDir,
parcelableOutputDir,
dependencyFileProcessor != null ?
dependencyFileProcessor : sNoOpDependencyFileProcessor,
mProcessExecutor,
mProcessOutputHandler);
processor.processFile(sourceFolder, aidlFile);
}
示例9: findPlatformSources
import com.android.sdklib.IAndroidTarget; //导入方法依赖的package包/类
/**
* Finds the root source code folder for the given android target, if any
*/
@Nullable
public static File findPlatformSources(@NotNull IAndroidTarget target) {
String path = target.getPath(IAndroidTarget.SOURCES);
if (path != null) {
File platformSource = new File(path);
if (platformSource.isDirectory()) {
return platformSource;
}
}
return null;
}
示例10: getInstallFolder
import com.android.sdklib.IAndroidTarget; //导入方法依赖的package包/类
/**
* Computes a potential installation folder if an archive of this package were
* to be installed right away in the given SDK root.
* <p/>
* A sample package is typically installed in SDK/samples/android-"version".
* However if we can find a different directory that already has this sample
* version installed, we'll use that one.
*
* @param osSdkRoot The OS path of the SDK root folder.
* @param sdkManager An existing SDK manager to list current platforms and addons.
* @return A new {@link File} corresponding to the directory to use to install this package.
*/
@Override
public File getInstallFolder(String osSdkRoot, SdkManager sdkManager) {
// The /samples dir at the root of the SDK
File samplesRoot = new File(osSdkRoot, SdkConstants.FD_SAMPLES);
// First find if this sample is already installed. If so, reuse the same directory.
for (IAndroidTarget target : sdkManager.getTargets()) {
if (target.isPlatform() && target.getVersion().equals(getAndroidVersion())) {
String p = target.getPath(IAndroidTarget.SAMPLES);
File f = new File(p);
if (f.isDirectory()) {
// We *only* use this directory if it's using the "new" location
// under SDK/samples. We explicitly do not reuse the "old" location
// under SDK/platform/android-N/samples.
if (f.getParentFile().equals(samplesRoot)) {
return f;
}
}
}
}
// Otherwise, get a suitable default
File folder = new File(samplesRoot, String.format("android-%s", getAndroidVersion().getApiString())); //$NON-NLS-1$
for (int n = 1; folder.exists(); n++) {
// Keep trying till we find an unused directory.
folder = new File(samplesRoot, String.format("android-%s_%d", getAndroidVersion().getApiString(), n)); //$NON-NLS-1$
}
return folder;
}
示例11: compileAllAidlFiles
import com.android.sdklib.IAndroidTarget; //导入方法依赖的package包/类
/**
* Compiles all the aidl files found in the given source folders.
*
* @param sourceFolders all the source folders to find files to compile
* @param sourceOutputDir the output dir in which to generate the source code
* @param importFolders import folders
* @param dependencyFileProcessor the dependencyFileProcessor to record the dependencies
* of the compilation.
* @throws IOException
* @throws InterruptedException
* @throws LoggedErrorException
*/
public void compileAllAidlFiles(@NonNull List<File> sourceFolders,
@NonNull File sourceOutputDir,
@Nullable File parcelableOutputDir,
@NonNull List<File> importFolders,
@Nullable DependencyFileProcessor dependencyFileProcessor)
throws IOException, InterruptedException, LoggedErrorException, ProcessException {
checkNotNull(sourceFolders, "sourceFolders cannot be null.");
checkNotNull(sourceOutputDir, "sourceOutputDir cannot be null.");
checkNotNull(importFolders, "importFolders cannot be null.");
checkState(mTargetInfo != null,
"Cannot call compileAllAidlFiles() before setTargetInfo() is called.");
IAndroidTarget target = mTargetInfo.getTarget();
BuildToolInfo buildToolInfo = mTargetInfo.getBuildTools();
String aidl = buildToolInfo.getPath(BuildToolInfo.PathId.AIDL);
if (aidl == null || !new File(aidl).isFile()) {
throw new IllegalStateException("aidl is missing");
}
List<File> fullImportList = Lists.newArrayListWithCapacity(
sourceFolders.size() + importFolders.size());
fullImportList.addAll(sourceFolders);
fullImportList.addAll(importFolders);
AidlProcessor processor = new AidlProcessor(
aidl,
target.getPath(IAndroidTarget.ANDROID_AIDL),
fullImportList,
sourceOutputDir,
parcelableOutputDir,
dependencyFileProcessor != null ?
dependencyFileProcessor : sNoOpDependencyFileProcessor,
mProcessExecutor,
mProcessOutputHandler);
SourceSearcher searcher = new SourceSearcher(sourceFolders, "aidl");
searcher.setUseExecutor(true);
searcher.search(processor);
}
示例12: getLibraryRootsForTarget
import com.android.sdklib.IAndroidTarget; //导入方法依赖的package包/类
@NotNull
public static List<OrderRoot> getLibraryRootsForTarget(@NotNull IAndroidTarget target,
@Nullable String sdkPath,
boolean addPlatformAndAddOnJars) {
List<OrderRoot> result = Lists.newArrayList();
if (addPlatformAndAddOnJars) {
for (VirtualFile file : getPlatformAndAddOnJars(target)) {
result.add(new OrderRoot(file, CLASSES));
}
}
VirtualFile platformDir = getPlatformDir(target);
if (platformDir == null) return result;
VirtualFile targetDir = platformDir;
if (!target.isPlatform()) {
targetDir = findFileInLocalFileSystem(target.getLocation());
}
boolean docsOrSourcesFound = false;
if (targetDir != null) {
docsOrSourcesFound = addJavaDocAndSources(result, targetDir);
}
VirtualFile sdkDir = sdkPath != null ? findFileInLocalFileSystem(sdkPath) : null;
VirtualFile sourcesDir = null;
if (sdkDir != null) {
docsOrSourcesFound = addJavaDocAndSources(result, sdkDir) || docsOrSourcesFound;
sourcesDir = sdkDir.findChild(FD_PKG_SOURCES);
}
// todo: replace it by target.getPath(SOURCES) when it'll be up to date
if (sourcesDir != null && sourcesDir.isDirectory()) {
VirtualFile platformSourcesDir = sourcesDir.findChild(platformDir.getName());
if (platformSourcesDir != null && platformSourcesDir.isDirectory()) {
result.add(new OrderRoot(platformSourcesDir, SOURCES));
docsOrSourcesFound = true;
}
}
if (!docsOrSourcesFound) {
VirtualFile javadoc = VirtualFileManager.getInstance().findFileByUrl(DEFAULT_EXTERNAL_DOCUMENTATION_URL);
if (javadoc != null) {
result.add(new OrderRoot(javadoc, JavadocOrderRootType.getInstance()));
}
}
String resFolderPath = target.getPath(RESOURCES);
if (resFolderPath != null) {
VirtualFile resFolder = findFileInLocalFileSystem(resFolderPath);
if (resFolder != null) {
result.add(new OrderRoot(resFolder, CLASSES));
}
}
// Explicitly add annotations.jar unless the target platform already provides it (API16+).
if (sdkPath != null && needsAnnotationsJarInClasspath(target)) {
String annotationsJarPath = toSystemIndependentName(sdkPath) + ANNOTATIONS_JAR_RELATIVE_PATH;
VirtualFile annotationsJar = findFileInJarFileSystem(annotationsJarPath);
if (annotationsJar != null) {
result.add(new OrderRoot(annotationsJar, CLASSES));
}
}
return result;
}
示例13: installTargetTemplate
import com.android.sdklib.IAndroidTarget; //导入方法依赖的package包/类
/**
* Installs a new file that is based on a template file provided by a given target.
* Each match of each key from the place-holder map in the template will be replaced with its
* corresponding value in the created file.
*
* @param templateName the name of to the template file
* @param destFile the path to the destination file, relative to the project
* @param placeholderMap a map of (place-holder, value) to create the file from the template.
* @param target the Target of the project that will be providing the template.
* @throws ProjectCreateException
*/
private void installTargetTemplate(String templateName, File destFile,
Map<String, String> placeholderMap, IAndroidTarget target)
throws ProjectCreateException {
// query the target for its template directory
String templateFolder = target.getPath(IAndroidTarget.TEMPLATES);
final String sourcePath = templateFolder + File.separator + templateName;
installFullPathTemplate(sourcePath, destFile, placeholderMap);
}