mirror of
https://github.com/processing/processing4.git
synced 2026-02-03 05:39:18 +01:00
finish JRE downloader
This commit is contained in:
7
build/jre/.classpath
Normal file
7
build/jre/.classpath
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="/processing-app/lib/ant.jar"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
3
build/jre/.gitignore
vendored
Normal file
3
build/jre/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
bin
|
||||
downloader.jar
|
||||
|
||||
17
build/jre/.project
Normal file
17
build/jre/.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>processing-jre</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,31 +1,36 @@
|
||||
<project name="methods" default="task-lib">
|
||||
<project name="downloader" default="dist">
|
||||
|
||||
<target name="compile">
|
||||
<mkdir dir="bin" />
|
||||
|
||||
<javac target="1.7"
|
||||
srcdir="src" destdir="bin"
|
||||
<javac source="1.7"
|
||||
target="1.7"
|
||||
srcdir="src"
|
||||
destdir="bin"
|
||||
debug="true"
|
||||
includeantruntime="true"
|
||||
nowarn="true"
|
||||
compiler="org.eclipse.jdt.core.JDTCompilerAdapter">
|
||||
<compilerclasspath path="../../java/mode/ecj.jar" />
|
||||
<compilerclasspath path="../../java/mode/org.eclipse.jdt.core.jar;
|
||||
../../java/mode/jdtCompilerAdapter.jar" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="task-lib" depends="compile">
|
||||
<target name="dist" depends="compile">
|
||||
<jar basedir="bin" destfile="downloader.jar" />
|
||||
</target>
|
||||
|
||||
<target name="demo">
|
||||
<target name="demo" depends="dist">
|
||||
<taskdef name="downloader"
|
||||
classname="Downloader"
|
||||
classpath="downloader.jar" />
|
||||
<preproc dir="demo"/>
|
||||
<downloader version="8" update="31" build="13"
|
||||
jdk="true" flavor="macosx-x64.dmg" />
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="bin" />
|
||||
<delete file="downloader.jar" />
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
||||
@@ -14,14 +14,19 @@ public class Downloader extends Task {
|
||||
"gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; " +
|
||||
"oraclelicense=accept-securebackup-cookie";
|
||||
|
||||
private int version;
|
||||
private int update;
|
||||
private int build;
|
||||
private int version; // Java 8
|
||||
private int update; // Update 31
|
||||
private int build; // Build 13
|
||||
|
||||
private boolean jdk;
|
||||
private boolean jdk; // false if JRE
|
||||
|
||||
private File baseDir;
|
||||
private boolean includeRecorder;
|
||||
// private String platform; // macosx, windows, linux
|
||||
// private String bits; // i586 or x64
|
||||
private String flavor;
|
||||
|
||||
private String path; // target path
|
||||
// private File baseDir;
|
||||
// private boolean includeRecorder;
|
||||
|
||||
|
||||
public Downloader() { }
|
||||
@@ -45,13 +50,50 @@ public class Downloader extends Task {
|
||||
public void setJDK(boolean jdk) {
|
||||
this.jdk = jdk;
|
||||
}
|
||||
|
||||
|
||||
// public void setPlatform(String platform) {
|
||||
// this.platform = platform;
|
||||
// }
|
||||
|
||||
|
||||
// public void setBits(String bits) {
|
||||
// this.bits = bits;
|
||||
// }
|
||||
|
||||
public void setFlavor(String flavor) {
|
||||
this.flavor = flavor;
|
||||
}
|
||||
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
|
||||
public void execute() throws BuildException {
|
||||
//if (baseDir == null) {
|
||||
// throw new BuildException("dir parameter must be set!");
|
||||
//}
|
||||
|
||||
if (version == 0) {
|
||||
throw new BuildException("version (i.e. 7 or 8) must be set");
|
||||
}
|
||||
|
||||
if (build == 0) {
|
||||
throw new BuildException("build number must be set");
|
||||
}
|
||||
|
||||
if (flavor == null) {
|
||||
throw new BuildException("you've gotta choose a flavor (macosx-x64.dmg, windows-x64.exe...");
|
||||
}
|
||||
// if (bits == null) {
|
||||
// throw new BuildException("bits must be set (x64 or i586)");
|
||||
// }
|
||||
|
||||
//download(path, jdk, platform, bits, version, update, build);
|
||||
download();
|
||||
|
||||
/*
|
||||
downloadJRE("linux-i586.tar.gz");
|
||||
downloadJRE("linux-x64.tar.gz");
|
||||
@@ -71,16 +113,20 @@ public class Downloader extends Task {
|
||||
}
|
||||
|
||||
|
||||
static void download(File folder, String filename,
|
||||
boolean jre, String platform,
|
||||
int version, int update, int build) {
|
||||
// static void download(String path, //File folder, String filename,
|
||||
// boolean jdk, String platform, String bits,
|
||||
// int version, int update, int build) {
|
||||
void download() {
|
||||
//HttpURLConnection.setFollowRedirects(true);
|
||||
if (filename == null) {
|
||||
filename = (jre ? "jre" : "jdk") +
|
||||
String filename = (jdk ? "jdk" : "jre") +
|
||||
(update == 0 ?
|
||||
String.format("-%d-%s", version, platform) :
|
||||
String.format("-%du%d-%s", version, update, platform));
|
||||
String.format("-%d-%s", version, flavor) :
|
||||
String.format("-%du%d-%s", version, update, flavor));
|
||||
|
||||
if (path == null) {
|
||||
path = filename; //System.getProperty("user.dir");
|
||||
}
|
||||
|
||||
//String url = "http://download.oracle.com/otn-pub/java/jdk/" +
|
||||
// https://edelivery.oracle.com/otn-pub/java/jdk/7u45-b18/jre-7u45-linux-i586.tar.gz
|
||||
String url = "https://edelivery.oracle.com/otn-pub/java/jdk/" +
|
||||
@@ -119,7 +165,7 @@ public class Downloader extends Task {
|
||||
if (conn.getResponseCode() == 200) {
|
||||
InputStream input = conn.getInputStream();
|
||||
BufferedInputStream bis = new BufferedInputStream(input);
|
||||
File outputFile = new File(folder, filename);
|
||||
File outputFile = new File(path); //folder, filename);
|
||||
BufferedOutputStream output =
|
||||
new BufferedOutputStream(new FileOutputStream(outputFile));
|
||||
int c = bis.read();
|
||||
|
||||
Reference in New Issue
Block a user