Skip to content

Commit ad2d3a3

Browse files
committed
[518053]Changes in config.xml related to platform are propagated to project
Bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=518053 Signed-off-by: Rastislav Wagner <[email protected]>
1 parent f874a3f commit ad2d3a3

File tree

47 files changed

+1069
-2024
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1069
-2024
lines changed

plugins/org.eclipse.thym.android.core/plugin.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@
1313
<extension
1414
point="org.eclipse.thym.core.platformSupport">
1515
<platform
16-
projectGenerator="org.eclipse.thym.android.core.adt.AndroidProjectGenerator"
1716
id="org.eclipse.thym.android.core.platformSupport"
1817
platform="Android"
1918
platformID="android"
20-
pluginInstallActionFactory="org.eclipse.thym.android.core.adt.AndroidPluginInstallationActionsFactory"
2119
libraryResolver="org.eclipse.thym.android.core.adt.AndroidLibraryResolver">
2220
</platform>
2321
</extension>

plugins/org.eclipse.thym.android.core/src/org/eclipse/thym/android/core/adt/AndroidLibraryResolver.java

Lines changed: 12 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -10,135 +10,31 @@
1010
*******************************************************************************/
1111
package org.eclipse.thym.android.core.adt;
1212

13-
import java.io.BufferedReader;
14-
import java.io.File;
15-
import java.io.FileReader;
16-
import java.io.IOException;
17-
import java.net.URL;
1813
import java.util.HashMap;
19-
import java.util.Iterator;
2014

2115
import org.eclipse.core.runtime.Assert;
22-
import org.eclipse.core.runtime.CoreException;
23-
import org.eclipse.core.runtime.IPath;
24-
import org.eclipse.core.runtime.IProgressMonitor;
25-
import org.eclipse.core.runtime.IStatus;
26-
import org.eclipse.core.runtime.Path;
27-
import org.eclipse.core.runtime.Status;
28-
import org.eclipse.osgi.util.NLS;
29-
import org.eclipse.thym.android.core.AndroidCore;
30-
import org.eclipse.thym.core.HybridCore;
3116
import org.eclipse.thym.core.engine.HybridMobileLibraryResolver;
32-
import org.eclipse.thym.core.internal.util.FileUtils;
17+
import org.eclipse.thym.core.platform.PlatformConstants;
3318

34-
import com.github.zafarkhaja.semver.Version;
35-
36-
public class AndroidLibraryResolver extends
37-
HybridMobileLibraryResolver {
38-
private static final Version VERSION_4_0_0 = Version.valueOf("4.0.0");
39-
40-
public static final String DIR_LIBS = "libs";
41-
public static final String DIR_RES = "res";
42-
public static final String DIR_SRC = "src";
19+
public class AndroidLibraryResolver extends HybridMobileLibraryResolver {
4320

44-
public static final String FILE_JAR_CORDOVA = "cordova.jar";
45-
private static final IPath KEY_PATH_CORDOVA_JAR = new Path(DIR_LIBS +"/" + FILE_JAR_CORDOVA);
46-
public static final String FILE_XML_ANDROIDMANIFEST = "AndroidManifest.xml";
21+
public static final String PROPERTIES="project.propeties";
4722

48-
HashMap<IPath, URL> files = new HashMap<IPath, URL>();
23+
HashMap<String, String> files = new HashMap<String, String>();
4924

5025
private void initFiles() {
51-
Assert.isNotNull(libraryRoot, "Library resolver is not initialized. Call init before accessing any other functions.");
52-
if(version == null ){
53-
return;
54-
}
55-
Version ver = Version.valueOf(version);
56-
57-
IPath templatePrjRoot = libraryRoot.append("bin/templates/project");
58-
IPath cordovaJar = libraryRoot.append("framework").append(NLS.bind("cordova-{0}.jar",version));
59-
files.put(KEY_PATH_CORDOVA_JAR, getEngineFile(cordovaJar));
60-
files.put(new Path(DIR_RES),getEngineFile(templatePrjRoot.append(DIR_RES)));
61-
files.put(new Path(FILE_XML_ANDROIDMANIFEST), getEngineFile(templatePrjRoot.append(FILE_XML_ANDROIDMANIFEST)));
62-
files.put(new Path(DIR_SRC).append(VAR_PACKAGE_NAME.replace('.', '/')).append(VAR_APP_NAME+".java"),
63-
getEngineFile(templatePrjRoot.append("Activity.java")));
64-
if(ver.lessThan(VERSION_4_0_0)){
65-
files.put(PATH_CORDOVA_JS, getEngineFile(libraryRoot.append("framework/assets/www/cordova.js")));
66-
}else{
67-
// version 4.0.0 places cordova.js to a new location
68-
files.put(PATH_CORDOVA_JS, getEngineFile(templatePrjRoot.append("assets/www/cordova.js")));
69-
}
70-
files.put(new Path("framework/project.properties"), getEngineFile(libraryRoot.append("framework/project.properties")));
71-
}
72-
73-
74-
@Override
75-
public URL getTemplateFile(IPath destination) {
76-
if(files.isEmpty()) initFiles();
77-
Assert.isNotNull(destination);
78-
Assert.isTrue(!destination.isAbsolute());
79-
return files.get(destination);
80-
}
81-
82-
@Override
83-
public IStatus isLibraryConsistent() {
84-
if(version == null ){
85-
return new Status(IStatus.ERROR, HybridCore.PLUGIN_ID, "Library for Android platform is not compatible with this tool. File for path {0} is missing.");
86-
}
87-
if(files.isEmpty()) initFiles();
88-
Iterator<IPath> paths = files.keySet().iterator();
89-
while (paths.hasNext()) {
90-
IPath key = paths.next();
91-
URL url = files.get(key);
92-
if(url != null ){
93-
File file = new File(url.getFile());
94-
if( file.exists() || key.equals(KEY_PATH_CORDOVA_JAR)){
95-
// we skip cordova.jar because it is generated by precompilation
96-
continue;
97-
}
98-
}
99-
return new Status(IStatus.ERROR, HybridCore.PLUGIN_ID, NLS.bind("Library for Android platform is not compatible with this tool. File for path {0} is missing.",key.toString()));
100-
}
101-
return Status.OK_STATUS;
102-
}
103-
104-
public void preCompile(IProgressMonitor monitor) throws CoreException{
105-
}
106-
107-
public boolean needsPreCompilation(){
108-
IPath cordovaJar = libraryRoot.append("framework").append(NLS.bind("cordova-{0}.jar",version));
109-
return !cordovaJar.toFile().exists();
110-
}
111-
112-
private URL getEngineFile(IPath path){
113-
File file = path.toFile();
114-
if(!file.exists()){
115-
AndroidCore.log(IStatus.WARNING, NLS.bind( "Missing Android engine file {0}", file.toString()), null );
116-
}
117-
return FileUtils.toURL(file);
26+
files.put(PROPERTIES, "android/project.properties");
27+
files.put(PlatformConstants.FILE_JS_CORDOVA, "android/assets/www/cordova.js");
11828
}
11929

12030

12131
@Override
122-
public String detectVersion() {
123-
File versionFile = this.libraryRoot.append("VERSION").toFile();
124-
if(versionFile.exists()){
125-
BufferedReader reader = null;
126-
try{
127-
try {
128-
reader = new BufferedReader(new FileReader(versionFile));
129-
String version = reader.readLine();
130-
return version;
131-
}
132-
finally{
133-
if(reader != null ) reader.close();
134-
}
135-
}catch (IOException e) {
136-
AndroidCore.log(IStatus.WARNING, "Can not detect version on library", e);
137-
}
138-
}else{
139-
AndroidCore.log(IStatus.WARNING, NLS.bind("Can not detect version. VERSION file {0} is missing",versionFile.toString()), null);
32+
public String getTemplateFile(String key) {
33+
if(files.isEmpty()){
34+
initFiles();
14035
}
141-
return null;
36+
Assert.isNotNull(key);
37+
return files.get(key);
14238
}
14339

144-
}
40+
}

0 commit comments

Comments
 (0)