removing downloader bits (i.e. Oracle) that will not be used

This commit is contained in:
Ben Fry
2020-01-17 14:29:25 -05:00
parent bf3f728bce
commit 1ff826b843
8 changed files with 47 additions and 130 deletions
-1
View File
@@ -372,7 +372,6 @@
platform="${target-platform}${jdk.data.model}"
update="${jdk.update}"
build="${jdk.build}"
hash="${jdk.hash}"
component="JDK"
flavor="${jdk.downloader}"
path="${jdk.tgz.path}" />
+5 -1
View File
@@ -1,7 +1,11 @@
<?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="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="/processing-app/lib/ant.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
@@ -0,0 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
org.eclipse.jdt.core.compiler.compliance=11
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=11
@@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2019 The Processing Foundation
Copyright (c) 2019-20 The Processing Foundation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -23,12 +23,14 @@
* Utility to generate download URLs from AdoptOpenJDK.
*/
public class AdoptOpenJdkDownloadUrlGenerator extends DownloadUrlGenerator {
static private final String BASE_URL =
"https://github.com/AdoptOpenJDK/openjdk%d-binaries/releases/download/jdk-%d.%d.%d%%2B%d/OpenJDK%dU-%s_%d.%d.%d_%d.%s";
private static final String BASE_URL = "https://github.com/AdoptOpenJDK/openjdk%d-binaries/releases/download/jdk-%d.%d.%d%%2B%d/OpenJDK%dU-%s_%d.%d.%d_%d.%s";
@Override
public String buildUrl(String platform, String component, int train, int version, int update,
int build, String flavor, String hash) {
public String buildUrl(String platform, String component,
int train, int version, int update,
int build, String flavor) {
if (!component.equalsIgnoreCase("jdk")) {
throw new RuntimeException("Can only generate JDK download URLs for AdoptOpenJDK.");
@@ -53,6 +55,7 @@ public class AdoptOpenJdkDownloadUrlGenerator extends DownloadUrlGenerator {
);
}
/**
* Build a the filename (the "flavor") that is expected on AdoptOpenJDK.
*
@@ -72,6 +75,7 @@ public class AdoptOpenJdkDownloadUrlGenerator extends DownloadUrlGenerator {
}
}
/**
* Determine the download file extension.
*
+6 -5
View File
@@ -40,8 +40,9 @@ public abstract class DownloadUrlGenerator {
* @param flavor The flavor like "macosx-x64.dmg".
* @param hash The hash like "d54c1d3a095b4ff2b6607d096fa80163".
*/
public abstract String buildUrl(String platform, String component, int train, int version,
int update, int build, String flavor, String hash);
public abstract String buildUrl(String platform, String component,
int train, int version, int update,
int build, String flavor);
/**
* Get the cookie that should be used in downloading the target component.
@@ -64,10 +65,10 @@ public abstract class DownloadUrlGenerator {
* @param update The update (like 13).
* @param build The build number (like 133).
* @param flavor The flavor like "macosx-x64.dmg".
* @param hash The hash like "d54c1d3a095b4ff2b6607d096fa80163".
*/
public String getLocalFilename(String downloadPlatform, String component, int train, int version,
int update, int build, String flavor, String hash) {
public String getLocalFilename(String downloadPlatform, String component,
int train, int version, int update,
int build, String flavor) {
String baseFilename = component.toLowerCase();
+16 -45
View File
@@ -33,20 +33,14 @@ import org.apache.tools.ant.Task;
public class Downloader extends Task {
private static final boolean PRINT_LOGGING = true;
private boolean openJdk; // If using openJDK.
private String platform; // macos
private int train; // Java 11 (was 1 through Java 8)
private int version; // 0 (was 8 prior to Java 9)
private int update; // Update 131
private int build; // Build 11
// https://gist.github.com/P7h/9741922
// http://stackoverflow.com/q/10268583
private String hash; // d54c1d3a095b4ff2b6607d096fa80163
private String component; // "JRE", "JDK", or "JFX"
private String flavor; // Like "zip"
private int update; // Update 131
private int build; // Build 11
private String component; // "jre", "jdk", or "jfx"
private String flavor; // Like "zip"
private String path; // target path
@@ -55,6 +49,7 @@ public class Downloader extends Task {
**/
public Downloader() { }
/**
* Set the platform being used.
*
@@ -64,14 +59,6 @@ public class Downloader extends Task {
this.platform = platform;
}
/**
* Indicate if the OpenJDK is being used.
*
* @param openJdk True if OpenJDK is being used. False if Oracle JDK is being used.
*/
public void setOpenJdk(boolean openJdk) {
this.openJdk = openJdk;
}
/**
* Specify the build train being used.
@@ -82,6 +69,7 @@ public class Downloader extends Task {
this.train = train;
}
/**
* Set the version to download within the given build train.
*
@@ -91,6 +79,7 @@ public class Downloader extends Task {
this.version = version;
}
/**
* Set the update number to download within the given build train.
*
@@ -100,6 +89,7 @@ public class Downloader extends Task {
this.update = update;
}
/**
* Set the build number to download.
*
@@ -109,14 +99,6 @@ public class Downloader extends Task {
this.build = build;
}
/**
* Set the expected hash of the download.
*
* @param hash The hash set.
*/
public void setHash(String hash) {
this.hash = hash;
}
/**
* Indicate what component or release type of Java is being downloaded.
@@ -127,6 +109,7 @@ public class Downloader extends Task {
this.component = component;
}
/**
* Indicate the file flavor to be downloaded.
*
@@ -136,6 +119,7 @@ public class Downloader extends Task {
this.flavor = flavor;
}
/**
* Set the path to which the file should be downloaded.
*
@@ -145,6 +129,7 @@ public class Downloader extends Task {
this.path = path;
}
/**
* Download the JDK or JRE.
*/
@@ -167,11 +152,6 @@ public class Downloader extends Task {
throw new BuildException("You've gotta choose a flavor (macosx-x64.dmg, windows-x64.exe...)");
}
if (update >= 121 && hash == null) {
throw new BuildException("Starting with 8u121, a hash is required, see https://gist.github.com/P7h/9741922");
}
//download(path, jdk, platform, bits, version, update, build);
try {
download();
} catch (IOException e) {
@@ -179,6 +159,7 @@ public class Downloader extends Task {
}
}
/**
* Download the package from AdoptOpenJDK or Oracle.
*/
@@ -310,17 +291,9 @@ public class Downloader extends Task {
// Determine url generator
if (isJavaDownload) {
if (openJdk) {
downloadUrlGenerator = new AdoptOpenJdkDownloadUrlGenerator();
} else {
downloadUrlGenerator = new OracleDownloadUrlGenerator();
}
downloadUrlGenerator = new AdoptOpenJdkDownloadUrlGenerator();
} else if (isJfxDownload) {
if (openJdk) {
downloadUrlGenerator = new GluonHqDownloadUrlGenerator();
} else {
return Optional.empty(); // Nothing to download
}
downloadUrlGenerator = new GluonHqDownloadUrlGenerator();
} else {
throw new RuntimeException("Do not know how to download: " + component);
}
@@ -333,8 +306,7 @@ public class Downloader extends Task {
version,
update,
build,
flavor,
hash
flavor
);
String url = downloadUrlGenerator.buildUrl(
@@ -344,8 +316,7 @@ public class Downloader extends Task {
version,
update,
build,
flavor,
hash
flavor
);
return Optional.of(new DownloadItem(url, path, downloadUrlGenerator.getCookie()));
@@ -3,7 +3,7 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2014-19 The Processing Foundation
Copyright (c) 2014-20 The Processing Foundation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@@ -29,7 +29,7 @@ public class GluonHqDownloadUrlGenerator extends DownloadUrlGenerator {
@Override
public String buildUrl(String platform, String component, int train, int version, int update,
int build, String flavor, String hash) {
int build, String flavor) {
String platformLower = platform.toLowerCase();
@@ -1,72 +0,0 @@
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2014-19 The Processing Foundation
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
version 2, as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
import java.util.Optional;
/**
* Utility to generate the download URL from Oracle.
*/
public class OracleDownloadUrlGenerator extends DownloadUrlGenerator {
private static final String COOKIE =
"oraclelicense=accept-securebackup-cookie";
@Override
public String buildUrl(String platform, String component, int train, int version, int update,
int build, String flavor, String hash) {
if (!component.equalsIgnoreCase("jdk")) {
throw new RuntimeException("Can only generate JDK download URLs for Oracle.");
}
String filename = getLocalFilename(
platform,
component,
train,
version,
update,
build,
flavor,
hash
);
String url = "http://download.oracle.com/otn-pub/java/jdk/" +
(update == 0 ?
String.format("%d-b%02d/", version, build) :
String.format("%du%d-b%02d/", version, update, build));
// URL format changed starting with 8u121
if (update >= 121) {
url += hash + "/";
}
// Finally, add the filename to the end
url += filename;
return url;
}
public Optional<String> getCookie() {
return Optional.of(COOKIE);
}
}