Skip to content
This repository was archived by the owner on Jul 4, 2023. It is now read-only.

Commit 788549a

Browse files
author
Matt York
committed
- Added support for static gear installation
1 parent c9c7135 commit 788549a

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

AndroidGears/src/Utilities/GearSpecManager.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,18 @@ public static Boolean installJar(GearSpec spec, Project project, Module module){
178178
}
179179

180180
//Build jar file
181-
File jarFile = new File(libsDirectory.getAbsolutePath()+Utils.pathSeparator()+Utils.jarFileNameForSpecSource(spec.getSource()));
181+
File jarFile = new File(libsDirectory.getAbsolutePath() + pathSeparator + Utils.jarFileNameForSpecSource(spec.getSource()));
182182

183183
//Build url for gear
184-
String jarUrl = spec.getSource().getUrl()+"/raw/"+spec.getSource().getTag()+"/"+spec.getSource().getSource_files();
185-
jarUrl = jarUrl.replace(".git", "");
184+
String jarUrl;
185+
186+
if(spec.getSource().getUrl().toLowerCase().contains(".jar")){
187+
jarUrl = spec.getSource().getUrl();
188+
}
189+
else {
190+
jarUrl = spec.getSource().getUrl()+"/raw/"+spec.getSource().getTag()+"/"+spec.getSource().getSource_files();
191+
jarUrl = jarUrl.replace(".git", "");
192+
}
186193

187194
//Download file
188195
try {

AndroidGears/src/Utilities/Utils.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,20 @@ public static String[] versionsForProject(String project){
9999
}
100100

101101
public static String jarFileNameForSpecSource(GearSpecSource source){
102-
if (source.getSource_files().contains("/")){
103-
int lastPathSeparatorIndex = source.getSource_files().lastIndexOf("/");
104-
String fileName = source.getSource_files().substring(lastPathSeparatorIndex+1);
102+
103+
//Get element with jar name in it
104+
String sourceString;
105+
if(source.getUrl().toLowerCase().contains(".jar")){
106+
sourceString = source.getUrl();
107+
}
108+
else {
109+
sourceString = source.getSource_files();
110+
}
111+
112+
//Parse out jar name
113+
if (sourceString.contains("/")){
114+
int lastPathSeparatorIndex = sourceString.lastIndexOf("/");
115+
String fileName = sourceString.substring(lastPathSeparatorIndex+1);
105116

106117
return fileName;
107118
}

0 commit comments

Comments
 (0)