Add support for 'android update test-project'.
This is only to be used to update the location of the main project. To update other properties, 'update project' can be used. Change-Id: I96ff44295460c7e331953263abccea17108d5a70
This commit is contained in:
@@ -239,6 +239,10 @@ public class Main {
|
||||
SdkCommandLine.OBJECT_PROJECT.equals(directObject)) {
|
||||
updateProject();
|
||||
|
||||
} else if (SdkCommandLine.VERB_UPDATE.equals(verb) &&
|
||||
SdkCommandLine.OBJECT_TEST_PROJECT.equals(directObject)) {
|
||||
updateTestProject();
|
||||
|
||||
} else if (verb == null && directObject == null) {
|
||||
showMainWindow();
|
||||
|
||||
@@ -345,7 +349,12 @@ public class Main {
|
||||
if (parentProject.isAbsolute() == false) {
|
||||
// if the path is not absolute, we need to resolve it based on the
|
||||
// destination path of the project
|
||||
parentProject = new File(projectDir, pathToMainProject);
|
||||
try {
|
||||
parentProject = new File(projectDir, pathToMainProject).getCanonicalFile();
|
||||
} catch (IOException e) {
|
||||
errorAndExit("Unable to resolve Main project's directory: %1$s",
|
||||
pathToMainProject);
|
||||
}
|
||||
}
|
||||
|
||||
if (parentProject.isDirectory() == false) {
|
||||
@@ -490,6 +499,21 @@ public class Main {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an existing test project with a new path to the main project.
|
||||
*/
|
||||
private void updateTestProject() {
|
||||
ProjectCreator creator = new ProjectCreator(mOsSdkFolder,
|
||||
mSdkCommandLine.isVerbose() ? OutputLevel.VERBOSE :
|
||||
mSdkCommandLine.isSilent() ? OutputLevel.SILENT :
|
||||
OutputLevel.NORMAL,
|
||||
mSdkLog);
|
||||
|
||||
String projectDir = getProjectLocation(mSdkCommandLine.getParamLocationPath());
|
||||
|
||||
creator.updateTestProject(projectDir, mSdkCommandLine.getParamTestProjectMain());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the project location to make it absolute & canonical relative to the
|
||||
* working directory, if any.
|
||||
|
||||
@@ -192,10 +192,10 @@ class SdkCommandLine extends CommandLineProcessor {
|
||||
VERB_UPDATE, OBJECT_PROJECT,
|
||||
"p", KEY_PATH,
|
||||
"Location path of the project", null);
|
||||
define(Mode.STRING, true,
|
||||
define(Mode.STRING, false,
|
||||
VERB_UPDATE, OBJECT_PROJECT,
|
||||
"t", KEY_TARGET_ID,
|
||||
"Target id to set for the project", -1);
|
||||
"Target id to set for the project", null);
|
||||
define(Mode.STRING, false,
|
||||
VERB_UPDATE, OBJECT_PROJECT,
|
||||
"n", KEY_NAME,
|
||||
@@ -214,7 +214,7 @@ class SdkCommandLine extends CommandLineProcessor {
|
||||
define(Mode.STRING, true,
|
||||
VERB_UPDATE, OBJECT_TEST_PROJECT,
|
||||
"m", KEY_MAIN_PROJECT,
|
||||
"Location path of the project to test", null);
|
||||
"Location path of the project to test, relative to the new project", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -290,6 +290,6 @@ class SdkCommandLine extends CommandLineProcessor {
|
||||
|
||||
/** Helper to retrieve the --main value. */
|
||||
public String getParamTestProjectMain() {
|
||||
return ((String) getValue(null, OBJECT_TEST_PROJECT, KEY_MAIN_PROJECT));
|
||||
return ((String) getValue(null, null, KEY_MAIN_PROJECT));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user