- Make the distinction between the activity class name, manifest entry,
fully-qualified name, and tested activity for the template place-holders.
Test activity names now directly contain the full name (including the
"Test" prefix) instead of the template adding it.
This is required by the new 'create test-project'
- New action: create test-project
This requires a path to the main project. It reads the package, activity
name and target from the main project.
The activity is read from the manifest and can be in a more complex form
than previously expected (for instance .subpackage.MyClass, instead of
simply MyClass). This is what required the re-work the activity related
template place holders.
Options:
-m --main Location path of the project to test, relative to the new
project [required]
-n --name Project name
-p --path Location path of the new project [required]
Example: for 2 projects MyProject and MyTests located in the same folder,
calling from their parent folder.
android create test-project -p MyTests -m ../MyProject
- build.properties now only gets application.package for older targets
as the new one get it directly from XPath
- Remove AndroidXPathFactory from the anttasks project as it was already
in sdklib which is a dependency.
- Removed IntelliJ templates for the SDK. We haven't supported them for
a while, and now that IntelliJ has built-in support for Android, it's
not that useful anymore.
While there is the command line parameters for 'update test-project'
it's not yet implemented.
Change-Id: I663d4cb7f439bb2abfe866f893e58f4d13aff975
83 lines
2.5 KiB
Java
83 lines
2.5 KiB
Java
/*
|
|
* Copyright (C) 2009 The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package com.android.ant;
|
|
|
|
import com.android.sdklib.xml.AndroidXPathFactory;
|
|
|
|
import org.apache.tools.ant.BuildException;
|
|
import org.apache.tools.ant.Task;
|
|
import org.apache.tools.ant.types.Path;
|
|
import org.xml.sax.InputSource;
|
|
|
|
import java.io.FileInputStream;
|
|
import java.io.FileNotFoundException;
|
|
|
|
import javax.xml.xpath.XPath;
|
|
import javax.xml.xpath.XPathExpressionException;
|
|
|
|
/**
|
|
* Android specific XPath task.
|
|
* The goal is to get the result of an XPath expression on Android XML files. The android namespace
|
|
* (http://schemas.android.com/apk/res/android) must be associated to the "android" prefix.
|
|
*/
|
|
public class XPathTask extends Task {
|
|
|
|
private Path mManifestFile;
|
|
private String mProperty;
|
|
private String mExpression;
|
|
|
|
public void setInput(Path manifestFile) {
|
|
mManifestFile = manifestFile;
|
|
}
|
|
|
|
public void setOutput(String property) {
|
|
mProperty = property;
|
|
}
|
|
|
|
public void setExpression(String expression) {
|
|
mExpression = expression;
|
|
}
|
|
|
|
@Override
|
|
public void execute() throws BuildException {
|
|
try {
|
|
if (mManifestFile == null || mManifestFile.list().length == 0) {
|
|
throw new BuildException("input attribute is missing!");
|
|
}
|
|
|
|
if (mProperty == null) {
|
|
throw new BuildException("output attribute is missing!");
|
|
}
|
|
|
|
if (mExpression == null) {
|
|
throw new BuildException("expression attribute is missing!");
|
|
}
|
|
|
|
XPath xpath = AndroidXPathFactory.newXPath();
|
|
|
|
String file = mManifestFile.list()[0];
|
|
String result = xpath.evaluate(mExpression, new InputSource(new FileInputStream(file)));
|
|
|
|
getProject().setProperty(mProperty, result);
|
|
} catch (XPathExpressionException e) {
|
|
throw new BuildException(e);
|
|
} catch (FileNotFoundException e) {
|
|
throw new BuildException(e);
|
|
}
|
|
}
|
|
}
|