ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/AntTasks/source/net/douglasthrift/anttasks/AndroidSDK.java
Revision: 1115
Committed: 2008-11-12T22:58:13-08:00 (16 years, 7 months ago) by douglas
File size: 1938 byte(s)
Log Message:
Android SDK! And unified taskdefs!

File Contents

# Content
1 // Android SDK
2 //
3 // Douglas Thrift
4 //
5 // $Id$
6
7 /* Copyright 2008 Douglas Thrift
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 */
21
22 package net.douglasthrift.anttasks;
23
24 import java.io.File;
25
26 import java.util.Iterator;
27
28 import org.apache.tools.ant.BuildException;
29 import org.apache.tools.ant.Project;
30 import org.apache.tools.ant.Task;
31 import org.apache.tools.ant.taskdefs.condition.Os;
32 import org.apache.tools.ant.types.Path;
33 import org.apache.tools.ant.types.resources.FileResource;
34 import org.apache.tools.ant.util.FileUtils;
35
36 public class AndroidSDK extends Task
37 {
38 private String property_;
39
40 public void setProperty(String property)
41 {
42 property_ = property;
43 }
44
45 @Override
46 public void execute()
47 {
48 if (property_ == null)
49 throw new BuildException("property not set");
50
51 Project project = getProject();
52
53 Path path = (Path)project.createDataType("path");
54
55 path.setPath(System.getenv("PATH"));
56
57 FileUtils utils = FileUtils.getFileUtils();
58
59 for (Iterator iterator = path.iterator(); iterator.hasNext();)
60 {
61 File file = ((FileResource)iterator.next()).getFile();
62
63 if (utils.resolveFile(file, Os.isFamily(Os.FAMILY_WINDOWS) ? "aapt.exe" : "aapt").isFile())
64 {
65 file = file.getParentFile();
66
67 if (new File(file, "android.jar").isFile())
68 {
69 project.setNewProperty(property_, file.toString());
70
71 return;
72 }
73 }
74 }
75
76 throw new BuildException("android sdk not found");
77 }
78 }

Properties

Name Value
svn:eol-style native
svn:keywords Id
svn:mergeinfo