Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Jan 25, 2019. It is now read-only.

Commit 778cf34

Browse filesBrowse files
committed
WIP
1 parent c5760f9 commit 778cf34
Copy full SHA for 778cf34

File tree

Expand file treeCollapse file tree

3 files changed

+64
-4
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+64
-4
lines changed
Open diff view settings
Collapse file

‎build.sh‎

Copy file name to clipboardExpand all lines: build.sh
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ echo -e "\033[0;33m<< Version: $VERSION >>\033[0m"; \
2121

2222
# Build target/loader.jar which serves as foundation for boot.sh/exe
2323

24-
javac -d target src/Boot.java src/boot/bin/ParentClassLoader.java
24+
javac -d target src/Boot.java src/boot/bin/ParentClassLoader.java src/boot/bin/BootSnapshotVersionFetcher.java
2525
cp -r resources/* target/
2626
jar cef Boot target/loader.jar -C target/ .
2727

Collapse file

‎src/Boot.java‎

Copy file name to clipboardExpand all lines: src/Boot.java
+20-3Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// vim: et:ts=4:sw=4
22

33
import boot.bin.ParentClassLoader;
4+
import boot.bin.BootSnapshotVersionFetcher;
45

56
import java.io.*;
67
import java.net.*;
@@ -182,7 +183,14 @@ public class Boot {
182183

183184
public static String
184185
downloadUrl(String version, String name) throws Exception {
185-
return String.format("https://github.com/boot-clj/boot/releases/download/%s/%s", version, name); }
186+
System.out.println("passed name " + name + " compare result " + version.compareTo("2.8"));
187+
if (0 < version.compareTo("2.8") && name.equals("boot.jar")) {
188+
if (version.endsWith("SNAPSHOT")) {
189+
return String.format("https://clojars.org/repo/boot/base/%s/base-%s.jar", version, BootSnapshotVersionFetcher.lastSnapshot(version)); }
190+
else {
191+
return String.format("https://clojars.org/repo/boot/base/%s/base-%s.jar", version, version); }
192+
} else { // 2.7.2 and lower download releases from github
193+
return String.format("https://github.com/boot-clj/boot/releases/download/%s/%s", version, name); }}
186194

187195
public static File
188196
validateBinaryFile(File f) throws Exception {
@@ -224,7 +232,9 @@ public class Boot {
224232
String v = p.getProperty(version);
225233
String vv = (v == null) ? version : v;
226234
String nn = "boot." + ((v == null) ? "jar" : "sh");
227-
return download(downloadUrl(vv, nn), binaryFileCreate(vv)); }
235+
String url = downloadUrl(vv, nn);
236+
System.out.println("Downloading " + nn + " / " + vv + " from " + url);
237+
return download(url, binaryFileCreate(vv)); }
228238

229239
public static URLClassLoader
230240
loadJar(File jar) throws Exception {
@@ -249,9 +259,16 @@ public class Boot {
249259
System.setProperty("BOOT_VERSION", initialVersion);
250260
System.err.println("Running for the first time, BOOT_VERSION not set: updating to latest."); }
251261

262+
// System.err.println("Fetching Jar from clojars");
263+
// System.out.println(downloadUrl("2.8.0-SNAPSHOT", "boot.jar"));
264+
// System.out.println(downloadUrl("2.7.2-SNAPSHOT", "boot.jar"));
265+
// System.out.println(downloadUrl("2.7.2", "boot.jar"));
266+
// BootSnapshotVersionFetcher.lastSnapshot("2.8.0-SNAPSHOT");
267+
252268
loadJar(f);
253269
tccl(loader);
254270
Class c = Class.forName("boot.App", true, loader);
255271
Method m = c.getMethod("main", String[].class);
256272

257-
m.invoke(null, new Object[]{a}); }}
273+
m.invoke(null, new Object[]{a});
274+
}}
Collapse file
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package boot.bin;
2+
3+
import java.util.ArrayDeque;
4+
import java.util.Deque;
5+
import java.util.Arrays;
6+
import javax.xml.parsers.SAXParser;
7+
import javax.xml.parsers.SAXParserFactory;
8+
import org.xml.sax.Attributes;
9+
import org.xml.sax.SAXException;
10+
import org.xml.sax.helpers.DefaultHandler;
11+
12+
public class BootSnapshotVersionFetcher {
13+
14+
private static class MavenMetadataHandler extends DefaultHandler {
15+
String snapshotVersion;
16+
Deque<String> stack = new ArrayDeque<>();
17+
18+
String marker[] = {"value", "snapshotVersion", "snapshotVersions", "versioning", "metadata"};
19+
20+
public String getSnapshotVersion() {
21+
return snapshotVersion; }
22+
23+
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
24+
stack.push(qName); }
25+
26+
public void endElement(String uri, String localName, String qName) throws SAXException {
27+
stack.pop(); }
28+
29+
public void characters(char ch[], int start, int length) throws SAXException {
30+
if (Arrays.equals(stack.toArray(), marker) && snapshotVersion == null) {
31+
// String versionString = new String(ch, start, length);
32+
// System.out.println("version " + versionString);
33+
snapshotVersion = new String(ch, start, length); }}};
34+
35+
public static String lastSnapshot(String version) throws Exception {
36+
MavenMetadataHandler handler = new MavenMetadataHandler();
37+
try { SAXParserFactory factory = SAXParserFactory.newInstance();
38+
SAXParser saxParser = factory.newSAXParser();
39+
String metadataFile = String.format("https://clojars.org/repo/boot/base/%s/maven-metadata.xml", version);
40+
saxParser.parse(metadataFile, handler); }
41+
catch (Exception e) { e.printStackTrace(); }
42+
43+
return handler.getSnapshotVersion(); }}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.