|
1 /* |
|
2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 package com.nokia.helium.sysdef.ant.taskdefs; |
|
18 |
|
19 import java.io.File; |
|
20 |
|
21 import org.apache.tools.ant.BuildException; |
|
22 import org.apache.tools.ant.Project; |
|
23 |
|
24 import com.nokia.helium.core.FileUtils; |
|
25 |
|
26 /** |
|
27 * Utility class to access the system definition tools. |
|
28 * |
|
29 */ |
|
30 public final class SysdefUtils { |
|
31 public static final String SYSDEF_HOME_PROPERTY_NAME = "sysdef.tools.home"; |
|
32 private static final String ASSET_PATH = "sf/os/buildtools/bldsystemtools/sysdeftools"; |
|
33 |
|
34 private SysdefUtils() { |
|
35 } |
|
36 |
|
37 /** |
|
38 * Get the location of the the system definitions tools. |
|
39 * Use the SYSDEF_HOME_PROPERTY_NAME if it is defined. |
|
40 * Else it tries to search the joinsysdef script on the path, |
|
41 * and finally falls back on the ASSET_PATH location. |
|
42 * @param project the current Ant project. |
|
43 * @param epocroot the epocroot location. |
|
44 * @return a directory represented by a File object. |
|
45 */ |
|
46 public static File getSysdefHome(Project project, File epocroot) { |
|
47 if (project.getProperty(SYSDEF_HOME_PROPERTY_NAME) != null) { |
|
48 File dir = new File(project.getProperty(SYSDEF_HOME_PROPERTY_NAME)).getAbsoluteFile(); |
|
49 if (dir.exists() && dir.isDirectory()) { |
|
50 return dir; |
|
51 } else { |
|
52 throw new BuildException("The " + SYSDEF_HOME_PROPERTY_NAME + |
|
53 " property refers to an invalid directory: " + dir); |
|
54 } |
|
55 } else { |
|
56 File dir = FileUtils.findExecutableOnPath("joinsysdef"); |
|
57 if (dir != null) { |
|
58 return dir.getParentFile(); |
|
59 } |
|
60 // last resorts the asset location... |
|
61 dir = new File(epocroot, ASSET_PATH); |
|
62 if (!dir.exists() || !dir.isDirectory()) { |
|
63 throw new BuildException("Could not find system definition tools home."); |
|
64 } |
|
65 return dir; |
|
66 } |
|
67 } |
|
68 |
|
69 } |